Skip to content

Cancel main's older CI run when a newer merge lands - #52

Merged
gshost1 merged 1 commit into
mainfrom
chore/ci-cancel-superseded
Nov 7, 2026
Merged

gshost1 merged 1 commit into
mainfrom
chore/ci-cancel-superseded

Conversation

@gshost1

@gshost1 gshost1 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

What and why
On Nov 6 at 18:39, merging eleven PRs started eleven full CI runs on main. Each needed about 5 minutes of work, but they queued behind the macOS runner limit for up to 62 minutes (run 42272702412). The doorbell PR (#40) waited 11 minutes for a runner in the same queue. Each merge was already tested on its own PR, and the newest main run tests everything merged before it, so the in-between runs added nothing.

Now main pushes share one concurrency group (github.ref) and cancel in progress: a batch of merges costs one run. PR behaviour is unchanged (grouped by PR number, newer commit cancels). Manual workflow_dispatch runs get their own group (run_id) and never cancel each other.

How tested

  • python3 -c "import yaml; yaml.safe_load(...)": parses.
  • This PR changes a workflow, so it runs every job; that run is the check.
  • The cancel-on-main behaviour can only be observed after merge: two quick merges should leave the older main run cancelled (grey) and the newer one green.

Risks

  • If merge A breaks main and merge B lands before A's run finishes, A's run is cancelled and B's run reports the break against B's commit, not A's. The PR runs still point at the culprit.
  • Cancelled runs show grey on those main commits. The protect-main ruleset checks PRs, not main pushes, so nothing is blocked.

What's left
Nothing.

Merging eleven PRs at 18:39 on Nov 6 started eleven full runs on main. Each
needed about 5 minutes, but they queued behind the macOS runner limit for up
to 62 minutes and held the doorbell PR's checks for 11. Every merge was
already tested on its PR and the newest main run covers all of them, so main
pushes now share one concurrency group and a newer one cancels the older.
@gshost1
gshost1 merged commit dbfcfb8 into main Nov 7, 2026
8 checks passed
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.

1 participant