Rollup merge of #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`
This commit is contained in:
Matthias Krüger 2023-06-26 11:58:45 +02:00 committed by GitHub
commit 5d9935a638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 34 deletions

View File

@ -30,10 +30,11 @@ permissions:
defaults: defaults:
run: run:
shell: bash shell: bash
concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true
jobs: jobs:
pr: pr:
permissions:
actions: write
name: "PR - ${{ matrix.name }}" name: "PR - ${{ matrix.name }}"
env: env:
CI_JOB_NAME: "${{ matrix.name }}" CI_JOB_NAME: "${{ matrix.name }}"
@ -84,11 +85,6 @@ jobs:
- name: ensure the channel matches the target branch - name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB
- name: configure GitHub Actions to kill the build when outdated
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
with:
github_token: "${{ secrets.github_token }}"
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
- name: collect CPU statistics - name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB
@ -162,8 +158,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
auto: auto:
permissions:
actions: write
name: "auto - ${{ matrix.name }}" name: "auto - ${{ matrix.name }}"
env: env:
CI_JOB_NAME: "${{ matrix.name }}" CI_JOB_NAME: "${{ matrix.name }}"
@ -496,11 +490,6 @@ jobs:
- name: ensure the channel matches the target branch - name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB
- name: configure GitHub Actions to kill the build when outdated
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
with:
github_token: "${{ secrets.github_token }}"
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
- name: collect CPU statistics - name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB
@ -574,8 +563,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
try: try:
permissions:
actions: write
name: "try - ${{ matrix.name }}" name: "try - ${{ matrix.name }}"
env: env:
DIST_TRY_BUILD: 1 DIST_TRY_BUILD: 1
@ -623,11 +610,6 @@ jobs:
- name: ensure the channel matches the target branch - name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB
- name: configure GitHub Actions to kill the build when outdated
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
with:
github_token: "${{ secrets.github_token }}"
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
- name: collect CPU statistics - name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB if: success() && !env.SKIP_JOB

View File

@ -147,13 +147,6 @@ x--expand-yaml-anchors--remove:
run: src/ci/scripts/verify-channel.sh run: src/ci/scripts/verify-channel.sh
<<: *step <<: *step
- name: configure GitHub Actions to kill the build when outdated
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
with:
github_token: "${{ secrets.github_token }}"
if: success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'
<<: *step
- name: collect CPU statistics - name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh run: src/ci/scripts/collect-cpu-stats.sh
<<: *step <<: *step
@ -305,10 +298,14 @@ defaults:
# shell is PowerShell.) # shell is PowerShell.)
shell: bash shell: bash
concurrency:
# For a given workflow, if we push to the same PR, cancel all previous builds on that PR.
# If the push is not attached to a PR, we will cancel all builds related to the same commit SHA.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
pr: pr:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job <<: *base-ci-job
name: PR - ${{ matrix.name }} name: PR - ${{ matrix.name }}
env: env:
@ -331,8 +328,6 @@ jobs:
<<: *job-linux-16c <<: *job-linux-16c
auto: auto:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job <<: *base-ci-job
name: auto - ${{ matrix.name }} name: auto - ${{ matrix.name }}
env: env:
@ -734,8 +729,6 @@ jobs:
<<: *job-windows-8c <<: *job-windows-8c
try: try:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job <<: *base-ci-job
name: try - ${{ matrix.name }} name: try - ${{ matrix.name }}
env: env: