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

Concurrency for build job #4997

Merged
merged 1 commit into from
Mar 17, 2023
Merged

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Mar 17, 2023

Concurrency will cancel jobs that are obsolete because they have been superseded by a new job, for example if a new commit was pushed to a branch that has a pull request.

In order for this to work properly, the "concurrency group" needs to be defined correctly for the job.

This PR defines the "concurrency group" thus:

a+${{ github.event_name }}
b+${{ github.workflow_ref }}
c+${{ github.job }}
d+${{ matrix.ghc }}
e+${{ matrix.cabal }}
f+${{ matrix.os }}
g+${{ (startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && github.run_id) || github.event.pull_request.number || github.ref }}

The <letter>+ prefix makes it easy to line up with debugging in the build output.

An example concurrency group looks like this:

a+push
b+input-output-hk/cardano-node/.github/workflows/haskell-linux.yml@refs/heads/newhoggy/concurrency-for-build-job
c+linux_ci
d+8.10.7
e+3.8.1.0
f+ubuntu-latest
g+refs/heads/newhoggy/concurrency-for-build-job

These were carefully chosen so that within the same PR request, old jobs are cancelled, but when jobs are created in the job queue, those jobs never get cancelled, because they always get a unique concurrency group.

@newhoggy newhoggy force-pushed the newhoggy/concurrency-for-build-job branch 8 times, most recently from 09f7aa6 to 029cd44 Compare March 17, 2023 05:28
@newhoggy newhoggy marked this pull request as ready for review March 17, 2023 05:29
@newhoggy newhoggy requested review from Jimbo4350 and a team as code owners March 17, 2023 05:29
@newhoggy newhoggy force-pushed the newhoggy/concurrency-for-build-job branch from 029cd44 to 4d00dc2 Compare March 17, 2023 05:30
@newhoggy newhoggy requested review from angerman and erikd March 17, 2023 05:33
@angerman
Copy link
Contributor

To be honest, I'm not sure we are being too overly specific here. But that would rather end up in too few cancelled builds, than too many, so I'm good with a conservative approach as taken here.

@newhoggy newhoggy merged commit 26125a0 into master Mar 17, 2023
@newhoggy newhoggy deleted the newhoggy/concurrency-for-build-job branch March 17, 2023 06:04
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