Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extends capability to engine #515

Merged
merged 6 commits into from
Dec 9, 2022
Merged

feat: add extends capability to engine #515

merged 6 commits into from
Dec 9, 2022

Conversation

marcelosousa
Copy link
Member

@marcelosousa marcelosousa commented Dec 8, 2022

Description

This pull request introduces the extends capabilities in the Reviewpad configuration.

The extends feature works as follows.

The user can specify in the Reviewpad configuration a list of other Reviewpad configuration files as GitHub blob urls (e.g. https://github.com/reviewpad/reviewpad/blob/main/reviewpad.yml).

As example:

api-version: reviewpad.com/v3.x

extends:
  - https://github.com/reviewpad/reviewpad/blob/main/common_team.yml
  - https://github.com/reviewpad/reviewpad/blob/main/specific_team_a.yml

The final configuration will be the concatenation of all configurations included in the extends and the contents of the current configuration.

The extended configuration will be included in the order they are specified in the "extends" section.

If properties have the same name, the one that was defined last overrides the previous ones.

For example:

api-version: reviewpad.com/v3.x

extends:
  - https://github.com/reviewpad/reviewpad/blob/main/common_team.yml
  - https://github.com/reviewpad/reviewpad/blob/main/specific_team_a.yml
 
workflows:
  - name: add-label-with-small-size
    if:
      - rule: $size() < 30
    then:
      - '$info("this is a small pr")'

Where common_team:

api-version: reviewpad.com/v3.x
 
workflows:
  - name: add-label-with-small-size
    if:
      - rule: $size() < 5
    then:
      - '$info("this is a very small pr")'
  - name: add-label-with-medium-size
    if:
      - rule: $size() >= 30
    then:
      - '$info("this is not a small pr")'
      - '$assignRandomReviewer()'

and specific_team_a:

api-version: reviewpad.com/v3.x
 
workflows:
  - name: add-label-with-small-size
    if:
      - rule: $size() < 10
    then:
      - '$info("this is a small pr for team a")'
  - name: add-label-with-medium-size
    if:
      - rule: $size() >= 30
    then:
      - '$info("this is not a small pr")'

The final configuration will be:

api-version: reviewpad.com/v3.x
 
workflows:
  - name: add-label-with-medium-size
    if:
      - rule: $size() >= 30
    then:
      - '$info("this is not a small pr")'
  - name: add-label-with-small-size
    if:
      - rule: $size() < 30
    then:
      - '$info("this is a small pr")'

Follow-up:

  • Add more unit tests to increase the coverage of this feature (in particular the (r *ReviewpadFile) extends(o *ReviewpadFile) function)
  • Add logging information to notify users that labels, groups, rules, workflows or pipelines were overridden.
  • Add mixpanel event whenever a configuration uses the extends feature.

Related issue

Closes #306

Type of change

New feature (non-breaking change which adds functionality)

How was this tested?

Added unit tests to the loader that also check the DownloadContents of the GitHub API.

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have ran task check -f and have no issues

Code review and merge strategy (ship/show/ask)

  • Ask: this pull request requires a code review before merge

@reviewpad reviewpad bot added ask Pull request requires a code review before merge run-build Label that controls when build should be executed critical Modifications to critical changes labels Dec 8, 2022
@reviewpad reviewpad bot requested review from ferreiratiago and shay2025 December 8, 2022 21:40
@reviewpad reviewpad bot added the large large pull request label Dec 8, 2022
@reviewpad
Copy link

reviewpad bot commented Dec 8, 2022

Reviewpad Report

ℹ️ Messages

  • @marcelosousa: you are being notified because critical code was modified

@reviewpad reviewpad bot added the waiting-review PR waiting for review label Dec 9, 2022
@marcelosousa marcelosousa marked this pull request as ready for review December 9, 2022 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ask Pull request requires a code review before merge critical Modifications to critical changes large large pull request run-build Label that controls when build should be executed waiting-review PR waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add extends system to Engine
1 participant