Skip to content

ci: cancel superseded CI runs per ref - #1604

Merged
c-vigo merged 3 commits into
devfrom
feature/1602-cancel-superseded-ci-runs
Sep 2, 2026
Merged

c-vigo merged 3 commits into
devfrom
feature/1602-cancel-superseded-ci-runs

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

The scaffolded ci.yml had no concurrency block, so a force-push or a rapid
follow-up push left the superseded run's every lane — lint, test,
commit-checks, scaffold-drift, summary — running to completion for a commit
that no longer matters. On a hosted runner that is wasted billed minutes; on a
self-hosted consumer with a small fixed slot pool it is worse: the stale run
holds the slots and the replacement run queues behind its own predecessor
(measured 120–250 s per-job queue times on a 3-slot consumer).

Consumers could not fix this themselves — ci.yml is a managed file, so a
hand-added block fails the scaffold-drift gate (#1295) on every PR. The fix
has to land here.

Both copies get the block, because they are separate render paths: devkit's own
image-building CI and the mode-aware scaffold consumers receive. #1414 is the
standing proof that a fix landing in one copy only is the likely failure mode.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • .github/workflows/ci.yml and assets/workspace/.github/workflows/ci.yml —
    a workflow-level concurrency block between on: and permissions:
    (the placement sync-main-to-dev.yml, release-core.yml and
    abandon-release.yml already use):

    concurrency:
      group: ci-${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: ${{ github.event_name != 'push' }}
  • tests/test_ci_concurrency.py — new suite, parametrized over both copies,
    pinning the group shape (per-workflow, per-ref) and the exact cancel
    condition.

  • CHANGELOG.md (+ synced mirror) — Changed entry.

Two decisions worth a reviewer's attention

  1. != 'push', not the == 'pull_request' the issue suggested. Neither
    copy triggers on push at all — both run only on pull_request and
    workflow_dispatch — so the acceptance criterion "in-flight main push
    runs are not cancelled" is satisfied by construction today. The issue's
    conservative form would therefore guard nothing while disabling the one case
    the issue explicitly wants cancelled ("a dispatched re-test supersedes the
    previous one"). != 'push' keeps dispatch supersession and still leaves the
    push guard standing if a push trigger is ever added.

  2. Existing gate semantics are untouched, and were checked rather than
    assumed.
    A cancelled superseded run cannot green the required check: the
    summary job is if: always() and trips on cancelled for every needed job
    ([BUG] CI Test Summary passes when a needed job is cancelled #1371/Scaffold ci.yml summary gate does not fail on cancelled required checks #1414). And it cannot refuse a green branch either: all six release-PR
    CI gate sites evaluate only the latest run per check name ([FEATURE] release.yml validate: count only the latest check run per name in the CI-green gate #1522), so a
    superseded run's entries are outranked. No changes were needed to either.

Changelog Entry

### Changed

- **CI cancels superseded runs instead of letting them burn runner slots**
  ([#1602](https://github.com/vig-os/devkit/issues/1602))
  - `ci.yml` carried no `concurrency` block, so a force-push or a rapid
    follow-up push left the previous run's every lane — lint, test,
    commit-checks, scaffold-drift, summary — running to completion for a commit
    that no longer matters. Wasted billed minutes on a hosted runner; worse on a
    self-hosted consumer with a small fixed slot pool, where the stale run holds
    the slots and the replacement run queues behind its own predecessor
  - Runs are now grouped per workflow and per ref, so a superseded
    `pull_request` or `workflow_dispatch` run is cancelled while distinct refs
    (other PRs, dispatches on other branches) stay independent. Consumers pick
    this up through the normal adoption PR; a hand-added block was never an
    option, since `ci.yml` is a managed file and the edit failed `scaffold-drift`
  - The cancel is conditioned on the event not being `push`: neither trigger is
    `push` today, but a deploy gating on the exact-commit CI run stays
    satisfiable if one is ever added
  - Existing gate semantics are unchanged: a cancelled run cannot green the
    required check (the summary job already trips on `cancelled`), and the
    release-PR CI gate evaluates only the latest run per check name, so a
    superseded run cannot refuse a branch that is green

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

N/A — the change is a declarative workflow key; GitHub evaluates it, so shape
assertions are the testable surface (the same treatment nix-image.yml's
concurrency block gets in test_workflow_cachix.py). Its live effect is
observable on this PR itself: pushing a follow-up commit should cancel the
run started by the previous one.

Evidence from the local run:

  • RED first: the new suite failed 4/4 before the block existed, on
    scaffold ci.yml must declare a workflow-level concurrency block (#1602).
  • GREEN after: tests/test_ci_concurrency.py,
    tests/test_workflow_summary_gate.py, tests/test_ci_green_gate.py and
    tests/test_ci_runner.py — 188 passed.
  • Full suite: 1714 passed, 3 skipped, 3 failed. All three failures reproduce
    identically on a clean origin/dev worktree and are local-environment
    artifacts, not regressions:
    • test_image.py::test_manifest_files — the locally cached
      ghcr.io/vig-os/devcontainer image is the 1.13.0 release, so its baked
      .pymarkdown no longer matches dev's.
    • test_integration.py::test_github_cli_authentication — the host gh
      config needs a keyring; dbus-launch is absent in the container.
    • test_transforms.py::test_mirror_is_the_source_plus_the_transforms — the
      changelog mirror was stale until sync-manifest regenerated it; green
      afterwards, and the regenerated mirror is committed.
  • Full hook suite: just precommit green over all files (actionlint and
    yamllint included, both workflows).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Refs: #1602

@c-vigo
c-vigo merged commit 61416ca into dev Sep 2, 2026
12 checks passed
@c-vigo
c-vigo deleted the feature/1602-cancel-superseded-ci-runs branch September 2, 2026 08:36
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