Skip to content

Commit

Permalink
Avoid git commands when running against a fork (#3095)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-shelkovnikov authored Jan 10, 2025
1 parent e9a6739 commit 51c88b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 3 additions & 4 deletions .buildkite/run_linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
set -euo pipefail

source .buildkite/shared.sh
source .buildkite/publish/git-setup.sh

init_python

if is_pr; then
if is_pr && ! is_fork; then
echo "We're on PR, running autoformat"
if ! make autoformat ; then
echo "make autoformat ran with errors, exiting"
Expand All @@ -19,6 +18,7 @@ if is_pr; then
echo "Nothing to be fixed by autoformat"
exit 0
else
source .buildkite/publish/git-setup.sh
git --no-pager diff
echo "linting errors are fixed, pushing the diff"
export GH_TOKEN="$VAULT_GITHUB_TOKEN"
Expand All @@ -30,10 +30,9 @@ if is_pr; then
exit 1
fi
else
echo "We're not on PR, running only linter"
echo "We're not on PR or running against a fork, running only linter"
# On non-PR branches the bot has no permissions to open PRs.
# Theoretically this would never fail because we always ask
# linter to succeed to merge. It can fail intermittently?
make lint
return
fi
4 changes: 2 additions & 2 deletions .buildkite/run_notice_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
set -euo pipefail

source .buildkite/shared.sh
source .buildkite/publish/git-setup.sh

init_python

Expand All @@ -14,7 +13,8 @@ if [ -z "$(git status --porcelain | grep NOTICE.txt)" ]; then
exit 0
else
git --no-pager diff
if is_pr; then
if is_pr && ! is_fork; then
source .buildkite/publish/git-setup.sh
export GH_TOKEN="$VAULT_GITHUB_TOKEN"

git add NOTICE.txt
Expand Down
8 changes: 8 additions & 0 deletions .buildkite/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ is_pr() {
return 0 # true
fi
}

is_fork() {
if [ "BUILDKITE_PULL_REQUEST_REPO" = "https://github.com/elastic/connectors.git"]; then
return 1 # false
else
return 0 # true
fi
}

0 comments on commit 51c88b4

Please sign in to comment.