Repository navigation
Conversation
For merge_group events, github.ref contains the base SHA, so the workflow-level concurrency group changes every time the merge queue rebuilds a PR's group and the previous run is never cancelled. Compute the PR number from the ref in a small job and use it in a job-level concurrency group on pr-ci. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
tarekziade
reviewed
Nov 25, 2026
tarekziade
left a comment
Collaborator
There was a problem hiding this comment.
some stuff to fix, and I guess we'll need to try it
| # group above differs each time the merge queue rebuilds a PR's merge group (e.g. another PR landed on `main`) and the | ||
| # previous run of the same PR is not cancelled. No context exposes `<N>` alone and expressions can't extract it, so we | ||
| # compute it here and use it in a job-level concurrency group below. | ||
| concurrency-key: |
Collaborator
There was a problem hiding this comment.
don't run it on all events, we can use
if: github.event_name == 'merge_group'
| # previous run of the same PR is not cancelled. No context exposes `<N>` alone and expressions can't extract it, so we | ||
| # compute it here and use it in a job-level concurrency group below. | ||
| concurrency-key: | ||
| runs-on: ubuntu-22.04 |
Collaborator
There was a problem hiding this comment.
nit: we can use ubuntu-slim to speed up
| pr-ci: | ||
| needs: concurrency-key | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ needs.concurrency-key.outputs.key }} |
Collaborator
There was a problem hiding this comment.
we need somehting like
group: ${{ github.workflow }}-${{ needs.concurrency-key.outputs.key || format('run-{0}', github.run_id) }}
Without it, every skipped event would get the same group PR CI- and they would cancel each other.
| fi | ||
|
|
||
| pr-ci: | ||
| needs: concurrency-key |
Collaborator
There was a problem hiding this comment.
we should add
if: ${{ !cancelled() && needs.concurrency-key.result != 'failure' }}
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When a PR is in the merge queue and another PR lands on
mainfirst, the queue rebuilds the PR's merge group and triggers a newPR CIrun, but the previous run of the same PR keeps running until it finishes.Example (2026-11-25), PR #51200:
gh-readonly-queue/main/pr-51200-21adb7e…: 10:00 → 10:19gh-readonly-queue/main/pr-51200-37fdf62…: 10:13 → 10:30Both runs completed; they overlapped for ~6 minutes.
Why the current
concurrencydoesn't cancel itFor
merge_groupevents,github.event.pull_request.numberis empty, so the workflow-level group falls back togithub.ref=refs/heads/gh-readonly-queue/main/pr-<N>-<base_sha>. The base SHA changes on every rebuild, so the new run is in a different group andcancel-in-progressnever applies.At workflow level only the
github/inputs/varscontexts are available. No field of themerge_grouppayload contains the PR number alone, and expressions have no substring/regex function to extract it. Other projects report the same limitation, e.g. dotCMS/core#38143, pyrite-wiki/pyrite#1189.Change
concurrency-key(a few seconds): extracts<N>from the merge-queue ref and outputsmerge-queue-<base>-pr-<N>. For all other events it outputsrun-<run_id>(unique per run).pr-cigets a job-levelconcurrencygroup built from that output, withcancel-in-progress: true. Job-level concurrency can useneeds.*outputs, and its groups apply across runs, so a new merge-queue run of PR N cancels the runningpr-cijob of the previous run of PR N.mainstill don't cancel each other).Not verified
pr-cijob (which calls a reusable workflow) is expected to cancel all jobs inside the reusable workflow; not tested.🤖 Generated with Claude Code