Enabling the "require branches be up to date" feature on GitHub repositories is great because, when coupled with CI, master will always be green.
However, as the number of collaborators on a GitHub repo increases, a repetitive behavior emerges where contributors are updating their branches manually hoping to merge their branch before others.
Kodiak fixes this wasteful behavior by automatically updating and merging branches. Contributors simply mark their PR with a (configurable) label to indicate the PR is ready to merge and Kodiak will do the rest; handling branch updates and merging using the minimal number of branch updates to land the code on master.
This means that contributors don't have to worry about keeping their PRs up to date with the latest on master or even pressing the merge button. Kodiak does this for them! 🎉
Additionally this introduces fairness to the PR merge process as ready to merge PRs in the merge queue are merged on a first come, first served basis.
Kodiak efficiently updates pull requests by only updating a PR when it's ready to merge. This prevents spurious CI jobs from being created as they would if all PRs were updated when their targets were updated.
How does it work?
Kodiak receives a webhook event from GitHub and adds it to a per-installation queue for processing
Kodiak processes these webhook events and extracts the associated pull requests for further processing
Pull request mergeability is evaluated using PR data
- kodiak configurations are checked
- pull request merge states are evaluated
- branch protection rules are checked
- the branch is updated if necessary
If the PR is mergeable it's queued in a per-repo merge queue
A task works serially over the merge queue to update a PR and merge it
The pull request is merged 🎉