Requesting reviews on a pull request is a standard part of the workflow of most teams. However, there are a few subtleties to what may sound very basic.

When assigning a pull request to a team rather than individuals, the pull request might get stuck forever. The diffusion of responsibility is a phenomenon whereby a person is less likely to take responsibility for action or inaction when other bystanders or witnesses are present. In that case, your team members might assume that others will review the pull request.

A key to merging pull requests is to make sure people are accountable and responsible. Pull Assigner was one of the first services to implement a solution to this problem. However, the news has landed: the service is shutting down this month.

Let's see some ways to solve that problem with Mergify!

Writing Assignment Rules

The core idea is that asking reviews from individuals is better than asking reviews from a team.

Mergify offers the ability to request reviews from teams or individuals, picked randomly. Here's an example:

pull_request_rules:
  - name: random request review for dependabot
    conditions:
      - author=dependabot[bot]
      - "#review-requested=0"
    actions:
      request_review:
        users:
          - jd
          - sileht
          - GuillaumeOj
        random_count: 1

When dependabot creates a pull request, Mergify requests a review from one of the listed users. Such a rule is great for spreading reviews across your team members.

You can even mix individuals and teams:

pull_request_rules:
  - name: random request review for dependabot
    conditions:
      - author=dependabot[bot]
      - "#review-requested=0"
    actions:
      request_review:
        users:
          - jd
          - sileht
          - GuillaumeOj
        teams:
          - devs
        random_count: 1

Using Weight to Spread the Load

In certain circumstances, you might want to assign a different number of reviews depending on people. Using weight in your Mergify configuration makes  it possible to distribute your review request equitably:

pull_request_rules:
  - name: random request review for dependabot
    conditions:
      - author=dependabot[bot]
      - "#review-requested=0"
    actions:
      request_review:
        users:
          jd: 4
          sileht: 1
          GuillaumeOj: 1
        random_count: 1

With such a rule, the user jd will have 4 more chances to see a review requested from him. This can be useful to include a user from time to time in order for they to ramp up.

Using the ability to write fine-grained rules, you can tune your request review algorithm to your feeling, ensuring your pull requests are approved on time!