Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid git commands when running against a fork #3095

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

artem-shelkovnikov
Copy link
Member

@artem-shelkovnikov artem-shelkovnikov commented Jan 10, 2025

See failure of CI in PR #3090: https://buildkite.com/elastic/connectors/builds/15589#01945040-19d0-4239-915a-173479f8aee8

++ git switch -
--
  | Warning: you are leaving 2 commits behind, not connected to
  | any of your branches:
  |  
  | 824f57b6 use rstrip for lists to remove whitespace
  | cf502ec0 remove '' as a space with trailing comma
  |  
  | If you want to keep them by creating a new branch, this may be a good time
  | to do so with:
  |  
  | git branch <new-branch-name> 824f57b6
  |  
  | Switched to branch 'main'
  | Your branch is up to date with 'origin/main'.
  | ++ git checkout meghanmurphy1:confluence-trailing-comma
  | error: pathspec 'meghanmurphy1:confluence-trailing-comma' did not match any file(s) known to git
  | 🚨 Error: The command exited with status 1
  | user command error: exit status 1

I happens because forks are not known to Buildkite agent. Forks will not by default give permissions to Elasitc agents, so we cannot really push anything into them. This PR just makes forks treated same way we treat main branch: just report failures, don't try to fix them.

@artem-shelkovnikov
Copy link
Member Author

buildkite test this

@artem-shelkovnikov
Copy link
Member Author

buildkite test this

@artem-shelkovnikov artem-shelkovnikov changed the title Testing sometinh Avoid git commands when running against a fork Jan 10, 2025
@artem-shelkovnikov artem-shelkovnikov marked this pull request as ready for review January 10, 2025 13:25
@artem-shelkovnikov artem-shelkovnikov requested a review from a team as a code owner January 10, 2025 13:25
Copy link
Member

@jedrazb jedrazb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@@ -34,3 +34,11 @@ is_pr() {
return 0 # true
fi
}

is_fork() {
if [ "BUILDKITE_PULL_REQUEST_REPO" = "https://github.com/elastic/connectors.git"]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 is false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun unix stuff :D Functions actually return exit codes, not regular variables:

https://stackoverflow.com/questions/17336915/return-value-in-a-bash-function

So 0 = "all good", non-0 are "something is wrong"

@artem-shelkovnikov artem-shelkovnikov merged commit 51c88b4 into elastic:main Jan 10, 2025
2 checks passed
Copy link

💔 Failed to create backport PR(s)

The backport operation could not be completed due to the following error:
There are no branches to backport to. Aborting.

The backport PRs will be merged automatically after passing CI.

To backport manually run:
backport --pr 3095 --autoMerge --autoMergeMethod squash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants