From c4673f11fc3c456fa7f3df87e956156a3df69b25 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:24:25 +0000 Subject: [PATCH] CI: Cancel obsolete concurrent GitHub Actions workflow jobs (#1940) If a new push happens to a staging branch or a PR branch, continuing to run now-obsolete tests is pointless and wasteful. However, we do want to finish any jobs running on previous master branch commits, so that every master branch commit has full test results. --- .github/workflows/quick.yaml | 6 ++++++ .github/workflows/slow.yaml | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/quick.yaml b/.github/workflows/quick.yaml index affa40466b..aad03461d4 100644 --- a/.github/workflows/quick.yaml +++ b/.github/workflows/quick.yaml @@ -16,6 +16,12 @@ on: # test PRs targeting this branch code branches: [ "master" ] +concurrency: + # Cancel ongoing tests in case of push to the same PR or staging branch, + # but let previous master commit tests complete. + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + env: # empty except for pull_request events PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/slow.yaml b/.github/workflows/slow.yaml index 6604bb9ec0..0d60fa04ed 100644 --- a/.github/workflows/slow.yaml +++ b/.github/workflows/slow.yaml @@ -14,6 +14,11 @@ on: push: branches: [ "auto" ] +concurrency: + # Cancel ongoing tests in case of push to staging branch. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: linux-distros: -- 2.47.3