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:

  1. Open the SourceCraft home page.

  2. On the Home tab, navigate to Repositories.

  3. Select the repository you want to configure approval rules in.

  4. Clone the repository:

    1. In the top-right corner, click Clone.

    2. Depending on your connection method, copy the link for cloning the repository.

    3. In the terminal, run this command:

      git clone <link_for_cloning_repository>
      
    4. Go to your cloned repository:

      cd <repository_name>
      
  5. 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.

  6. Under usernames, list the users the pool request must feature at least one approval from.

  7. Add the approval rule configuration file to the git index, commit, and push the changes to the main branch:

    git add .src.ci.yaml
    git commit -m "Added code review configuration"
    git push -u origin main
    
  8. Make sure that the approval rules were applied:

    1. Create a test pull request.

    2. Make sure that in the pool request you created:

      • The Overview tab displays the Code Review verification with In progress status.
      • The Reviewers section shows some of the reviewers from among those specified in the approval rule configuration file.
    3. Wait for the pull request to be approved.

    4. To merge with the main branch, click Merge.

      Note

      The merging can be done only by users with the Repository developer role or higher.

See also