-
🔰 fundamental topics for beginners getting started with DevSensei
-
🔬 advanced topics for once you have your first workflows automated
List of enforced checks that protect against merging unless they all succeed.
Let us know if your use case is not covered.
Merge checks reuse the same expressions as conditions, and can be grouped with a custom title. DevSensei also offers alias merge checks for common use cases.
Custom Check
Example
merge-checks:
- title: block when PR title requests
check:
- title ~!= '[block]*'
Properties
|
Property |
Definition |
|---|---|
|
|
a list of conditions that must all be met for the check to pass. The list of conditions are implicitly combined with |
|
|
a ( |
Alias: Minimum Approvals
Equivalent to a custom merge check with the single condition count(approved-by) >= n for positive number n.
Example
merge-checks:
- minimum-approvals: 1
Properties
|
Property |
Definition |
|---|---|
|
|
a positive ( |
Alias: Minimum Successful Builds
Equivalent to a custom merge check with the conditions:
-
count(builds.successful) >= nfor a positive numbern. -
count(builds.failed) = 0disallow failed builds -
count(builds.in-progress) = 0wait for all builds to be complete
Example
merge-checks:
- minimum-successful-builds: 1
Properties
|
Property |
Definition |
|---|---|
|
|
a positive ( |
Alias: No Open Tasks
Equivalent to a custom merge check with the single condition count(open-tasks) = 0.
Add this merge check by adding the string no-open-tasks to the workflow merge-checks list.
Example
merge-checks:
- no-open-tasks
Properties
This merge check alias has no property.
Code Owners Merge Check
This merge check enforces rules as described in the Code Owners documentation. For existing CODEOWNERS users, copy your merge checks to this section.
Properties
|
Property |
Definition |
|---|---|
|
|
a multiline string, where each line is an independent rule, and each line must be simultaneously true. Combine multiple rules on the same line with |
Example
merge-checks:
- codeowners-check: |
(Check(@@MyDevs >= 2) | Check(@@JavaExperts >= 1))
Merge Check Use Cases
The merge-checks section gives more control over which pull requests should be merged, for example applying unique checks to specific branch patterns.
|
Use Case |
Example Workflow |
|---|---|
|
Enforce that there are no incomplete tasks |
YAML
|
|
Enforce that the build passed, and no other build is in progress or failed |
YAML
|
|
Enforce that on PRs to the main branch there are at least 3 approvers |
YAML
|
|
Enforce branch naming conventions |
YAML
|
|
Prevent merge to release branch from a feature branch. |
YAML
|
|
Restrict PRs on certain branches to be specific author. |
YAML
|
|
Prevent merge PR where either |
YAML
|
|
Ensure there are Jira issues references and commit titles follow a guide line |
YAML
|
|
Prevent merge PR with too many file changes. |
YAML
|
|
Prevent merge if draft or conflicting. This matches Bitbucket’s own behavior so is unnecessary, but demonstrates how you could create equivalent checks with conditions. |
YAML
|
Planned Use Cases
The following ideas rely upon planned or otherwise unimplemented features. Contact support to let us know your use case.
Fine-grained equivalents to built-in Bitbucket merge checks
Supporting the following would allow to create finer grained checks (e.g. by filtering on destination branch pattern):
-
Require no "requested changes" status
Support non-functional requirements
-
Require that a pull request has been open long enough to be seen (time-based condition)
-
Prevent merge to a release branch on a specific day.
More fine-grained attributes
-
check text contents of
open-tasks, e.g. if your team uses a marker to indicate some tasks can be ignored. -
check specific user in
approved-by.
Code Owners merge checks
Over time we hope to migrate the merge checks from the add-codeowners action, starting with the codeowners-check option. We could possibly make them more flexible, for example check the intersection of approved-by with the added code owners.