This repo is used to discover how Github merge queues work by using a simple node.js project and Github Actions for CI. The app pulls current weather data from OpenWeatherMap for a location.
Github merge queues are only available for org accounts:
- any public repo
- private repos on the Enterprise plan
npm start
will run the main file (app.js) and display results for Berlinnode app --location Paris
will run app.js for a custom location, e.g. Parisnpm test
will run the Mocha tests, output results and generate reports
There is a single queue per repo (at the moment).
There's is just a handful of configuration options to control queue's behaviour:
It wasn't obvious how Merge limits affect queue's behaviour - the minimum defines when queue starts merging PRs: as soon as one condition is met - N PRs added or M minutes passed.
Once merge queue is enabled, PRs can be added with "Merge when ready" button:
And eventually merged if status checks pass:
As PRs get added to the queue, Github will create a temporary branch and start merging PRs in the way they are added to the queue, running checks after each merge.
Here's the flow for two PRs that get successfully merged:
- We start by opening two PRs
- Then add one by one to the queue. Their status icon changes to reflect that:
- After "minimum PRs" limit is met (number of PRs or timeout), the queue starts merging them:
- If all goes well you'll end up with two merge commits on the main branch:
The actions page shows order of actions:
- tmp branch
gh-readonlhy-queue/main/pr..
branch is created - PR #3 is merged into the tmp branch, status checks pass
- PR #3 gets merged into
main
(as defined by Minimum PRs) - tmp branch
gh-readonlhy-queue/main..
branch is (most likely) again created - PR #4 is merged into the tmp branch, status checks pass
- PR #4 gets merged into
main
This behaviour is controller by Minimum pull requests to merge, if it had been 2, then both PRs would've been merged into tmp branch before mering each into main
.
If status checks fail, *that PR will be left out and the queue will proceed merging the remaning PRs. Here's a demo with 3 PRs where status checks fail for the second one:
- We start by opening 3 PRs
- enqueue them in order:
- then eventually get processed:
- PR #6 fails status checks since #5 modified the test file and it doesn't get merged:
- That's not indicated in any way on the PR page:
- and can be found in the CI/CD (Github Actions in this case):
- or with email notifications if enabled:
From the actions page it follows (assuming no clock skew):
- tmp branch
gh-readonlhy-queue/main..
branch is created - PR #5 is merged into the tmp branch, status checks pass
- PR #6 is merged into the tmp branch, status checks fail
- PR #5 gets merged into
main
- tmp branch
gh-readonlhy-queue/main..
branch is (most likely) again created - PR #7 is merged into the tmp branch, status checks pass
- PR #7 gets merged into
main
Let's update "Minimum pull requests to merge" to 2 and open two PRs:
- Enqueue the first PR
- It gets merged into tmp and checked, but not merged into
main
(unless 5min go by) - Enqueue the second PR
- The second gets merged into tmp branch and status checks pass
- Finally both get merged into main
- can 2+ branches have branch protection rules that include merge queue? How are then PRs merged if from both get added to the queue?