-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix git ls-remote command when running sg-bridge #140
Fix git ls-remote command when running sg-bridge #140
Conversation
310b916
to
c3e45eb
Compare
Can you describe the problem that this fixes? I have a guess based on working through it, but would like to be sure. My understanding (subject to correction!) based on reading the github docs[1] is:
So AFAICT this change does two things:
Is the problem that If that's the problem you're trying to solve, and you'd like to preserve the push workflow, then the following might work: This will default to using the bare branch name in GITHUB_HEAD_REF when it's available in a PR, and will fall back to parsing it out of the GITHUB_REF when operating on a branch in a push workflow, where "refs/heads" will be correct. [1] https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables |
While working on other patches, I noticed that the action of looking for an existing branch with the same name in the sg-core repository was not really being honored. Digging into it, I got to the Github documentation here https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables, which states the following GITHUB_REF: The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by push, this is the branch or tag ref that was pushed. For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1. For how our CI work, we trigger this action on PRs. So the resulting value for this variable would be refs/pull/<pr_number>/merge. So we never actually pick up if there is a branch with the same name. I wanted to fix that by constructing the path. Maybe I misunderstood the actual use case of this action? |
Reading over your explanation I don't think you've misunderstood at all! I was trying to work out what was broken and why without any details, and it seems my guesses were correct. My feedback is that the solution appears like it will break the push workflow. I have suggested an alternative solution that I think is more straightforward to read and doesn't break that workflow. I'm happy to approve this if you're sure the push workflow is not necessary. |
Thanks for the review and sorry for the lack of context in my pull request. Next time I will provide more details for reviewers to work with. I agree that this proposed patch breaks the push workflow and that is, indeed, an unintended change. I was not sure how to properly fix the issue I was seeing. I will submit your suggested fix instead. Thanks Chris! |
GITHUB_HEAD_REF points to the head ref or source branch of the pull request in a workflow run. GITHUB_REF points to the pull request merge branch. The ref given is fully-formed, meaning that for pull requests it is refs/pull/<pr_number>/merge We should use the former to achieve the retrieving a branch with the same name
Default to using the bare branch name in GITHUB_HEAD_REF when it's available in a PR, and will fall back to parsing it out of the GITHUB_REF when operating on a branch in a push workflow, where "refs/heads" will be correct.
dbab849
to
04fe580
Compare
Build failed (check pipeline). Post https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/63ac85237f88451696d388e611f8fb4c ❌ stf-crc-ocp_414-local_build RETRY_LIMIT in 16m 53s |
recheck |
Fix git ls-remote command in the integration suite
The syntax should be refs/heads/GITHUB_REF