Skip to content

fix(ci): cancel superseded external CI runs - #25896

Draft
iAmMichaelConnor wants to merge 1 commit into
nextfrom
mike/ci-external-concurrency
Draft

iAmMichaelConnor wants to merge 1 commit into
nextfrom
mike/ci-external-concurrency

Conversation

@iAmMichaelConnor

@iAmMichaelConnor iAmMichaelConnor commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge order

Merge after #25895 and #25894, ideally also after aztec-labs-eng/ci3#28 and the ci3 pin bump. This PR makes superseded external runs get cancelled, and both of those must be in place first:

  • Without fix(ci): record external CI success only when the run succeeded #25895: a cancelled external run still records its tree as having passed CI, so each cancel this enables would record a false pass.
  • Without fix(ci): terminate build instances when a CI run is cancelled #25894: a cancelled run doesn't terminate its build instance. The instance keeps running, idle, until its shutdown timer (60–75 minutes from launch), or with no timer at all if it was cancelled in its first minute.
    • A new run of the same PR usually terminates the old instance when it launches its own, because the instance names match.
    • It doesn't when the new run stops before launching anything, for example a label-gated failure, a forbidden-files failure or a cache hit.
    • Until ci3#28, a cancel during the instance request can still leave an instance with no timer.

Problem

ci3-external.yml (CI for pull requests from forks) is meant to allow one run per fork branch:

group: |
  ci3-external-${{ github.event_name == 'pull_request' && format('{0}/{1}', …) || github.run_id }}
cancel-in-progress: true

But the workflow runs on pull_request_target and never on pull_request, so the test is always false. Every run lands in its own run_id group, and cancel-in-progress never applies. What happens to a superseded run depends on its instance name:

  • Same name: the instance name keeps only the first part of the branch name. If the new run in the same CI mode launches an instance with the same name, it terminates the old run's instance, and the old run fails instead of being cancelled.
  • Different name, or the new run stops before launching: the old run keeps going to the end.

Change

  • One group per pull request, keyed by PR number, for pull_request_target events. A new run cancels the one it supersedes, the same as in ci3.yml (which groups by <pr>/merge). Keying by PR number rather than fork and branch also covers a fork branch with PRs into two bases, and a deleted fork.
  • Label events that can't start CI get a group of their own. That's any label other than ci-external-once, on a PR without ci-external; External Contributor Checks fails those runs. Without this, adding an unrelated label while a maintainer's ci-external-once run is in progress would cancel the approved run and replace it with a failure. (A label added after that run has finished still starts a run that fails External Contributor Checks, as it does today, and as the newest ci-external result that failure replaces the earlier pass.)
  • merge_group runs keep their own run_id group, as before.

Testing

No CI was run; this is a draft. To check after merging, on a fork PR:

  • push twice in quick succession with ci-external on the PR, and confirm the first run is cancelled;
  • add ci-external-once, then an unrelated label while that run is going, and confirm the approved run carries on.

ci3-external.yml put runs for the same fork branch in one concurrency
group only when the event was `pull_request`, but it runs on
`pull_request_target`. Every run fell through to its own run_id group, so
a new push to a fork PR never cancelled the run it superseded.

Group by pull request number for pull_request_target events. A label event
that cannot start CI (any label other than ci-external-once, on a PR
without ci-external) keeps a group of its own, so it cannot cancel a run a
maintainer approved with ci-external-once. merge_group runs keep their own
group as before.

This branch has not been deployed

No deployments
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