Skip to content

Commit 07ef815

Browse files
chore(ci): add in cancellations for concurrent builds of the same branch (#17915)
I'd love to get others opinions on this. 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. EDIT: Following the meeting I added in the ability to include a `[no cancel]` to your PR body. When this is included concurrent builds will be allowed.
2 parents 5caa6aa + d75c896 commit 07ef815

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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

docs/_docs/contributing/sending-in-a-pr.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ Below are commonly used ones:
114114
| `[skip community_build_a]`| Skip the "a" community build |
115115
| `[skip docs]` | Skip the scaladoc tests |
116116

117+
#### Making sure every commit triggers a new run
118+
119+
By default the Dotty CI will cancel your previous runs if you push a new commit.
120+
This helps make sure the CI keeps moving without getting stuck running a ton of
121+
jobs if you push multiple times in a row. _However_, there are times you may
122+
want to run every commit. To do this, make sure your PR body contains `[no
123+
cancel]`. This will ensure that there are no cancellations of your previous
124+
runs.
125+
117126
### 7: Create your PR!
118127

119128
When the feature or fix is completed you should open a [Pull

0 commit comments

Comments
 (0)