Skip to content

Conversation

adombeck
Copy link
Contributor

Our CI jobs run for a long time and use a lot of resources.

It happens quite often to me that, after I push something to a PR, I find something to small to fix (e.g. improve the commit message) and push that fix soon after. We can save some resources by automatically cancelling in-progress workflows on new pushes to the same branch (I do that manually sometimes, but that's wasting my time).

The implementation is directly from the example of the concurrency keyword: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-using-concurrency-and-the-default-behavior

Our CI jobs run for a long time and use a lot of resources.

It happens quite often to me that, after I push something to a PR, I
find something to small to fix (e.g. improve the commit message) and
push that fix soon after. We can save some resources by automatically
cancelling in-progress workflows on new pushes to the same branch (I do
that manually sometimes, but that's wasting my time).

The implementation is directly from the example of the concurrency keyword:
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-using-concurrency-and-the-default-behavior
@adombeck adombeck marked this pull request as ready for review September 11, 2025 10:43
@adombeck adombeck requested a review from a team as a code owner September 11, 2025 10:43
@adombeck
Copy link
Contributor Author

adombeck commented Sep 11, 2025

@denisonbarbosa @3v1n0 @didrocks What do you think about that? Should we do it in other repos too (e.g. the ubuntu-pro-for-wsl repo, which starts more than 30 jobs per workflow run)?

@didrocks
Copy link
Member

I think this is indeed a nice one and we should standardize concurrrency across those.

I have one question as it’s unclear from the documentation: is the tag limitting concurrency on each workflow, or is it like a mutex limiting all workflows concurrent run? I think it’s per workflow (otherwise, you would have some cancellation on this PR), but just checking.

@adombeck
Copy link
Contributor Author

is the tag limitting concurrency on each workflow, or is it like a mutex limiting all workflows concurrent run?

Which workflows are cancelled depends on the concurrency group. By defining the group as ${{ github.workflow }}-${{ github.ref }}, which, IIUC, resolves to something like qa-main, we are applying a concurrency limit on the workflow + branch name. So the QA workflow can run once per branch. If you push again, and there is already a QA workflow running for the same branch, that is being cancelled.

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

Successfully merging this pull request may close these issues.

2 participants