Skip to content

Commit d53c237

Browse files
committed
chore(ci): add in cancellations for concurrent builds of the same branch
This PR introduces a change to the CI that we use in Metals that has really come in handy. The problem that this attempts to address is that sometimes during the day the Dotty CI gets really backed up. Many times when you look at why this is, it's because sometimes people push their branch 2 or 3 times shortly after one another will small changes. This then adds 3 full runs to CI when the vast majority of the time, the latest one is the one they actually care about. What this change does is cancels the previous one to run the latest. This _only_ does this on PRs, not on the main branch.
1 parent 7694985 commit d53c237

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ on:
2727
env:
2828
DOTTY_CI_RUN: true
2929

30+
concurrency:
31+
# Taken from scalameta/metals
32+
# On main, we don't want any jobs cancelled so the sha is used to name the group
33+
# On PR branches, we cancel the job if new commits are pushed
34+
# You can also bypass that making sure[no cancel] is in your pull request body
35+
group: ${{
36+
((github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
37+
&& format('contributor-pr-base-{0}', github.sha)
38+
|| format('contributor-pr-{0}', github.ref))
39+
&& !contains(github.event.pull_request.body, '[no cancel]')
40+
}}
41+
cancel-in-progress: true
42+
3043
# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
3144
# since it means that every container has the same weight which should be
3245
# equivalent to doing nothing, but it turns out that OpenJDK computes

0 commit comments

Comments
 (0)