Extends
Through the extends
property, Reviewpad users can import another Reviewpad configuration file.
This provides the ability to share across multiple repositories some common workflows and definitions of labels or rules for instance.
Importing some configuration files
In the Reviewpad configuration, users specify with the extends
property
a list of other Reviewpad configuration filepaths to be imported. Each filepath must be a GitHub blob URL (e.g. https://github.com/reviewpad/reviewpad/blob/main/reviewpad.yml
).
As an example:
extends:
- https://github.com/baz/foo/blob/main/common.yml
- https://github.com/baz/qux/blob/main/team_a.yml
These GitHub blob URLs can live in different repositories.
Please note that Reviewpad GitHub App (or the underlying token used to run Reviewpad) has to be able to read the contents of these repositories. You can do it by installing the Reviewpad GitHub App in all repositories (or the whole organization) where you which to extend Reviewpad from.
In the example above, Reviewpad GitHub App needs to be installed either in the organization baz
or in both projects foo
and qux
.
The final configuration is computed by concatenating all configurations included in the extends section (in the order they are specified) with the contents of the current configuration.
Overriding some properties
As part of a configuration, if you have for instance two workflows or two labels with the same name, the last one has the precedence and so overrides the previous one.
For example, consider the following specification:
extends:
- https://github.com/baz/foo/blob/main/common.yml
- https://github.com/baz/qux/blob/main/team_a.yml
workflows:
- name: small-size
run:
if: $getSize() < 30
then: $reportInfo("this is a small pr")
Where common.yml
:
metrics-on-merge: true
workflows:
- name: small-size
run:
if: $getSize() < 5
then: $reportInfo("this is a very small pr")
- name: medium-size
run:
if: $getSize() >= 30
then:
- $reportInfo("this is not a small pr")
- $addReviewerRandomly()
and team_a.yml
:
workflows:
- name: small-size
run:
if: $getSize() < 10
then: $reportInfo("this is a small pr for team a")
- name: medium-size
run:
if: $getSize() >= 30
then: $reportInfo("this is not a small pr")
The final configuration will be:
metrics-on-merge: true
workflows:
# we first load the "medium-size" workflow from common.yml (the first configuration in the extends section)
# then we override it with the "medium-size" workflow from team_a.yml (the second configuration in the extends section)
- name: medium-size
run:
if: $getSize() >= 30
then: $reportInfo("this is not a small pr")
# we first load the "small-size" workflow from common.yml (the first configuration in the extends section)
# then we override it with the "small-size" workflow from team_a.yml (the second configuration in the extends section)
# and finally we override it with the "small-size" workflow from the current configuration
- name: small-size
run:
if: $getSize() < 30
then: $reportInfo("this is a small pr")
During the extension process, the properties that are being overridden are logged on the Reviewpad execution details.
For example, taking into account the configurations mentioned above we would have the following logs:
[warning] Workflow 'medium-size' has been overridden by https://github.com/baz/foo/blob/main/common.yml
[warning] Workflow 'small-size' has been overridden by https://github.com/baz/foo/blob/main/common.yml
[warning] Workflow 'medium-size' has been overridden by https://github.com/baz/qux/blob/main/team_a.yml
[warning] Workflow 'small-size' has been overridden by https://github.com/baz/qux/blob/main/team_a.yml