Skip to content

Cancel superseded pull request CI runs - #1267

Merged
rzo1 merged 1 commit into
mainfrom
ci-cancel-superseded-pr-runs
Sep 5, 2026
Merged

Cancel superseded pull request CI runs#1267
rzo1 merged 1 commit into
mainfrom
ci-cancel-superseded-pr-runs

Conversation

@rzo1

@rzo1 rzo1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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 CI runs 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.yml pull_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_request get:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

What is deliberately not cancelled

  • Pushes to main. They fall to the github.ref group and cancel-in-progress evaluates to false, so every commit on main still gets a full build. Cancelling those would leave commits without a result and could interfere with Regenerate NOTICE and Publish snapshot artifacts.
  • license.yml and publish-snapshots.yml are untouched — both are push-to-main-only, and license.yml commits back to the repo, so cancelling it mid-run is exactly what we don't want. (Serialising snapshot publishes with cancel-in-progress: false might be worth a separate look, but it is a different problem from this one.)

Note on the required status check

ASF Allowlist Check is 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.

concurrency is a core Actions feature, not an action reference, so the ASF allowlist doesn't apply to it.

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.
@rzo1
rzo1 requested a review from krickert September 4, 2026 18:40
@rzo1 rzo1 self-assigned this Sep 4, 2026

@krickert krickert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, straightforward.. thanks for doing this.

@krickert krickert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, straightforward.. thanks for doing this.

@rzo1
rzo1 merged commit 535c6d4 into main Sep 5, 2026
10 checks passed
@rzo1
rzo1 deleted the ci-cancel-superseded-pr-runs branch September 5, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants