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: ping reviewers based on which files were changed #265

Merged
merged 1 commit into from
Aug 7, 2020

Conversation

mmarchini
Copy link
Contributor

@mmarchini mmarchini commented Jul 1, 2020

Using a custom OWNERS file, github-bot will ping the appropriate teams
based on which files were changed in a Pull Request. This feature is
inteded to work around GitHub's limitation which prevents teams without
explicit write access from being added as reviewers (thus preventing the
vast majority of teams in the org from being used on GitHub's CODEOWNERS
feature).

The OWNERS file is a yaml file (to simplify parsing) composed of
key-value paris. The key is always a string and represents a glob of the
changed files. The value is always an array of strings, and each string
is a team to be pinged.

Ref: nodejs/node#33984
Ref: nodejs/node#34150

@mmarchini
Copy link
Contributor Author

Still need to add tests, but I'm looking for feedback on the implementation (using a YAML file, fetching from core, etc.). This has been discussed already in nodejs/node#33895 and nodejs/node#33984 (and a couple old pull requests where CODEOWNERS were first introduced but then removed because of the GitHub limitations mentioned above).

mmarchini added a commit to mmarchini/node that referenced this pull request Jul 1, 2020
Introduces a custom OWNERS file, which is intended to be handled by
`github-bot` as a way to work around GitHub CODEOWNERS limitation which
prevents teams without explicit write access from being added as
reviewers.

Ref: nodejs#33984
Ref: nodejs/github-bot#265
@phillipj
Copy link
Member

phillipj commented Jul 1, 2020

Conceptually looks good to me 👍

The fact that the definition lives inside the node repo is surely a step in a more sustainable direction going forward.

I'm not opinionated about the format and naming of OWNERS | CODEOWNERS, whatever makes most sense for the core maintainers.

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

lib/node-owners.js Outdated Show resolved Hide resolved
lib/node-owners.js Outdated Show resolved Hide resolved
lib/node-repo.js Outdated
debug(`Fetching OWNERS on ${url}`)
request(url, (err, res, body) => {
if (err || !res || res.statusCode >= 400) {
return options.logger.error(err, 'Error retrieving OWNERS')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, also log res (or at least res.statusCode) in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but can be done in a follow up PR (so we don't block the PR)

@mmarchini
Copy link
Contributor Author

Previous version was a merge-conflict show, it was easier for me to go revert the changes and copy them manually. I added all new functions after current function to avoid any future conflicts if this doesn't land soon.

Main changes:

  • Rewrote everything in async/await fashion since we started to use it
  • Broke down all steps into separate function to make testing easier
  • The format is not YAML anymore, we're using the same format GitHub does
    • No need to create a new file on nodejs/node amymore, as soon as we land this the bot will start ping folks :D
  • Added tests
    • I used nock for all tests because using sinon to stub github API calls will supress deprecation warnings that are helpful when bumping major versions of the github rest API package

lib/node-repo.js Outdated Show resolved Hide resolved
lib/node-repo.js Outdated Show resolved Hide resolved
lib/node-repo.js Outdated Show resolved Hide resolved
lib/node-repo.js Outdated Show resolved Hide resolved
lib/node-repo.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubberstamp lgtm, let's try this.

@mmarchini
Copy link
Contributor Author

mmarchini commented Aug 4, 2020

@phillipj do you want to take another look before we land this? Was hoping to land it this week (but if you want to take another look and don't have time this week we can postpone it)

Using .github/CODEOWNERS, `github-bot` will ping the appropriate teams
based on which files were changed in a Pull Request. This feature is
inteded to work around GitHub's limitation which prevents teams without
explicit write access from being added as reviewers (thus preventing the
vast majority of teams in the org from being used on GitHub's CODEOWNERS
feature).

Ref: nodejs/node#33984
@mmarchini mmarchini merged commit e64662f into nodejs:master Aug 7, 2020
@mmarchini mmarchini deleted the owners branch August 7, 2020 19:07
@mmarchini
Copy link
Contributor Author

@phillipj feel free to ping me if you have any comments, suggestions or concerns on this PR. I can send a patch addressing those or we can revert if necessary.

@phillipj
Copy link
Member

phillipj commented Aug 7, 2020 via email

mmarchini added a commit to mmarchini/node that referenced this pull request Aug 7, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: nodejs#33984
Copy link
Member

@phillipj phillipj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Belated LGTM, nice one 💯

mmarchini added a commit to nodejs/node that referenced this pull request Aug 9, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: #33984

PR-URL: #34670
Fixes: #33984
Refs: nodejs/github-bot#265
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
codebytere pushed a commit to nodejs/node that referenced this pull request Aug 10, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: #33984

PR-URL: #34670
Fixes: #33984
Refs: nodejs/github-bot#265
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
codebytere pushed a commit to nodejs/node that referenced this pull request Aug 11, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: #33984

PR-URL: #34670
Fixes: #33984
Refs: nodejs/github-bot#265
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
addaleax pushed a commit to nodejs/node that referenced this pull request Sep 22, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: #33984

PR-URL: #34670
Fixes: #33984
Refs: nodejs/github-bot#265
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
addaleax pushed a commit to nodejs/node that referenced this pull request Sep 22, 2020
A recent feature was added to github-bot to ping codeowners defined on
the CODEOWNERS file even if the team doesn't have write permission to
the repository. That means we can enable codeowners everywhere in the
repository.

Ref: nodejs/github-bot#265
Fix: #33984

PR-URL: #34670
Fixes: #33984
Refs: nodejs/github-bot#265
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants