Skip to content

Commit 5d9935a

Browse files
authored
Rollup merge of rust-lang#112955 - Kobzol:ci-pr-cancel-workflows, r=Mark-Simulacrum
CI: cancel in-progress workflow runs after a push Experimenting with the `concurrency` attribute. r? `@Mark-Simulacrum`
2 parents de79f51 + e8973ea commit 5d9935a

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

.github/workflows/ci.yml

+3-21
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ permissions:
3030
defaults:
3131
run:
3232
shell: bash
33+
concurrency:
34+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
35+
cancel-in-progress: true
3336
jobs:
3437
pr:
35-
permissions:
36-
actions: write
3738
name: "PR - ${{ matrix.name }}"
3839
env:
3940
CI_JOB_NAME: "${{ matrix.name }}"
@@ -84,11 +85,6 @@ jobs:
8485
- name: ensure the channel matches the target branch
8586
run: src/ci/scripts/verify-channel.sh
8687
if: success() && !env.SKIP_JOB
87-
- name: configure GitHub Actions to kill the build when outdated
88-
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
89-
with:
90-
github_token: "${{ secrets.github_token }}"
91-
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
9288
- name: collect CPU statistics
9389
run: src/ci/scripts/collect-cpu-stats.sh
9490
if: success() && !env.SKIP_JOB
@@ -162,8 +158,6 @@ jobs:
162158
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
163159
if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
164160
auto:
165-
permissions:
166-
actions: write
167161
name: "auto - ${{ matrix.name }}"
168162
env:
169163
CI_JOB_NAME: "${{ matrix.name }}"
@@ -496,11 +490,6 @@ jobs:
496490
- name: ensure the channel matches the target branch
497491
run: src/ci/scripts/verify-channel.sh
498492
if: success() && !env.SKIP_JOB
499-
- name: configure GitHub Actions to kill the build when outdated
500-
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
501-
with:
502-
github_token: "${{ secrets.github_token }}"
503-
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
504493
- name: collect CPU statistics
505494
run: src/ci/scripts/collect-cpu-stats.sh
506495
if: success() && !env.SKIP_JOB
@@ -574,8 +563,6 @@ jobs:
574563
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
575564
if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
576565
try:
577-
permissions:
578-
actions: write
579566
name: "try - ${{ matrix.name }}"
580567
env:
581568
DIST_TRY_BUILD: 1
@@ -623,11 +610,6 @@ jobs:
623610
- name: ensure the channel matches the target branch
624611
run: src/ci/scripts/verify-channel.sh
625612
if: success() && !env.SKIP_JOB
626-
- name: configure GitHub Actions to kill the build when outdated
627-
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
628-
with:
629-
github_token: "${{ secrets.github_token }}"
630-
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
631613
- name: collect CPU statistics
632614
run: src/ci/scripts/collect-cpu-stats.sh
633615
if: success() && !env.SKIP_JOB

src/ci/github-actions/ci.yml

+6-13
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ x--expand-yaml-anchors--remove:
147147
run: src/ci/scripts/verify-channel.sh
148148
<<: *step
149149

150-
- name: configure GitHub Actions to kill the build when outdated
151-
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
152-
with:
153-
github_token: "${{ secrets.github_token }}"
154-
if: success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'
155-
<<: *step
156-
157150
- name: collect CPU statistics
158151
run: src/ci/scripts/collect-cpu-stats.sh
159152
<<: *step
@@ -305,10 +298,14 @@ defaults:
305298
# shell is PowerShell.)
306299
shell: bash
307300

301+
concurrency:
302+
# For a given workflow, if we push to the same PR, cancel all previous builds on that PR.
303+
# If the push is not attached to a PR, we will cancel all builds related to the same commit SHA.
304+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
305+
cancel-in-progress: true
306+
308307
jobs:
309308
pr:
310-
permissions:
311-
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
312309
<<: *base-ci-job
313310
name: PR - ${{ matrix.name }}
314311
env:
@@ -331,8 +328,6 @@ jobs:
331328
<<: *job-linux-16c
332329

333330
auto:
334-
permissions:
335-
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
336331
<<: *base-ci-job
337332
name: auto - ${{ matrix.name }}
338333
env:
@@ -734,8 +729,6 @@ jobs:
734729
<<: *job-windows-8c
735730

736731
try:
737-
permissions:
738-
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
739732
<<: *base-ci-job
740733
name: try - ${{ matrix.name }}
741734
env:

0 commit comments

Comments
 (0)