Cancel superseded pull request CI runs - #1267
Merged
Merged
Conversation
A push to a pull request left the run already in flight to finish, so every follow-up commit paid for a full matrix whose result nobody would read. Java CI runs nine jobs per run across three operating systems, and macOS and Windows runners bill at a multiple of Linux, so a superseded run is not cheap. Both workflows that react to pull_request now group by pull request number and cancel the run in progress when a new commit arrives. Pushes group by ref and set cancel-in-progress to false, so every commit on main still gets a full build, and the allowlist check stays a usable required status: only superseded runs are cancelled, and the run for the head commit always completes.
jzonthemtn
approved these changes
Sep 4, 2026
krickert
reviewed
Sep 5, 2026
krickert
left a comment
Contributor
There was a problem hiding this comment.
Good idea, straightforward.. thanks for doing this.
krickert
approved these changes
Sep 5, 2026
krickert
left a comment
Contributor
There was a problem hiding this comment.
Good idea, straightforward.. thanks for doing this.
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.
Pushing a new commit to a PR currently leaves the run already in flight to finish. Nobody reads that result — the newer commit supersedes it — but it still occupies runners to completion.
Java CIruns nine jobs per run: a 3 OS × 2 JDK build matrix (fail-fast: false) plus three shell-test jobs, and macOS and Windows runners bill at a multiple of Linux. So a superseded run is not a rounding error.How often this happens
Sampling the last 100
maven.ymlpull_request runs (52 branches), 9 had a newer commit arrive while they were still running — ~9%. Median PR run is ~11 minutes of wall-clock across those nine jobs. Branches with the most, unsurprisingly, are the ones under active review.The change
Both workflows that react to
pull_requestget:What is deliberately not cancelled
main. They fall to thegithub.refgroup andcancel-in-progressevaluates tofalse, so every commit on main still gets a full build. Cancelling those would leave commits without a result and could interfere withRegenerate NOTICEandPublish snapshot artifacts.license.ymlandpublish-snapshots.ymlare untouched — both are push-to-main-only, andlicense.ymlcommits back to the repo, so cancelling it mid-run is exactly what we don't want. (Serialising snapshot publishes withcancel-in-progress: falsemight be worth a separate look, but it is a different problem from this one.)Note on the required status check
ASF Allowlist Checkis a required check via.asf.yaml. Cancellation only ever hits runs for superseded commits; the run for the head commit always completes and reports. So the required check keeps behaving as before.concurrencyis a core Actions feature, not an action reference, so the ASF allowlist doesn't apply to it.