Revy Syntax

A Revy configuration file has the following shape:

apiVersion: reviewpad.com/v0.0.4
mode: MODE

labels:
 label_1
 label_2
 ...
 label_N

groups:
  group_1
  group_2
  ...
  group_N
rules:
  rule_1
  rule_2
  ...
  rule_N
protectionGates:
  - gate_1
  - gate_2
  ...
  - gate_N

You can see the latest formal version of the format here.

If you use VSCode, we recommend that you setup yaml.schemas to enjoy syntax checking and auto-completion.

The central concept in this specification is the protection gate.

A protection gate is a specification of a list of actions to be executed if the pull request satisfies any of the rules in its specification.

Example. Automated labeling of pull requests

Consider the following revy.yml:

apiVersion: reviewpad.com/v0.0.4

labels:
  small:
    color: "f15d22"
    description: Pull requests with less than 90 LOC

rules:
  isSmallPatch:
    kind: patch
    description: Patch has less than 90 LOC
    spec: $size() < 90

protectionGates:
  - name: labelSmall
    description: Label small pull requests
    patchRules:
      - rule: isSmallPatch
    actions:
      - $addLabel("small")

This configuration file specifies one protection gate called labelSmall which automatically labels a pull request with small if it changes less than 90 lines of code.

API Version

The apiVersion is the version of Revy specification format. The version is necessary so the the format can be evolved, and the field is used for the parser to know how to interpret the content.

Mode

The mode is a flag that allows you to enable or disable a report of Revy as a pull request comment. By default, Reviewpad will comment on the pull request with the results of execution. If you don't want this comment use:

mode: silent

Label

A label specifies a label that can be used as an argument to the label related functions.

The structure of a label is as follows:

LABEL-NAME:
  description: STRING [OPTIONAL]
  color: STRING [OPTIONAL] 
  • name of a label is used to reference it in other entities.
  • description is a short description of the label. Must be 100 characters or fewer.
  • color is the hexadecimal color code for the label, without the leading #.

If the label does not exist in the repository, it will be created. If it already exists in the repository, no action will be taken.

Group

A group specifies a list of entities. At the moment, we only support GitHub users.

There are two ways to specify a group:

Group By Enumeration

GROUP-NAME:
  description: STRING
  kind: developers
  spec: '[LIST OF GITHUB USERS]'
  • name of a group is used to reference it in other entities.
  • kind of a group can only be developers at the moment.
  • description is a string that can be used to provide more details about the group.
  • spec is an Aladino array.

Example. Group by Enumeration

groupWithMarcelo:
  description: The group composed of marcelosousa
  kind: developers
  spec: '["marcelosousa"]'

Group By Filter

GROUP-NAME:
  description: STRING
  kind: developers
  type: filter
  param: VARIABLE
  spec: ALADINO-BOOLEAN-EXPRESSION
  • name of a group is used to reference it in other entities.
  • kind of a group can only be developers at the moment.
  • type with filter specifies that we will require a param and a boolean spec.
  • param declares the name of a variable representing a single developer.
  • spec is an Aladino boolean expression that uses the param variable to define a condition on which developers should be part of the group.

Example. Group by Filter

newJoiners:
    description: Group of devs that have created less than 10 PRs
    kind: developers
    type: filter
    param: dev
    where: $totalCreatedPRs($dev) < 10

Rule

A Revy rule specifies a boolean condition on a pull request.

The structure of a rule is as follows:

RULE-NAME:
  kind: [patch | author]
  description: STRING
  spec: ALADINO-BOOLEAN-EXPRESSION
  • name of a rule is used to reference it in other rules and protection gates.
  • kind of a rule can be either patch or author. The kind is related to different properties of pull requests that will be used in the evaluation of the spec field.
  • description is a string that can be used to provide more details about the rule.
  • spec is a boolean expression in Aladino.

Protection Gate

The structure of protection gate is as follows:

- name: STRING
  description: STRING
  alwaysRun: BOOLEAN
  patchRules:
    - rule: REF_TO_RULE_1
      extraActions: [OPTIONAL]
        - ACTION_1
        - ACTION_2
        ...
        - ACTION_N
    ...
    - rule: REF_TO_RULE_N
  actions: [OPTIONAL]
    - ACTION_1
    - ACTION_2
    ...
    - ACTION_N
  • name is a string that identifies the protection gate.
  • description is a string that can be used to provide more details about the rule.
  • alwaysRun field is a boolean that specifies the protection gate should always be checked or not. By default, this value is false.
  • patchRules field specifies which rules should be checked. For each rule, we can also specify a list of extra actions that will be executed if this rule is activated by the pull request.
  • actions field is a list of Aladino actions.

Did this page help you?