Skip to content

ci: a PR's newer push cancels its older CI/CD run; closing a PR cancels its runs - #991

Merged
transfix merged 2 commits into
masterfrom
ci/stale-pr-runs
Nov 3, 2026
Merged

transfix merged 2 commits into
masterfrom
ci/stale-pr-runs

Conversation

@transfix

@transfix transfix commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Stale CI runs pile up in the queue. On 2026-11-03, 9 of the 28 queued or running runs were for PRs that had already merged (#984, #980, #979), for PR commits a newer push had replaced (#985, #990, #982), or for an older master commit. They were cancelled by hand. This PR stops them building up.

Why they piled up

  • ci.yml gave every pull_request run a concurrency group of its own (run-<run_id>), so a newer push never replaced or cancelled a PR's older run. CI (recipe-first) and llm-gate already group per ref and cancel.
  • Nothing cancelled a PR's runs when it merged or closed, so they ran to the end ahead of newer jobs.

What changes

  • ci.yml:
    • PR runs share one group per PR number, ci-pr-<N>, with cancel-in-progress. A newer push cancels the PR's older CI/CD run, whether it's queued or running.
    • Pushes keep their group as it was: one run per ref, a waiting run is replaced, a running one finishes. Cancelling running master runs could leave master with no finished run, since merges land faster than a run clears.
  • ci-cancel-closed.yml (new, on pull_request: closed):
    • It joins ci-pr-<N> with cancel-in-progress, which cancels that PR's CI/CD run as soon as the closer run is created, without waiting for a runner.
    • Its one job then cancels the branch's other unfinished pull_request runs (CI (recipe-first), llm-gate, ...). It needs actions: write, runs on a hosted ubuntu-latest and checks nothing out.
    • It covers same-repo PRs only; a fork's token can't cancel runs.

The trade-off: heavy jobs can now be cancelled mid-build

The old comments said a running package job must never be cancelled, because that would strand the VTK cache and force a 22-min cold rebuild. That no longer holds:

  • No workflow has saved a build cache since the deps moved to cvcpkg (b640d5e, 2026-07). grep -rn 'actions/cache\|ccache\|sccache' .github/ finds nothing.
  • Cancelling a heavy job now loses only the minutes it has run.

The job-level groups are unchanged, and the comments now say why no cache is at stake.

Not changed: no new actions/cache or upload-artifact steps.

Checks

  • No YAML linter here. GitHub validates the workflow files on push, and this PR's own CI/CD run already uses the new group.
  • A second (empty) push to this branch cancelled the first push's CI/CD run (41567067349, 6c3e5ac) right away; the new run (41567128377) took the group.
  • The closed-PR workflow can't run until it's on master. The first PR to merge or close after this one is its test.

…ls its runs

CI/CD gave each pull_request run a concurrency group of its own, so every
push's run ran to the end, and nothing cancelled a PR's runs once it merged.
On 2026-11-03, 9 of 28 queued runs were for merged PRs or replaced commits.

- ci.yml: PR runs share one group per PR number with cancel-in-progress, so
  a newer push cancels the older run, queued or running. Pushes keep their
  group as it was (a running master run finishes).
- ci-cancel-closed.yml: on pull_request closed, join that PR's CI/CD group
  with cancel-in-progress (cancels its CI/CD run without waiting for a
  runner), then cancel the branch's other unfinished pull_request runs.

The heavy jobs' "never cancel, it strands the cache" rule no longer holds:
nothing has been cached since the deps moved to cvcpkg (b640d5e). The
comments say so.
@transfix
transfix enabled auto-merge (squash) November 3, 2026 02:41
@transfix
transfix merged commit 4f33d35 into master Nov 3, 2026
10 of 28 checks passed
@transfix
transfix deleted the ci/stale-pr-runs branch November 3, 2026 03:44
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