From: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Harald Nordgren <haraldnordgren@gmail.com>,
Harald Nordgren <haraldnordgren@gmail.com>
Subject: [PATCH v2] ci: cancel stale pull request workflow runs
Date: Sun, 30 Aug 2026 10:59:20 +0000 [thread overview]
Message-ID: <pull.2369.v2.git.git.1788087560290.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2369.git.git.1785492641983.gitgitgadget@gmail.com>
From: Harald Nordgren <haraldnordgren@gmail.com>
The CI workflow previously grouped all runs by commit hash using
`group: ${{ github.sha }}`. This meant every push to a pull
request started a separate workflow run, and all workflows
triggered by the same commit shared 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>
---
ci: cancel stale pull request workflow runs
Group CI workflow runs by pull request and cancel older revisions so
only the latest push consumes runner capacity.
Changes in v2:
* Explain behavior in commit message.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2369%2FHaraldNordgren%2Fcancel-stale-pr-ci-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2369/HaraldNordgren/cancel-stale-pr-ci-v2
Pull-Request: https://github.com/git/git/pull/2369
Range-diff vs v1:
1: a0a618d8cc ! 1: 2773cc5a84 ci: cancel stale pull request workflow runs
@@ Metadata
## Commit message ##
ci: cancel stale pull request workflow runs
- The CI workflow groups runs by commit hash, so every push to a pull
- request starts a separate workflow run. Group pull request runs by pull
- request number and cancel runs superseded by a newer push, while keeping
- push events grouped by commit hash for the skip-if-redundant behavior.
+ The CI workflow previously grouped all runs by commit hash using
+ `group: ${{ github.sha }}`. This meant every push to a pull
+ request started a separate workflow run, and all workflows
+ triggered by the same commit shared 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>
.github/workflows/main.yml | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 205325eb33..4fff344874 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:
base-commit: c73e85354c275c9d409b26445089bc16940fc527
--
gitgitgadget
prev parent reply other threads:[~2026-08-30 10:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 10:10 [PATCH] ci: cancel stale pull request workflow runs Harald Nordgren via GitGitGadget
2026-08-21 11:14 ` Harald Nordgren
2026-08-26 19:54 ` Junio C Hamano
2026-08-30 10:59 ` Harald Nordgren via GitGitGadget [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2369.v2.git.git.1788087560290.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=haraldnordgren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox