Sub topic 5
Required checks in a queued world
This chapter assumes you know GitHub Actions workflow syntax, how required status checks work on a pull request, and how branch protection rules or rulesets are configured. It also assumes you have read the previous chapters on merge groups and enabling the queue.
Two rounds of checks
With a merge queue, each required check runs twice for the same pull request:
- On the pull request branch, before the pull request can join the queue.
- On the temporary merge group branch, after it joins the queue.
The second round is the one that protects main. The queue builds a commit from the latest base branch, the changes queued ahead of it, and your changes, and it asks your required checks to pass on that commit. A pull request merges only if they do.
The required checks you list in branch protection or in a ruleset apply to both rounds. You don't configure them separately.
The common failure: a check that never reports
A workflow that triggers only on pull_request never starts on a merge group branch. The required check stays pending on the merge group commit. The queue waits until the check response timeout expires, then removes the pull request. Nothing is wrong with your code, but the pull request never merges.
The fix is to add the merge_group event to every workflow that produces a required check.
name: CI
on:
pull_request:
branches: [main]
merge_group:
types: [checks_requested]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: make testThe job name test is what the required check matches, so it must be the same for both events. If you use a matrix, or rename the job, update the required check list too.
You can omit types, because checks_requested is the only activity type for merge_group.
Checks that skip themselves
Some teams use path filters or if: conditions to skip jobs on pull requests that don't touch certain files. This is risky with a queue, because a skipped job may not report the status that the ruleset requires. Prefer this pattern:
- Run the job on every event.
- Detect inside the job whether the work is needed, and exit successfully if it isn't.
A job that always starts always reports a status, so the queue never waits on a check that won't arrive.
What to verify
- The required check list matches the job names in your workflows.
- Each workflow with a required job has
merge_groupin itson:block. - No required job depends on a
pathsfilter or on pull-request-only context, such asgithub.event.pull_request.number. - The check response timeout is longer than your slowest required check.
Exercise
A team enables a merge queue on main. Their required check test runs in a workflow with on: pull_request. Pull requests pass their checks and enter the queue, but each one is removed after about an hour. What is wrong, and what is the smallest fix?
Show answer
The workflow never runs on the merge group branch, so test never reports a status on the merge group commit. The queue waits until the check response timeout and then removes the pull request. The fix is to add merge_group: (optionally with types: [checks_requested]) to the workflow's on: block, so the test job runs for the queue too.