Skip to content

Cancel superseded main validation runs - #6537

Merged
rdimitrov merged 2 commits into
mainfrom
rdimitrov/cancel-outdated-main-runs
Sep 8, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
rdimitrov/cancel-outdated-main-runs

Conversation

@rdimitrov

Copy link
Copy Markdown
Member

Summary

Follow-up to #6533, which cancels superseded pull request checks. Pushes to main were left alone because that workflow also publishes and signs container images, and a workflow-level cancel-in-progress would abort a publish half-way through, leaving pushed-but-unsigned tags in GHCR.

This applies the same "only the latest validation matters" idea to main without touching in-flight publishing. When PRs A, B, and C merge close together, C already contains all three changes, so its checks validate the combined result and the older runs are redundant.

Behaviour after this change:

  • Validation: a newer push to main cancels the older run's in-progress lint, tests, codegen, security scan, Helm, E2E, operator CI, and skills jobs. Each job has its own concurrency group keyed on the ref, so jobs in different tiers do not cancel each other.
  • Publishing not yet started: a new publish-gate job runs after validation and checks whether the commit is still the tip of the branch. If it has been superseded, the five multi-arch image builds are skipped. A cancelled validation job also skips publishing for that run via needs.
  • Publishing already started: the image job has no concurrency group and always runs to completion, so every pushed tag is also signed.
  • Tagged releases: unaffected. They run from releaser.yml on the release event, not from this workflow.

Type of change

  • Other: CI/CD

Test plan

  • actionlint on the changed workflow: no diagnostics.
  • git diff --check: clean.
  • After merge: watch two pushes to main landing within a few minutes of each other. Expect the older run's unfinished validation jobs to end as cancelled and its publish job to be skipped, while the newer run publishes.

Does this introduce a user-facing change?

No. Dev images for superseded main commits will no longer be published; the newer commit's image contains their changes.

Special notes for reviewers

  • Job-level concurrency is one of the keys GitHub permits on a job that calls a reusable workflow (uses:), and cancelling the caller job cancels its nested jobs. The called workflows carry no concurrency groups of their own that would interfere; security-scan.yml has one from Cancel superseded pull request checks #6533 but it only cancels on pull_request.
  • A superseded commit on main will show as cancelled rather than green in the commit list and on the README build badge until the newer run finishes. That is the intended trade-off.
  • workflow_dispatch on a non-main branch keeps working: groups include github.ref, and the gate compares against that branch's tip.

Generated with Claude Code

🤖 Generated with Claude Code

Every push to main currently runs the full validation suite to
completion even when a newer push has already landed. When several
PRs merge close together, the newest commit contains all of them, so
its checks validate the combined result and the older runs only
consume runners.

Add a per-job concurrency group to each validation job so a newer
push cancels the older run's in-progress validation. Concurrency is
deliberately not set at the workflow level: that would also cancel
image publishing part-way through, leaving pushed-but-unsigned tags.

Add a publish gate that runs after validation and skips publishing
when the commit is no longer the tip of the branch. Publishing that
has already started is never cancelled. Tagged releases run from
releaser.yml and are unaffected.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@rdimitrov
rdimitrov requested a review from JAORMX as a code owner September 8, 2026 10:10
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Sep 8, 2026
@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.66%. Comparing base (6f73212) to head (b186c3e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6537      +/-   ##
==========================================
- Coverage   78.67%   78.66%   -0.02%     
==========================================
  Files         777      777              
  Lines       76687    76687              
==========================================
- Hits        60335    60327       -8     
- Misses      16347    16355       +8     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov
rdimitrov merged commit 074c3c6 into main Sep 8, 2026
44 of 45 checks passed
@rdimitrov
rdimitrov deleted the rdimitrov/cancel-outdated-main-runs branch September 8, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants