Auto-merge
The ability to configure automatic pull request merge can greatly unblock developers that typically wait for hours, or even days, to receive a LGTM review.
Since not every pull request needs the same review process, using the semantic features of Reviewpad, you can configure many scenarios where auto-merge seems natural.
Out of the box, Reviewpad supports a merge action which can be used in multiple scenarios.
Auto-merge based on file properties
labels:
ship:
description: Ship mode
color: 76dbbe
rules:
- name: only-docs-changes
spec: $hasFileExtensions([".md"])
workflows:
- name: ship
description: Ship process - bypass the review and merge with rebase
if:
- rule: only-docs-changes
then:
- $addLabel("ship")
- $merge()
Auto-merge small pull requests
labels:
ship:
description: Ship mode
color: 76dbbe
groups:
- name: ignore-patterns
spec: '["*.lock", "generated/**"]'
rules:
- name: is-small-patch
description: Patch has less than 90 changes and 6 files
spec: $size($group("ignore-patterns")) < 90 && $fileCount() <= 5
workflows:
- name: ship
description: Ship process - bypass the review and merge with rebase
if:
- rule: is-small-patch
then:
- $addLabel("ship")
- $merge("rebase")
Auto-merge non-critical pull requests
The hasAnnotation built-in can be used to configure powerful auto-merges. See a more in-depth example of the usage of hasAnnotation in the automated labelling section.
labels:
ship:
description: Ship mode
color: 76dbbe
rules:
- name: not-critical-changes
description: Patch does not touch critical code
spec: $hasAnnotation("critical") == false
workflows:
- name: ship
description: Ship process - bypass the review and merge with rebase
if:
- rule: not-critical-changes
then:
- $addLabel("ship")
- $merge("rebase")
Auto-merge on required approvals
In GitHub, repository administrators can require a minimum number of pull request approvals before merging into a protected branch.
However, we may want the required number of approvals to come from a defined set of users/team. In this case, GitHub does not offer this ability.
We can use Reviewpad to verify if a pull request has the required number of approvals from a specific team.
Here's an example of a reviewpad.yml
configuration that verifies if a pull request has at least 2 approvals from the core team when changes are critical.
rules:
- name: changes-critical-code
spec: $hasAnnotation("critical")
workflows:
- name: auto-merge-on-required-approvals
if:
- $rule("changes-critical-code") && $hasRequiredApprovals(2, $team("core"))
then:
- $merge()