First Revy Action: PR Size Label

This page will help you run your first Revy Action to automatically label pull requests in a GitHub repository depending on their size.

You can check this Revy action in the GitHub repository reviewpad/pr-size-labeller.

To keep things simple, we will consider the size of a pull request as the sum of number added lines with the number of deleted lines.

Our goal is to automatically label PRs depending on their size:

  • small until 90 LOC
  • medium from 90 until 300 LOC
  • large to PRs after 300 LOC.

To do this, we just need to do two steps.

Step 1. Configure the GitHub action

Configure Reviewpad as a GitHub Action in a pull_request workflow:

name: Reviewpad Action
on:
  pull_request

jobs:
  reviewpad-action:
    runs-on: ubuntu-latest
    steps:
      - name: Running reviewpad action
        uses: reviewpad/[email protected]

The source code of the GitHub Action can be found in the GitHub repository reviewpad/action.

Step 2. Add revy.yml to the root of the repository

Add the configuration file revy.yml to the root of your repository.

apiVersion: reviewpad.com/v0.0.4

labels:
  small:
    description: small changes
    # color is the hexadecimal color code for the label, without the leading #.
    color: "294b69"
  medium:
    description: medium changes
    color: "a8c3f7"
  large:
    description: large changes
    color: "8a2138"

rules:
  isSmall:
    kind: patch
    description: small pull request
    spec: $size() <= 90
  
  isMedium:
    kind: patch
    description: medium-sized pull request
    spec: $size() > 90 && $size() <= 300

  isLarge:
    kind: patch
    description: large-sized pull request
    spec: $size() > 300
  
protectionGates:
  - name: label-pull-request-with-size
    description: Label pull request with size
    patchRules:
      - rule: isSmall
        extraActions:
          - $addLabel("small")
      - rule: isMedium
        extraActions: 
          - $addLabel("medium")
      - rule: isLarge
        extraActions: 
          - $addLabel("large")

Now, on each pull request event that triggers the GitHub workflow, Reviewpad will put the appropriated label depending on the size.

See some examples at reviewpad/pr-size-labeller/pulls.


Did this page help you?