Sub topic 10
When checks fail in the queue
This chapter assumes you have enabled a merge queue and that your required workflows already run on the merge_group event. It covers what GitHub does when a queued pull request fails, and what you should do next.
What happens to the failing pull request
Each pull request in the queue is tested on a temporary merge group branch. That branch holds the latest base branch, the changes queued ahead, and the pull request itself. If a required check fails on that branch, GitHub removes the pull request from the queue. The pull request stays open, and nothing is merged for it.
Pull requests ahead of the failure are not affected. They keep their own merge group branches and merge as normal.
Pull requests behind the failure are affected. Their merge group branches included the failed change, so their results no longer describe what main will contain. GitHub rebuilds them without the removed pull request and runs their checks again. They keep their place in line, but they pay for a second CI run.
Why a pull request gets removed
Failed checks are the common cause, but they are not the only one. A pull request can also leave the queue for these reasons:
- A required check does not report within the configured check timeout.
- The pull request conflicts with the base branch or with a change ahead of it.
- Someone removes it manually.
The pull request's timeline records the reason. Read it before you rerun anything.
How grouping changes the blast radius
When the queue builds groups with ALLGREEN, every group must pass its own checks. A failure removes only the pull request that caused it.
With HEADGREEN, only the head of the group needs to pass. This saves CI runs, but you must trust your checks to catch problems early in the group.
With either strategy, a larger group means more pull requests are rebuilt when one fails. Teams with flaky tests should keep max_entries_to_build small.
Recovering
- Open the removed pull request and read the failing check's logs on the merge group run, not on the earlier pull request run. The two runs test different code.
- Reproduce locally against the latest
main. A failure that only appears in the queue usually means a semantic conflict with a change that merged ahead of you, which is the case the queue exists to catch. - Push a fix to the pull request branch. If the pull request fails only because of a flaky test, fix or quarantine the test instead of just retrying.
- Add the pull request to the queue again. It goes to the back, so it does not regain its old position.
Make failures arrive sooner
A hung job holds up everyone behind it until the queue's check timeout expires. Set a job timeout that is shorter than the queue timeout, so a stuck job fails and frees the line.
name: CI
on:
pull_request:
branches: [main]
merge_group:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Run tests
run: make testWith a queue timeout of 60 minutes, this job fails after 30 and the queue moves on.
Exercise
A queue has pull requests A, B and C in order. B fails its required check on the merge group branch. What happens to A and C, and where does B go after the author fixes it?
Show answer
A is unaffected and merges. C is rebuilt without B, its checks run again, and it then merges. B is removed from the queue. After the author pushes a fix, B must be added again and joins at the back of the queue.