Merge Queue Batches
Test several queued pull requests in one CI run, to merge more of them for less CI.
A batch tests several queued pull requests together, in one CI run, and merges them all when it passes. The queue then merges more pull requests an hour, for fewer CI runs, than one that tests each pull request on its own.
When to use batches
Section titled When to use batchesUse them when pull requests arrive faster than your CI can test them one at a time, or when each CI run is expensive. A batch pays off when most pull requests pass: one that fails takes the batch down with it, and finding it costs extra CI runs.
Configuring batch merging
Section titled Configuring batch mergingSet batch_size on the queue rule:
queue_rules: - name: default batch_size: 5 batch_max_wait_time: 5 minMergify waits up to 5 minutes for five pull requests, then tests the batch with what it has.
A longer batch_max_wait_time fills batches and saves CI; a shorter one merges
sooner.
How batches behave
Section titled How batches behaveMergify pushes each batch to a branch of its own, on top of the base branch and
the batches ahead of it, and by default opens a draft pull request for it, so
your CI runs on the batch like on any pull request. Run CI on a
Batch covers your CI’s side, and Keep Merge Queue Pull
Requests Out of Your Way the drafts.
When the batch passes, Mergify merges the original pull requests and closes the
draft. To merge the tested commit itself, see
fast-forward and
merge-batch.
Dynamic batch sizing
Section titled Dynamic batch sizingWith a {min, max} range as batch_size, Mergify spreads the queue over the
free parallel checks: batches stay
at min while the queue is light and grow toward max when it backs up.
queue_rules: - name: default batch_size: min: 1 max: 10How pull requests are grouped into a batch
Section titled How pull requests are grouped into a batchA batch is not always the next pull requests in the queue. Mergify fills it with pull requests that touch the same scopes, or the same directories without scopes, so a failure drags fewer unrelated changes with it. It never takes a pull request ahead of a higher priority, and keeps a stack in one batch. Parallel mode batches by scope differently: see Batching in parallel mode.
In-place checks (no batch PRs)
Section titled In-place checks (no batch PRs)With batch_size: 1 and max_parallel_checks: 1 in serial
mode, Mergify can test each pull request in
place, on its own branch, with no draft pull request:
max_parallel_checks
lists every condition. Mergify updates that branch itself, which GitHub refuses
for some pull requests, such as one opened by another bot: see Combining merge
and update
methods.
Handling batch failure or timeout
Section titled Handling batch failure or timeoutWhen a batch fails, or its checks time out,
Mergify splits it to find the pull request that broke it: that one leaves the
queue and the others merge. The batches tested on top of the failed one are
cancelled, and their pull requests are tested again. While it runs, the batches
report a batch status such as
bisecting in the dashboard and the CLI.
With batch_max_failure_resolution_attempts, Mergify stops splitting after that
many rounds, and the pull requests it could not clear leave the queue with a
dequeue reason that says so.
With skip_intermediate_results, a batch that passes also merges the batches it
was tested on top of, so a flaky failure there no longer holds them up.
When a Batch Fails draws the split, the batch sizes that split cleanly, both options, and Fail First, which makes each split cheaper.
Options
Section titled OptionsUnder queue_rules:
batch_max_failure_resolution_attempts#The number of attempts to resolve a batch failure before dequeueing pull requests. By default, Mergify will attempt to resolve a batch failure by splitting the batch multiple times until it finds the root cause of the failure. You can stop this process earlier by limiting the number of resolution attempts. Setting this to 0 will dequeue all the pull requests from a batch when a batch fails.
batch_max_wait_time#The maximum amount of time to wait for additional pull requests before processing a batch that hasn't reached batch_size. The timer starts when the first pull request enters the batch. If batch_size is reached before this time expires, the batch processes immediately. This does not enforce a minimum delay between batches.
batch_size#The number of pull requests per speculative check in the queue. Either a single integer (fixed size, 1-128) or an object {min, max} for dynamic batching: the queue uses min when parallel-check slots are plentiful and grows toward max to keep the backlog at zero.
Under merge_queue:
skip_intermediate_results#Allow PRs to merge even if their own speculative check fails, as long as later downstream checks including them pass and test every scope they touch between them, and schedule conditions are valid.
See also
Section titled See alsoWas this page helpful?
Thanks for your feedback!