Skip to content

Commit

Permalink
chore(ci): add in cancellations for concurrent builds of the same branch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ckipp01 committed Jun 13, 2023
1 parent 7694985 commit d53c237
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ on:
env:
DOTTY_CI_RUN: true

concurrency:
# Taken from scalameta/metals
# On main, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# You can also bypass that making sure[no cancel] is in your pull request body
group: ${{
((github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
&& format('contributor-pr-base-{0}', github.sha)
|| format('contributor-pr-{0}', github.ref))
&& !contains(github.event.pull_request.body, '[no cancel]')
}}
cancel-in-progress: true

# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
# since it means that every container has the same weight which should be
# equivalent to doing nothing, but it turns out that OpenJDK computes
Expand Down

0 comments on commit d53c237

Please sign in to comment.