Skip to content
Latchkey

How to Combine a Merge Queue With Incremental CI

The merge queue builds a candidate merge commit and fires the merge_group event; running your affected detection against that group base keeps incremental CI correct as PRs combine.

A merge queue tests the actual combination of queued PRs before merge. Add the merge_group trigger and compute your affected set against the group base so incremental selection reflects the batched change, not a single PR.

Steps

  • Add merge_group to the workflow triggers.
  • Use the merge group base ref for change detection.
  • Keep the same required checks so the queue enforces them.

Workflow

.github/workflows/ci.yml
on:
  pull_request:
  merge_group:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - run: npm ci
      # affected against the base the queue is merging into
      - run: npx nx affected -t test --base=origin/main

Gotchas

  • Incremental selection at PR time can miss a break that only appears when two PRs combine; the merge queue re-testing the group is what catches it.
  • Required checks must be configured to run on merge_group, or the queue cannot verify them.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →