Skip to content

Cancel superseded pull-request CI runs #2402

Closed

Description

@josecelano

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.md that 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; develop push 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

  1. added 5 commits that reference this issue on Oct 1, 2026
  2. self-assigned this
    on Oct 2, 2026
  3. added 7 commits that reference this issue on Oct 2, 2026
  4. 5 remaining items

  5. josecelano commented on Oct 4, 2026

    @josecelano
    MemberAuthor

    Closing after M1/M2 real-run verification and independent completion review passed; archival documentation follows in the close-out PR.

  6. added 3 commits that reference this issue on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions