Skip to content

Cancel CI runs of merged and closed pull requests - #5748

Merged
nlohmann merged 1 commit into
developfrom
claude/ci-pipeline-merged-prs-f1002a
Oct 1, 2026
Merged

nlohmann merged 1 commit into
developfrom
claude/ci-pipeline-merged-prs-f1002a

Conversation

@nlohmann

@nlohmann nlohmann commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

Every workflow already has a concurrency group, so a new commit on a pull request cancels its older runs, and there is at most one run per workflow and branch. But once a pull request is merged or closed, the runs of its last commit keep going. With many open pull requests this holds up the queue for hours. For example, all nine runs of #5745 were still queued after it had been merged.

This adds .github/workflows/cancel_closed_pr_runs.yml:

  • triggers on pull_request_target / closed (which includes merged), so the token can also cancel runs of pull requests from forks
  • has actions: write only; it never checks out or runs pull request code, it only calls the API
  • cancels every unfinished run of the pull request's head SHA whose event is pull_request or pull_request_target. Push runs are excluded because a branch that is pushed to develop directly shares the head SHA with the push runs there.
  • a run that finishes between listing and cancelling is not an error

As a one-off cleanup I also cancelled 111 stale queued runs by hand (merged/closed pull requests and superseded commits of open ones).

Breaking changes

None. This only changes CI; the library and its public API are unchanged.


Written by Claude Code.

🤖 Generated with Claude Code

The concurrency groups cancel superseded runs when a pull request gets new
commits, but the runs of its last commit keep going after it is merged or
closed and hold up the queue of the open pull requests. A new workflow on
pull_request_target/closed cancels all unfinished pull request runs of the
head commit. It never checks out the pull request's code.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann nlohmann added this to the Release 3.13.0 milestone Oct 1, 2026
@nlohmann
nlohmann merged commit 11e75a5 into develop Oct 1, 2026
14 of 161 checks passed
@nlohmann
nlohmann deleted the claude/ci-pipeline-merged-prs-f1002a branch October 1, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant