Sub topic 3
Day to day: queueing and dequeueing pull requests
Assume you know Git branches, pull requests, branch protection, and GitHub Actions. A merge queue is a GitHub service that orders approved pull requests and tests them together before merging.
Queueing and dequeueing pull requests
When a pull request is approved and its required checks pass, select Add to merge queue. GitHub places it behind earlier entries. The queue creates a temporary merge group containing the pull request, the current base branch, and possibly other queued pull requests.
Remove a pull request from the queue when you need to revise it, pause deployment, or merge another change first. Use Remove from merge queue in the pull request interface. Removing it does not close the pull request or delete its branch.
When checks fail in the queue
A failure tests the merge group, not necessarily one pull request. A change may pass alone but fail when combined with another queued change. GitHub may remove the failing entry or rebuild groups according to the queue's grouping strategy. Inspect the merge-group workflow run and reproduce the failure locally when possible.
Balancing throughput, latency, and CI cost
Larger groups reduce the number of workflow runs, but a failure can block or disturb more pull requests. Smaller groups give clearer failure ownership but consume more CI time. Higher build concurrency reduces waiting while increasing cost.
Use short check timeouts for predictable tests. Increase them when valid builds often exceed the default. Choose squash or merge commits to match your repository's history policy.
Troubleshooting common queue problems
- An empty queue often means the pull request is not approved, lacks required checks, or does not meet branch rules.
- A stuck entry may have a workflow that does not trigger on
merge_group. - A repeated failure may come from a test that depends on time, ordering, or external state.
- A pull request can leave the queue after new commits; update it, rerun checks, and queue it again.
Configuring the queue through the rulesets API
A repository ruleset can define queue behavior as code:
{
"name": "main-merge-queue",
"target": "branch",
"enforcement": "active",
"conditions": {
"ref_name": {
"include": ["refs/heads/main"],
"exclude": []
}
},
"rules": [
{
"type": "merge_queue",
"parameters": {
"merge_method": "SQUASH",
"grouping_strategy": "ALLGREEN",
"max_entries_to_build": 5,
"check_response_timeout_minutes": 60
}
}
]
}Comparing alternatives
GitHub's built-in queue integrates with branch rules and pull requests. Dedicated tools can offer richer batching, dashboards, or cross-repository orchestration, but they add configuration and operational cost. Use the built-in queue when GitHub Actions and repository rulesets meet your needs.
Exercise
Why can a pull request with passing checks still fail after entering the merge queue?
Show answer
The queue tests a temporary merge group that includes the pull request, the latest base branch, and possibly other queued pull requests.