Sub topic 10
When checks fail in the queue
This chapter assumes you can read GitHub Actions workflows and know what a required status check is. It also assumes the queue is enabled and your workflows already run on the merge_group event, as covered in earlier chapters. Here you will learn what happens when a check fails on a queued pull request, why a pull request can leave the queue without anyone clicking a button, and how to recover with the least wasted CI time.
What a failure means in the queue
A pull request in the queue is not tested as you wrote it. GitHub builds a temporary branch named gh-readonly-queue/<base>/pr-<number>-<sha>. This branch holds the latest base branch, plus every pull request ahead of yours in the queue, plus your changes. Your required checks run against that commit.
A failure on that commit therefore means something different from a failure on the pull request branch. Your branch was green alone. The queued combination is red. The cause is one of these:
- Your change breaks, or is broken by, a change that merged after you opened the pull request.
- Your change conflicts semantically with a pull request queued ahead of you.
- A flaky test or infrastructure problem hit this particular run.
- A required check never reported a status at all.
The queue cannot tell these apart. It only sees a required check that failed or never finished.
What GitHub does automatically
When a required check fails on a merge group, GitHub removes the pull request from the queue. Nothing merges and the base branch is untouched. The pull request stays open, and its timeline records that it was removed from the merge queue.
The pull requests behind it were being tested on top of the failed one. Their temporary branches contain code that will never reach the base branch, so those results no longer prove anything. GitHub discards those merge groups and builds new ones without the removed pull request. The new groups include everything ahead of it that is still in the queue.
A pull request leaves the queue without merging in these cases:
| Cause | Result |
|---|---|
| A required check fails on its merge group | Removed. Entries behind it are rebuilt. |
| A required check does not report within `check_response_timeout_minutes` | Removed. Treated like a failure. |
| The pull request cannot be merged into the group (merge conflict) | Removed. |
| A user with permission clicks **Remove from queue** | Removed. Entries behind it are rebuilt. |
| An entry ahead of it is removed | Not removed. Its own merge group is rebuilt. |
The last row matters for reading your queue. A pull request that shows a fresh set of running checks was not necessarily changed. A neighbor ahead of it probably left.
How grouping changes the picture
The grouping_strategy setting controls how much of a group must be green. It applies when max_entries_to_merge is greater than one.
ALLGREENrequires every entry in the group to pass its required checks before the group merges. It is the conservative choice.HEADGREENrequires only the last entry's checks to pass. That last commit contains all the earlier ones, so a green head implies the whole stack is green. This saves CI time, but it only works if your checks test the combined content rather than something unique to each commit.
Batching has a cost on failure. When a group of five contains a bad pull request, the failure removes the culprit, and GitHub rebuilds the other four. The other four are tested again even though they did nothing wrong. A larger max_entries_to_merge helps most when failures are rare. A flaky suite plus large groups can leave the queue repeating work.
Finding out why a pull request left
Work through these steps in order.
- Open the pull request and read the timeline. The removal event usually says why it left.
- Open the Actions tab and filter by event
merge_group. Failed runs for queued commits appear under the temporary branch name, not under your pull request branch. - Open the failed job and read the log as you would for any CI failure. The log shows the code that ran, including your changes and the queued changes ahead of you.
- Compare the failure with your pull request's own run. If your pull request run passed, the failing test probably touches code that changed ahead of you.
Do not look for the failure in the pull request's Checks tab alone. A pull request that was removed can show green checks there, because the pull request run really did pass.
Make failures easier to read
The merge_group event carries the commit information the queue uses. You can log it so a failed run states which base it was built on:
name: CI
on:
pull_request:
branches: [main]
merge_group:
types: [checks_requested]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Show merge group context
if: github.event_name == 'merge_group'
run: |
echo "Group branch: ${{ github.event.merge_group.head_ref }}"
echo "Base commit: ${{ github.event.merge_group.base_sha }}"
echo "Group commit: ${{ github.event.merge_group.head_sha }}"
- name: Run tests
run: make test
- name: Upload test report
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-report-${{ github.run_id }}
path: reports/Two details are deliberate:
- The
concurrencyblock cancels superseded runs only for pull requests. Each merge group run has a differentgithub.ref, and canceling one would make a required check fail or never report, which removes a healthy pull request from the queue. - The report upload uses
if: failure()so the evidence survives. The temporary branch is deleted after the queue is done with it, so you cannot check it out later to reproduce the failure.
Use base_sha to reproduce locally. Check out the base commit, merge the pull requests listed in the queue ahead of yours, then merge your branch. That reproduces what the queue tested.
Recovering a removed pull request
After you know the cause, pick the matching fix.
A real conflict between changes. Update your branch from the base branch, fix the interaction, and push. Wait for the pull request checks to pass again, then add the pull request back to the queue. It joins at the back, so you lose your place.
A flaky test. Do not simply re-queue and hope. Re-queuing costs you the queue position and triggers a new set of runs for everyone behind you. Fix or quarantine the flaky test as a separate pull request. If the cause was infrastructure, such as a runner outage, re-queuing is reasonable.
A check that never reported. This is a configuration problem, not a code problem. The required check name probably does not run on merge_group, or a path filter skipped the workflow. Fix the workflow first. Otherwise every pull request fails the same way.
A merge conflict at queue time. Rebase or merge the base branch into your branch, resolve the conflict, push, and re-queue.
Keeping the queue moving
Failures cost the whole queue, not just the author, so reduce them where they start.
- Keep required checks fast and deterministic. A test with a 2% flake rate removes about one in fifty pull requests for no reason.
- Keep required checks few. Each required check is another way to be removed.
- Run extra, slower checks only on the pull request. Run on
merge_grouponly the checks you require. - Treat a repeat failure on the same test across unrelated pull requests as a repository problem. Open an issue and fix it. Do not tell authors to re-queue.
Summary of behavior
- A failed or missing required check on a merge group removes that pull request from the queue.
- Pull requests behind it are rebuilt without it, so their checks run again.
- The pull request stays open and its branch is unchanged.
- Failure evidence lives in
merge_groupruns on temporary branches, so preserve logs and artifacts. - Cancel superseded runs only for the
pull_requestevent.
Exercise
Pull requests A, B and C are in the queue in that order, each with its own merge group. B fails a required check. What happens to A and C, and where do you look for the cause of B's failure?
Show answer
A is unaffected, because its group does not contain B, so it can merge when its checks pass. B is removed from the queue and stays open. C's group contained B, so GitHub discards it and rebuilds C on the base branch plus A, then runs C's checks again. To find the cause, open the Actions tab, filter by the merge_group event, and read the failed run for B's temporary gh-readonly-queue branch. B's own pull request checks may be green, so they will not show the failure.
Exercise
Your team's pull requests are removed from the queue with no failed test, and the timeline mentions the checks did not report. The workflow has on: pull_request only. What is the fix, and why does a short timeout make the problem worse in other situations?
Show answer
Add merge_group to the workflow's on: triggers, since the required check never runs for the temporary branch and so never reports a status. A timeout shorter than the slowest check plus runner wait time removes healthy pull requests when CI is busy, and each removal forces a rebuild of the pull requests behind it.