parabol icon indicating copy to clipboard operation
parabol copied to clipboard

Auto-assign reviewers

Open Dschoordsch opened this issue 2 years ago • 4 comments

We want to assign reviewers automatically based on a couple of criteria. There are 2 tensions we like to solve:

  1. a lot of external contributors at the moment who do not get reviewers assigned for a long time until someone stumbles across the PR
  2. data representatives are not always kept in the loop when we make database changes

We want to have at least 3 groups:

  • reviewers
  • maintainers
  • data-representatives

We want to assign reviewers:

  • **/migrations/** touched -> add data-representative
  • author not in any of the reviewer groups -> add reviewer
  • (optional) some analytics specific file (which ones exactly?) -> add data-representative

Some options:

  • draft -> do not assign
  • title contains "WIP" -> do not assign

The following GitHub action looks like it would do the trick: https://github.com/marketplace/actions/auto-request-review

Dschoordsch avatar Jul 29 '22 09:07 Dschoordsch

Notify @mwermuth once it's deployed.

Dschoordsch avatar Aug 22 '22 17:08 Dschoordsch

@mwermuth I added automatically adding reviewers to external PRs and data to migrations. Let me know if you expected something else be done as well.

Dschoordsch avatar Sep 13 '22 18:09 Dschoordsch

Hi @Dschoordsch the Auto Request Review GitHub workflow looks like it's still a failure for external contributors:

Matched no reviewers
Falling back to the default reviewers
Randomly picking reviewers if the number of reviewers is set
Requesting review to jmtaber[12](https://github.com/ParabolInc/parabol/actions/runs/3077044304/jobs/4971620538#step:2:13)9
Error: HttpError: Resource not accessible by integration

I have researched this HttpError: Resource not accessible by integration error and this happens as soon as the person creating the PR does not have permission to the repository. looking into this issue, there are two interesting potential solutions mentioned:

  1. As mentioned in the GitHub documentation, all permissions that you don't explicitly set on a job will be set to none:

If you specify the access for any of these scopes, all of those that are not specified are set to none.

Setting write permissions to the pull request as follows fixed the problem for us completely:

jobs:
  job_name:
    name: Job Name
    runs-on: ubuntu-latest

    permissions:
      pull-requests: write
  1. developed a Github bot app which has more permission and flexibility [^1]:

e.g. https://github.com/kaxil/boring-cyborg created by apache/airflow

🤖 A Github bot to automatically label PRs, issues and perform all the boring operations that you don't want to do.

The bot is actually very interesting and includes a lot of the work we wanted to do before, such as automatically adding labels, checking PR titles, etc. and also: automatically welcoming new contributors to the project and check if a branch is up to date with the master

For the first one of setting write permissions, let's give it a quick try. For what the second bot contains, WDYT?

[^1]: probot/probot: 🤖 A framework for building GitHub Apps to automate and improve your workflow

JimmyLv avatar Sep 19 '22 04:09 JimmyLv

hmm, after setting write permissions to the pull request, it's still failed to assign a reviewer for an external contributor https://github.com/ParabolInc/parabol/actions/runs/3103116036/jobs/5026094541

JimmyLv avatar Sep 22 '22 05:09 JimmyLv

Works now as intended, the bot assigns reviewers to external contributors: https://github.com/ParabolInc/parabol/pull/7357 but not internal ones: https://github.com/ParabolInc/parabol/pull/7356 except when migrations are touched: https://github.com/ParabolInc/parabol/pull/7352

Dschoordsch avatar Oct 28 '22 11:10 Dschoordsch