fix(ci): expand Auto Queue triggers and skip when queue head is in flight#4845
Merged
Yicong-Huang merged 3 commits intoMay 3, 2026
Merged
Conversation
…ight
Triggers
Add pull_request {auto_merge_enabled, ready_for_review},
pull_request_review {submitted}, and workflow_run for the
Required Checks workflow. Drop the cron interval from hourly to
5 minutes (its only role now is bounded safety net for missed
events). The script short-circuits non-approval reviews up front
so the most chatty event is a cheap no-op.
In-flight guard
Pull commits[last:1].commit.statusCheckRollup.state in the GraphQL
query and treat an eligible PR as in-flight when its
mergeStateStatus is not BEHIND and its CI rollup is PENDING,
EXPECTED, or SUCCESS. When such a PR exists the run exits without
bumping anyone else — it is the queue head and bumping a
different PR would just preempt CI on a PR we would re-bump
after the head merges.
PRs that are BEHIND with PENDING checks do NOT count as in-flight:
that CI is on pre-update code and would have to re-run anyway.
Likewise, FAILURE / ERROR rollups release the guard so the queue
advances past stuck-on-CI PRs instead of waiting on cron.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4845 +/- ##
=========================================
Coverage 43.02% 43.02%
- Complexity 2029 2030 +1
=========================================
Files 957 957
Lines 34077 34077
Branches 3753 3753
=========================================
Hits 14663 14663
Misses 18637 18637
Partials 777 777
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
A 500 from api.github.com/graphql on attempt 2/6 killed the whole run even though the backoff loop had four attempts left. Wrap the GraphQL call in try/catch and treat any failure as "retry next attempt". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aglinxinyuan
approved these changes
May 3, 2026
Yicong-Huang
added a commit
that referenced
this pull request
May 3, 2026
### What changes were proposed in this PR? Add an `emergency` label fast-path to Auto Queue. A PR with this label is bumped before any non-emergency PR regardless of CREATED_AT, and its presence in BEHIND bypasses the in-flight guard so a non-emergency PR's running CI doesn't delay the bump. Within each priority class CREATED_AT-ASC ordering is preserved. Eligibility gates (auto-merge / not draft / not conflicting / APPROVED / threads resolved) still apply — this only reorders the bump, it does not bypass review. Label name is set by the `EMERGENCY_LABEL` constant (one-line change if `priority/P0` or similar is preferred later). ### Any related issues, documentation, discussions? Builds on #4672, #4678, #4845. ### How was this PR tested? `yaml.safe_load` parses; `node --check` parses the wrapped script body. Unit test on the partition logic: `[#100 docs, #101 emergency, #102 plain, #103 emergency+fix]` → `[101, 103, 100, 102]`. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.7, 1M context) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Three changes to
.github/workflows/auto-queue.yml.1. More triggers, shorter cron. Add
pull_request {auto_merge_enabled, ready_for_review},pull_request_review {submitted},workflow_run {Required Checks completed}, and drop cron from hourly to every 5 min. Each event covers a state change that previously waited up to an hour for cron — most notablyworkflow_run completedlets us bump the next PR the moment the head PR's CI finishes (pass or fail).2. In-flight guard. GraphQL now pulls
statusCheckRollup.state. If any eligible PR hasmergeStateStatus != BEHINDand CI isPENDING / EXPECTED / SUCCESS, the run exits without bumping anyone — the queue head is already moving, and preempting CI on another PR would just force a re-bump after the head merges.BEHIND + PENDINGdoes not count (CI runs on pre-update code), andBLOCKED + FAILURE/ERRORdoes not count (won't auto-merge, release the guard).3. Tolerate transient GraphQL 5xx. A real run died on attempt 2/6 from a
HttpError: terminated(HTTP 500) even though four backoff attempts remained. Wrap the GraphQL call in try/catch and treat failures as "retry next attempt".Any related issues, documentation, discussions?
Tracking issue: #4553. Builds on #4672 (initial workflow) and #4678 (UNKNOWN retry + eligibility gates).
How was this PR tested?
Workflow YAML parses clean. Decision logic is exercised by every trigger after merge — no separate test harness for this workflow today.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7, 1M context)