Repository navigation
Cancel a closed PR's CI runs, including for fork contributors - #572
Closed
nirvedhmeshram wants to merge 3 commits into
Closed
nirvedhmeshram wants to merge 3 commits into
nirvedhmeshram wants to merge 3 commits into
Conversation
The concurrency group only cancels a PR's in-flight run when a newer run of the same PR starts. Merging or closing starts none, so the old run kept holding the GPU runners. Trigger the three GPU workflows on pull_request closed too: that run joins the PR's group, cancels the in-flight run, and skips its own jobs. Also key the group on the PR number rather than the head branch, so two forks' same-named branches (e.g. patch-1) no longer cancel each other's runs, which closing a PR would otherwise now do as well. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nirvedhmeshram
requested review from
BKP,
artulab,
mawad-amd and
neoblizz
as code owners
October 6, 2026 19:12
The previous commit's pull_request closed trigger had two gaps. On merge, GITHUB_REF is refs/heads/main, so cancel-in-progress evaluated to false and nothing was cancelled in the one case that matters. And a fork contributor's closed-event run waits for the same maintainer approval as their other runs. pull_request_target runs from main regardless of approval settings and GITHUB_REF. The new workflow cancels the PR's queued and in-progress runs by head commit, branch and repo through the API. It only reads the event payload and never checks out PR code, so its write token is not exposed to it. The GPU workflows keep only the PR-number concurrency key. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: None
What changed in this PR
Updates GPU-related GitHub Actions workflows so CI runs don’t keep occupying GPU runners after a PR is closed/merged, by improving concurrency grouping and adding explicit run cancellation on PR close.
Changes:
- Key concurrency groups by PR number (instead of
head_ref) to prevent cross-fork branch-name collisions. - Add a
pull_request_target: closedworkflow that cancels queued/running workflow runs for the PR’s head SHA via the Actions API.
| File | Description |
|---|---|
| .github/workflows/iris-tests.yml | Switch concurrency grouping to PR number to avoid fork branch collisions. |
| .github/workflows/iris-performance-regression-test.yml | Switch concurrency grouping to PR number to avoid fork branch collisions. |
| .github/workflows/iris-external-validation-test.yml | Switch concurrency grouping to PR number to avoid fork branch collisions. |
| .github/workflows/cancel-closed-pr-ci.yml | New workflow to cancel in-flight PR runs when the PR is closed. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
pull_request_target is a HIGH dangerous-triggers finding in the PR security scan. A scheduled run is equally immune to fork-approval holds and to GITHUB_REF being main on merge, and needs no scanner exception. Every 10 minutes it lists in-flight pull_request runs, finds each run's PR by head branch (fork runs carry no PR number) and cancels it only if every PR whose head is that commit is closed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Collaborator
Author
|
This seems too much complexity for a small problem so I will close this PR |
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.
Problem
When a PR is merged or closed, its in-flight
Iris Tests, performance-regression and external-validation runs keep going and hold the GPU runners. The concurrency group only cancels a run when a newer run of the same PR starts, and merging or closing starts none.A live example: #570 is merged, but its
Iris Testsrun (from commit8f34e8a9) is still queued.Change
New
cancel-closed-pr-ci.ymlruns every 10 minutes (and on manual dispatch). It lists in-flightpull_requestruns and cancels any whose PR is closed.GPU workflows' concurrency is keyed on the PR number instead of
github.head_ref, the same pattern IREE uses. Two PRs from different forks with the same branch name (e.g.patch-1) currently share a group and cancel each other's runs.Why a scheduled sweep
pull_request: closed+ concurrency (first commit)GITHUB_REFisrefs/heads/main(docs), socancel-in-progressis falsepull_request_target: closed+ API (second commit)dangerous-triggersThe cost is up to one interval (about 10 minutes) before a closed PR's runs stop, against GPU runs that take 1–2 hours. If instant cancellation is worth a reviewed
dangerous-triggersexception in.github/scan_tools_configs/zizmor.yml, the second commit's workflow can come back.Testing
Iris Tests, and left every open PR's runs alone (this one, Allocate CI GPUs per task instead of per job #571, Dependabot, Copilot).zizmor 1.30.0 --persona regularwith the repo's config reports no findings.Scheduled workflows only run from
main, so this takes effect after merge; it can also be triggered from the Actions tab.🤖 Generated with Claude Code