Skip to content

ci: cancel a pull request's checks when it merges or closes - #453

Merged
JuroOravec merged 2 commits into
mainfrom
ci/cancel-runs-of-closed-prs
Oct 28, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
ci/cancel-runs-of-closed-prs

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Part of #405, step 1, which Juro approved.

Problem

A PR merged while its checks were still queued kept those runs, and they ran in full after the merge. The jobs that started after the merge used about 375 job-minutes for #436, 381 for #435, 355 for #430 and more than 295 for #437. #437's Python tests run was still queued more than two hours after the merge. Meanwhile the merge's own run on main tested the same change again. The existing concurrency groups cancel only a run that a newer push replaces; nothing cancels on close or merge.

Change

Ten check workflows now also start on the PR's closed event: py--examples--tests, py--tests, repo--check, repo--codeql, repo--docs-check, repo--docs-lighthouse, repo--dom-members, repo--generated, repo--security and rust--tests.

  • Cancelling: the closed run joins the PR's existing concurrency group (${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}). The group's cancel-in-progress, which is true for pull_request events, cancels the PR's queued and running checks.
  • Skipping: every job without needs has if: github.event.action != 'closed', and jobs with needs skip with the jobs they need. So the cancelling run takes no runner, which matters because the runners are what is saturated.
  • Push and schedule runs: github.event.action is empty there, so those jobs run as before.
  • Workflows left out: repo--discord-pr and repo--dependabot-relock run no checks.

test_ci_workflows.py gains test_check_workflows_cancel_a_pull_requests_runs_when_it_closes. It finds every workflow with a pull_request trigger, except repo--discord-pr and repo--dependabot-relock, which run no checks. For each, it checks the trigger types and that every job that can start a run skips on closed, so a new check workflow is covered without a list edit. The existing concurrency-block test is unchanged and still passes.

What to watch after merging

  • Skipped check status: a closed PR's head commit gets a skipped check status from the cancelling run. Branch protection only reads open PRs, and reopening a PR starts a full run (reopened).
  • Path filters: these apply to closed the same way as to the original run, so a workflow that did not run for the PR does not start a cancelling run either.

Evidence

  • The workflow-reading tests pass: 111 passed across test_ci_workflows, test_repo_check_script, the release and toolchain validator tests, and the examples catalog and archive tests.
  • scripts/validate.py passes.
  • actionlint is not installed locally, so this PR's own CI and the first merged or closed PR are the real check.

🤖 Generated with Claude Code

JuroOravec and others added 2 commits October 28, 2026 10:53
A PR merged while its checks were still queued kept those runs, and
they ran in full after the merge: about 300 to 400 job-minutes each for
#430, #435, #436 and #437, while the merge's own run on main tested the
same change again. Every check workflow that runs on pull requests now
also starts on the PR's `closed` event. That run joins the PR's
concurrency group, whose cancel-in-progress cancels the PR's queued and
running checks, and every job skips on that event, so the cancelling run
itself needs no runner.

The notification and relock workflows are left out because they run no
checks. A test checks each check workflow's trigger types and that every
job that can start a run skips on `closed`.

This is step 1 of the #405 proposal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The DOM member table workflow landed after the first commit and also runs
checks on pull requests. The workflow test now finds every pull-request
workflow except the two that run no checks, so a new one is covered
without a list edit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec force-pushed the ci/cancel-runs-of-closed-prs branch from 4c51e3c to 7dc7fe4 Compare October 28, 2026 09:54
@JuroOravec
JuroOravec marked this pull request as ready for review October 28, 2026 09:54
@JuroOravec

Copy link
Copy Markdown
Member Author

The failing browsers job (DOM member table in browsers) is not caused by this PR. The workflow runs here only because this PR edits repo--dom-members.yml, which is in its own path filter. It fails the same way on other branches, for example fix/dom-table-boolean-attributes-without-effect, with browser property changes such as cue and cuebackground. It is not a required check.

@JuroOravec
JuroOravec merged commit 5273b56 into main Oct 28, 2026
26 of 40 checks passed
@JuroOravec
JuroOravec deleted the ci/cancel-runs-of-closed-prs branch October 28, 2026 10:47
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