summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Nordgren <haraldnordgren@gmail.com>2026-08-31 16:18:15 +0000
committerJunio C Hamano <gitster@pobox.com>2026-08-31 11:05:35 -0700
commita251b1bd213cc2991ad17c78f2cfe0fad826a159 (patch)
tree1b95d8395bf2632ee551cdf1deb683a7c3aa3e3d
parente9019fcafe0040228b8631c30f97ae1adb61bcdc (diff)
ci: cancel stale pull request workflow runs
The CI workflow groups all runs by commit hash using `group: ${{ github.sha }}`. This means every push to a pull request starts a separate workflow run, and all workflows triggered by the same commit share the same concurrency group. With this change, pull request runs are grouped by pull request number instead of commit hash, and runs superseded by a newer push are canceled. The concurrency group becomes `${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}` and `cancel-in-progress` is set to true for pull request events. For pull request events, the group is `<workflow>-<pull-request-number>` (e.g., "main-workflow-42"). If you push a new commit to an existing pull request before the CI working on it finishes, the new request will be placed in the same group and cancel the currently running run. For non-pull-request events, the group is `${{ github.workflow }}-${{ github.sha }}` and `cancel-in-progress` defaults to false, so there is no regression in behavior. Note that the previous configuration used `group: ${{ github.sha }}`, which meant all workflows sharing the same commit hash were in the same group. The new configuration includes the workflow name in the group, so each workflow has its own concurrency group per commit/PR. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--.github/workflows/main.yml20
1 files changed, 11 insertions, 9 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index cf341d74db..6b56c36996 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -5,18 +5,20 @@ on: [push, pull_request]
env:
DEVELOPER: 1
-# If more than one workflow run is triggered for the very same commit hash
-# (which happens when multiple branches pointing to the same commit), only
-# the first one is allowed to run, the second will be kept in the "queued"
-# state. This allows a successful completion of the first run to be reused
-# in the second run via the `skip-if-redundant` logic in the `config` job.
+# For pull requests, only the latest workflow run is allowed to proceed.
+# Older runs are canceled when a new revision is pushed.
#
-# The only caveat is that if a workflow run is triggered for the same commit
-# hash that another run is already being held, that latter run will be
-# canceled. For more details about the `concurrency` attribute, see:
+# For pushes, if more than one workflow run is triggered for the very same
+# commit hash (which happens when multiple branches point to the same commit),
+# only the first one is allowed to run. This allows a successful completion of
+# the first run to be reused in the second run via the `skip-if-redundant`
+# logic in the `config` job.
+#
+# For more details about the `concurrency` attribute, see:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
- group: ${{ github.sha }}
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
ci-config: