Setting up approval rules in a SourceCraft repository
With SourceCraft, you can flexibly set up mandatory approval rules before any code can be added to the target branch of the repository.
For more information, see Approval rules in SourceCraft.
The approval rule configuration is specified for a particular repository and stored in the root of the repository in a file named .src.ci.yaml
.
See the templates repository in SourceCraft for the full specification of the .src.ci.yaml
file.
To set up approval rules in a repository:
-
Open the SourceCraft home page.
-
On the
-
Select the repository you want to configure approval rules in.
-
Clone the repository:
-
In the top-right corner, click
-
Depending on your connection method, copy the link for cloning the repository.
-
In the terminal, run this command:
git clone <link_for_cloning_repository>
-
Go to your cloned repository:
cd <repository_name>
-
-
Generate an approval rule configuration file named
.src.ci.yaml
, e.g.:codereview: need_ships: 1 # Required number of approvals from reviewers ignore_self_ship: false # Ignore approvals from the pull request author ignore_non_reviewers_block: false # Ignore pull request blocking from non-reviewers auto_assign: true # Automatically assign reviewers rules: - patterns: - '*' reviewers: usernames: - "<user_name>" # List of reviewers assign: 1 # Number of automatically assigned reviewers need_ships: 1 # Required number of approvals from reviewers ignore_self_ship: false # Ignore approvals from the pull request author
See the templates repository in SourceCraft for the full specification of the
.src.ci.yaml
file. -
Under
usernames
, list the users the pool request must feature at least one approval from. -
Add the approval rule configuration file to the
git
index, commit, and push the changes to themain
branch:git add .src.ci.yaml git commit -m "Added code review configuration" git push -u origin main
-
Make sure that the approval rules were applied:
-
Create a test pull request.
-
Make sure that in the pool request you created:
- The
In progress
status. - The Reviewers section shows some of the reviewers from among those specified in the approval rule configuration file.
- The
-
Wait for the pull request to be approved.
-
To merge with the main branch, click
Note
The merging can be done only by users with the Repository developer role or higher.
-