-
Notifications
You must be signed in to change notification settings - Fork 299
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
Replace styfle/cancel-workflow-action with new GitHub concurrency:
standard
#2316
Conversation
due to #2297 |
1d58d2f
to
e639148
Compare
.github/workflows/build.yml
Outdated
@@ -34,6 +34,10 @@ env: | |||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true | |||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: "fhir" # change this to invalidate cache | |||
|
|||
concurrency: | |||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the run_id is included here in the group id, does this not mean that each run will have a separate group id? and does that mean previous runs will not be cancelled?
actually, if the head_ref is part of this, how would cancellation even help anything? shouldn't we cancel jobs that are in the same branch? i.e. if you push a new commit we should cancel the previous job?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now had a closer look at related docs about this (e.g. https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) and, as far as I understand it, believe this to be correct as-is, because:
- those
||
are fallback values (not "concatenations") so my understanding is that e.g. therun_id
would not be included as long as ahead_ref
or elseref
was non-NIL - the
head_ref
is (quote) "the source branch of the pull request in a workflow run" - which will (should, based on doc) cancel jobs that are in the same branch - I think? But note that, quote: "This property is only available when the event that triggers a workflow run is either pull_request or pull_request_target." ... - ... so the
ref
is a fallback to (quote) "(...) For workflows triggered by push, this is the branch or tag ref that was pushed (...) " From the doc it seems like it may actually be sufficient to use only this, but given that http://go/github-actions#cancel-workflows suggests to use the combination, I went with that; I suspect it can't harm to be double extra safe - lastly, the
run_id
is a last fallback is something I thought I saw on some example yesterday. I'm not sure if this will be used, but given thatref
docs says that it's "only set if a branch or tag is available for the event type" it seems like a sensible pre-caution as a last resort? I can also remove it, if you think it's confusing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks michael for the explanation.
this is clear to me now.
up to you about the run_id. but either way can we add a single line of comment to explain what's happening here? doesn't have to go to the length of your comment above, but just noting that we're using the branch/pr ref etc so possible to cancel previous runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once addressed please feel free to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed github.run_id
and added inline documentation comments; I will self merge when build is green.
FTR: I "tested" this by clicking the Update Branch button, and seeing https://github.com/google/android-fhir/actions/runs/6696513296 got cancelled. I'm going to merge this now, without waiting for Kokoro, because this is a GitHub-Action-only change, which cannot impact Firebase Test Lab runs (so Kokoro's result is irrelevant in this particular case). |
See https://github.com/styfle/cancel-workflow-action/blob/main/README.md (and go/github-actions#cancel-workflows)
I've intentionally raised this separately from #2313 (which is included here) and #2314 (which builds on this) to make it easier to review, and revert in case it's needed because this unexpectedly breaks anything (which it should not).
This should be rebased after #2313 is merged.