Repository navigation
Description
Parent EPIC: #1840
Goal
When a new commit is pushed to a pull request, cancel that pull request's older Container and Testing runs that are still queued or running, so the single self-hosted runner does not build commits that will never be merged. Runs for pushes to develop, main, and releases/** are never cancelled.
Background
Every push to a pull request targeting develop starts a Test (Docker) job on the one self-hosted runner. With about 4 open pull requests whose checks run 3 to 5 times each, a fix pushed while the previous run is queued or running leaves that older run testing a commit nobody will merge, and every other pull request waits behind it. No workflow has a concurrency group.
#2386 measured the job at 801 s and replayed the 554 real Container runs from 2026-08-31 to 2026-09-30:
| Setup | Jobs completed | Waited >15 min | 90th-percentile wait | Longest wait |
|---|---|---|---|---|
| 1 runner (today) | 554 | 206 | 140 min | 239 min |
| 1 runner, cancelling | 376 | 12 | 11 min | 32 min |
| 2 servers | 554 | 50 | 13 min | 63 min |
| 2 servers, cancelling | 392 | 0 | 0 min | 12 min |
Cancelling gives a lower 90th-percentile and longest wait than a second server, at no cost (event-driven replay, corrected in PR #2403). The maintainer chose to do this first and add a second server only if waits over 15 minutes remain common afterwards.
Design
The same workflow-level block in container.yaml and testing.yaml:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('run-{0}', github.run_id) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}Push runs need a group of their own: by default a group keeps at most one pending run and a new one replaces it, so a shared group could leave a develop merge commit untested and unpublished. Testing uses only GitHub-hosted runners on pull requests to develop; it is included to free GitHub-hosted job slots and keep both workflows consistent. Job routing does not change.
Tasks
- T1: Add the block to
container.yaml. - T2: Add the block to
testing.yaml. - T3: Note in
docs/self-hosted-runner.mdthat superseded pull-request runs are cancelled, and to re-run only the latest run. - T4: Verify on real runs: a second push to a pull request cancels the older runs;
developpush runs are never cancelled. - T5: Update EPIC EPIC: Improve PR Workflow Performance #1840.
Out of Scope
A second server or runner instance, other workflows (for example docs-lint.yaml), feature-branch pushes, and changes to job routing or fork gating.
The full specification is in docs/issues/open/2402-1840-cancel-superseded-pr-runs/ISSUE.md.
Activity
docs(issues): [torrust#2402] tighten verification scenarios and corre…
docs(issues): add issue specification for torrust#2402
docs(issues): [torrust#2402] tighten verification scenarios and corre…
Merge #2403: docs(issues): [#2386] record runner capacity measurement…
Merge #2405: docs(issues): [#2386] record retrospective and independe…
docs(issues): [torrust#2402] start M1 verification
docs(issues): [torrust#2402] record M1 supersession
ci(workflows): [torrust#2402] cancel superseded PR runs
docs(issues): [torrust#2402] record workflow implementation
docs(issues): [torrust#2402] start M1 verification
docs(issues): [torrust#2402] record M1 supersession
ci(workflows): [torrust#2402] cancel superseded PR runs
5 remaining items
test(ci): supersede torrust#2402 M2 verification
test(ci): start torrust#2402 M2 verification
test(ci): supersede torrust#2402 M2 verification
test(ci): supersede torrust#2402 M1 concurrent verification
test(ci): queue torrust#2402 M1 control
test(ci): start torrust#2402 M1 queued verification
test(ci): supersede queued torrust#2402 M1 verification
test(ci): queue torrust#2402 M1 queued-job control
test(ci): start torrust#2402 M1 queued-job verification
test(ci): supersede torrust#2402 M1 queued-job verification
josecelano commentedon Oct 4, 2026
Closing after M1/M2 real-run verification and independent completion review passed; archival documentation follows in the close-out PR.
docs(issues): fix archived torrust#2402 metadata links
chore(issues): archive closed issue #2402 spec
Merge #2433: chore(issues): archive closed issue #2402 spec