Skip to content

fix(ci): stop Mergify label events from cancelling required PR Gate runs - #11164

Merged
mergify[bot] merged 1 commit into
mainfrom
fix-pr-gate-label-concurrency
Jul 31, 2026
Merged

fix(ci): stop Mergify label events from cancelling required PR Gate runs#11164
mergify[bot] merged 1 commit into
mainfrom
fix-pr-gate-label-concurrency

Conversation

@alchemydc

Copy link
Copy Markdown
Contributor

Motivation

Mergify merge-queue requeues currently fail systematically. On every requeue, Mergify flips labels on the source PR (queued added, then the stale dequeued label removed ~40 s later). pr-gate.yml triggers on labeled/unlabeled and uses a single concurrency group with cancel-in-progress: true, so the second label event cancels the first PR Gate run mid-flight. The cancelled run's pr-gate-result aggregator still executes (if: always()) and posts a failure check on the PR head. Mergify's stay-in-queue condition check-success=pr-gate-result then dequeues the PR within ~2 minutes, before the queue draft's CI (which is green) can complete.

Observed on #11146: queue attempts on 2026-07-31 at 14:42 and 18:12 UTC were both dequeued "with no time running CI". The pr-gate-result check-run history on head 2c187ad6 shows failures at 14:43:28, 14:45:41, 18:14:19, and 18:15:56 — each seconds after a queued/dequeued label event — recovering to success once the label churn settles. The first queue attempt (2026-07-30) survived because no stale dequeued label existed yet, so only one label event fired.

tests-unit.yml already guards against this exact hazard ("Unrelated label events use a separate group so they cannot cancel the required unit test run"). lint.yml and test-crates.yml use the default pull_request types and are not exposed.

Solution

Mirror the tests-unit.yml pattern in pr-gate.yml, extended to cover unlabeled (PR Gate subscribes to both label event types; the only label the gate actually reacts to is A-release):

  • Concurrency group: unrelated label events get an ignored-label group suffix so they cannot cancel the required run; all other events (including A-release label changes) stay in the required group.
  • changes job: skips on unrelated label events, so semver-checks and changelog-gate skip too (this also stops re-running a full semver-checks pass on every label flip).
  • release-readiness job: same guard, so a Mergify label flip on a release PR (which carries A-release) doesn't spawn a redundant readiness run. Adding/removing A-release still re-evaluates readiness in the required group.
  • pr-gate-result job: skips on unrelated label events and gets a dynamic name (mirroring the unit-tests aggregator) so the skipped run's check posts under a different name and cannot replace the required pr-gate-result check that Mergify and branch protection consume.

Net effect on a Mergify requeue: both label events land in the ignored-label group, every job skips, the run completes in seconds, no check named pr-gate-result is posted, and the latest required-gate result on the head is untouched.

Tests

  • YAML validated locally; expression constructs (group suffix, guard, dynamic aggregator name) are copied from the battle-tested tests-unit.yml pattern.
  • On this PR (workflows run from the PR head for pull_request events): applying/removing an arbitrary label should produce a fast skipped run under the alternate check name, without cancelling the required PR Gate run or perturbing pr-gate-result.
  • End-to-end after merge: requeue fix(state): make read_only_open_with_ephemeral_config_returns_error more robust #11146 (it still carries the stale dequeued label, so the failure scenario replays exactly) and confirm it survives past the ~2-minute mark.

Specifications & References

Follow-up Work

  • Rapid edited events (Mergify editing queue-draft bodies) can still race-cancel a gate run on queue drafts; the window is ~25 s and it was not the cause of the observed dequeues. Can be addressed separately if it ever bites.

AI Disclosure

  • AI tools were used: Claude Code for the CI-failure investigation and the workflow change; reviewed and tested by the author.

PR Checklist

  • The PR title follows conventional commits format: type(scope): description
  • The PR follows the contribution guidelines.
  • This change was discussed in an issue or with the team beforehand.
  • The solution is tested.
  • The documentation and changelogs are up to date.

@alchemydc alchemydc added A-devops Area: Pipelines, CI/CD and Dockerfiles C-bug Category: This is a bug labels Jul 31, 2026
@conradoplg
conradoplg requested a review from Copilot July 31, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents unrelated Mergify label events from cancelling required PR Gate runs.

Changes:

  • Isolates unrelated label events into a separate concurrency group.
  • Skips gate jobs and uses an alternate check name for those events.
  • Preserves A-release label behavior.

@alchemydc
alchemydc requested a review from conradoplg July 31, 2026 20:57
@mergify mergify Bot added the queued label Jul 31, 2026
@mergify

mergify Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-07-31 21:12 UTC · Rule: batched · triggered by rule move to any queue if GitHub Rulesets are satisfied
  • Checks skipped · PR is already up-to-date
  • Merged2026-07-31 21:13 UTC · at 56741151ddb82956104f677fa96bf06963adc9ba · merge

This pull request spent 57 seconds in the queue, including 12 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit 5cd42d5 into main Jul 31, 2026
135 checks passed
@mergify
mergify Bot deleted the fix-pr-gate-label-concurrency branch July 31, 2026 21:13
@mergify mergify Bot removed the queued label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-devops Area: Pipelines, CI/CD and Dockerfiles C-bug Category: This is a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants