ci: cancel previous CI runs on Pull Requests #961
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #959
Please provide a detailed description of the changes made in this pull request.
Added github concurrency the workflow level in order to cancel previous runs.
Added to all workflows that run on PRs which could technically face this issue.
Explanation:
Concurrency works by only running a workflow (or job) one at a time. They are normally queued (and cancelled) based on their
group
name.github.workflow
) in order for different workflows to not interfere with one another.github.head_ref || github.run_id
ensures that concurrency only run on pull requests. How?github.head_ref
is pull_request specific based on source branch. So only during pull requests will it get a value.head_ref
is empty, then it's not a pull requests and resorts torun_id
.run_id
is a unique id generated per-run, so on non-PR runs it'll be unique, and multiple pushes tomain
's runs won't affect one-another.cancel-in-progress: true
ensures that when multiple workflows are ran in the same group, the in-progress ones get cancelled in favor of the latest runs.Therefore, only per PR run it'll have name
workflowName-prHeadRef
, and on sequential runs on the same PR, each new workflow will be part of their respective groups and be affected by the concurrency.Checklists...
Contributors Checklist
BREAKING CHANGE: xxx
message was included in the descriptionMaintainers Checklist
CONTRIBUTING.md
BREAKING CHANGE:
in the body)