Sub topic 14
How the built-in queue compares with other tools
This chapter assumes you know Git branching, pull requests, branch protection or rulesets, and GitHub Actions required status checks. You also need the merge queue model from earlier chapters: a queue builds temporary merge group branches and tests each pull request against the latest base branch plus the changes ahead of it. Here you will compare that built-in queue with the other ways teams keep a busy main branch green, and decide which one fits your situation.
What problem each tool solves
Every tool in this chapter tries to stop the same failure. Two pull requests each pass checks against an older main. Both merge. The combined result breaks. The tools differ in where they test the combination, who controls the process, and what it costs.
The main options are:
- Branch protection with "Require branches to be up to date before merging" and no queue.
- The built-in GitHub merge queue.
- Third-party merge queues and merge bots, such as Mergify, Bors-style bots, Aviator, Graphite, or Kodiak.
- Self-hosted automation, such as a custom GitHub Actions workflow or a bot built on the GitHub API.
- Trunk-based development with feature flags and post-merge testing, with no gate at all.
The product names are examples. Their features change, so check each vendor's current documentation before you decide.
Option 1: "Require branches to be up to date"
This setting is part of branch protection and rulesets. A pull request cannot merge until its branch contains the current tip of the base branch.
It works, but it scales badly. When the base branch moves, every open pull request becomes out of date. Each author must update the branch, wait for checks again, and hope no one else merges first. With ten active authors, this becomes a race. Someone merges, the other nine are stale, and the cycle repeats.
A merge queue removes the race. Authors add a pull request to the queue once. The queue does the updating and retesting for them.
| Aspect | Up-to-date requirement | Built-in merge queue |
|---|---|---|
| Who updates the branch | The author, by hand or with the update-branch button | The queue, automatically |
| What is tested | The pull request branch plus current main | The pull request plus main plus every entry ahead of it |
| Contention | Authors race to merge | Entries wait in order |
| Extra workflow setup | None | Workflows must handle `merge_group` |
| Cost per merge | One run per update | One run per queue build, which may cover a group |
The up-to-date requirement is enough for small teams that merge a few times a day. Past that, authors spend more time rebasing than coding.
Option 2: the built-in merge queue
The built-in queue is part of GitHub's branch protection and rulesets. You configure it in the same place as your other merge rules.
Strengths:
- No extra service. There is no app to install, no webhook receiver, and no extra account to manage.
- Integrated permissions. It uses the same required checks, required reviews, and bypass rules as the rest of the repository.
- Native user interface. The pull request page shows queue position, the "Merge when ready" action, and the removal reason.
- Rules as code. The
merge_queuerule is available in the rulesets API, so you can version and review its settings.
Limits you should know before committing:
- Few merge-order controls. You can set the merge method, build concurrency, group size, wait time, and check timeout. You cannot assign priorities to pull requests or define custom ordering rules. Some third-party tools offer these.
- Workflow changes are required. Every required workflow needs the
merge_grouptrigger. A missing trigger leaves the queue waiting for a status that never arrives. - Plan and repository requirements. Availability depends on your plan and on whether the repository is owned by an organization. Confirm this in the current GitHub documentation.
- Limited customization of batching. You choose a grouping strategy from the options GitHub provides. You cannot write your own logic for which pull requests share a batch.
The workflow trigger from earlier chapters looks like this:
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 testBecause checks_requested is the only activity type for merge_group, you may also write merge_group: with no types key.
Option 3: third-party queues and merge bots
Third-party tools predate the built-in queue and cover more specialized needs. They usually run as a GitHub App or a hosted service. They watch pull request events, create their own temporary branches, and merge when checks pass.
Features that third-party tools may provide, depending on the product:
- Priority lanes, so a hotfix can jump ahead of normal work.
- Queue rules based on labels, paths, or authors.
- Speculative testing of several queued pull requests in parallel, with their own strategies for failure recovery.
- Monorepo awareness, so unrelated changes in different directories do not block each other.
- Support for other Git hosts.
- Dashboards and analytics on queue time and CI use.
The costs are real:
- Another dependency. If the service is down, merging may stop. You also depend on the vendor's roadmap and pricing.
- Another permission holder. The app needs write access to your repository. Review what it can do and how it authenticates.
- Two systems to configure. Rules may live in a file in the repository or in the vendor's web interface, apart from your GitHub rules.
- Interaction with GitHub features. If both a third-party queue and the built-in queue are active on the same branch, they will conflict. Pick one per branch.
A useful test is to ask whether you need a feature the built-in queue lacks. If the answer is "not really", the integrated option has less to maintain.
Option 4: custom automation
Some teams write their own bot or a GitHub Actions workflow that rebases a pull request, runs tests, and merges. This gives total control and is a common starting point for teams with unusual requirements.
It also gives you the whole maintenance burden. You must handle concurrent runs, token permissions, partial failures, retries, and the corner cases that the built-in queue already handles, such as a pull request closed while its build is running. A hand-built queue often works well on a quiet day and fails during a release rush.
Build custom automation only when no existing tool meets a specific need, and keep it small.
Option 5: no gate, with fast detection
Some teams do not gate merges at all. They merge to main after review, run the full suite afterward, and use feature flags and fast reverts to limit damage. This is common in large trunk-based organizations with strong observability and quick rollback.
This approach trades safety for speed. A broken main will happen, and your process must make it cheap: automated bisection, an on-call owner, and a rule that the first response is to revert. It is a deliberate choice, not a default. Teams that have no automated revert path should not adopt it.
Choosing between them
The decision depends on how often main breaks, how long CI takes, and how much control you need.
Use these criteria as a checklist:
- Merge volume. A handful of merges per day rarely justifies a queue. Dozens per day usually does.
- CI duration. The longer a build takes, the more a stale-branch race costs, and the more a queue helps. Long builds also make queue latency worse, so combine queues with fast tests where you can.
- Ordering needs. If every pull request is equal, the built-in first-in, first-out order is fine. If hotfixes must skip ahead, look at tools with priorities.
- Repository layout. A monorepo with independent areas may want path-aware queueing.
- Operational ownership. Count who will maintain the tool and who gets paged when it stops merging.
- Compliance. Check which tools your security team allows to hold write access.
Migrating between tools
Moving from a bot or the up-to-date requirement to the built-in queue is mostly a workflow and settings change. Do it in this order:
- Add
merge_groupto every workflow that produces a required check, and merge that change first. It is harmless without a queue. - Disable the old bot on the target branch, or you will have two systems trying to merge.
- Enable the queue through a ruleset, starting with conservative settings such as a build concurrency of one and a group size of one.
- Watch queue time and failure reasons for a week, then raise concurrency and group size gradually.
Keep the previous settings documented so you can roll back. Remember that required check names must match between the pull request run and the merge group run, or the queue will wait forever.
A ruleset that applies the queue to main can be sent to the create-ruleset REST endpoint:
{
"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",
"min_entries_to_merge": 1,
"max_entries_to_merge": 5,
"min_entries_to_merge_wait_minutes": 5,
"max_entries_to_build": 5,
"check_response_timeout_minutes": 60
}
}
]
}Starting from one entry per build and one concurrent build, as step 3 suggests, means changing max_entries_to_merge and max_entries_to_build to 1.
Common mistakes when comparing tools
- Comparing features without comparing cost. Speculative parallel builds finish sooner but use more CI minutes. This applies to the built-in queue's concurrency setting as much as to third-party tools.
- Running two queues on one branch. Pick one system per branch.
- Forgetting the workflow change. The most common failure after adopting the built-in queue is a required check that never runs for
merge_group. - Treating a queue as a test strategy. A queue only runs your checks in a better place. Flaky or slow tests will make the queue flaky and slow.
Exercise
Your team merges about 40 pull requests a day to main. CI takes 25 minutes. Authors complain that they keep updating their branches because someone else merges first. Nobody needs priority lanes or path-aware batching. Which option fits, and what must you change in your workflows before enabling it?
Show answer
Use the built-in merge queue. It removes the update-and-retest race, and with no need for priorities or custom batching there is no reason to add a third-party service. Before enabling it, add the merge_group trigger to every workflow that produces a required status check, so those checks report on the temporary merge group branch. Keep the check names the same as on the pull request run.
Exercise
A team enables the built-in merge queue while an existing merge bot is still active on main. What problem should you expect, and how do you fix it?
Show answer
Two systems will try to control merging to the same branch, so they can conflict, for example by updating branches or merging pull requests in different orders. Disable the bot on that branch (or remove its merge permissions) and use one system per branch.