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

Add GitHub action for auto-requesting code owner reviews. #3471

Merged

Conversation

OhmSpectator
Copy link
Member

This new GitHub Action automatically requests reviews from code owners when a pull request is opened or updated. It fetches the necessary number of commits related to the PR and identifies the appropriate code owners based on the changed files. This is particularly useful as most of the code owners do not have write access to the repository, and thus are not automatically assigned by GitHub.

@OhmSpectator
Copy link
Member Author

I am not very familiar with GH Actions and find it challenging to test. I would appreciate reviews from those with more experience. It would also be helpful if you could test it yourself. Or just use it as an inspiration for a proper solution.

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (6e22b47) 20.29% compared to head (b60ef7c) 20.29%.
Report is 5 commits behind head on master.

❗ Current head b60ef7c differs from pull request most recent head 7b14d83. Consider uploading reports for the commit 7b14d83 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3471   +/-   ##
=======================================
  Coverage   20.29%   20.29%           
=======================================
  Files         198      198           
  Lines       45268    45268           
=======================================
+ Hits         9188     9189    +1     
+ Misses      35396    35395    -1     
  Partials      684      684           

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@OhmSpectator OhmSpectator force-pushed the feature/auto-request-codeowners-review branch from 082eb8e to dc36222 Compare September 27, 2023 19:19
@OhmSpectator
Copy link
Member Author

Fixed the Yetus checks.

@rouming
Copy link
Contributor

rouming commented Sep 28, 2023

I was thinking this is the default behavior of the GitHub, when codewners file is filled in. What's new in the behavior?

@OhmSpectator
Copy link
Member Author

I was thinking this is the default behavior of the GitHub, when codewners file is filled in. What's new in the behavior?

@rouming , it handles the code owners without write permissions. I've mentioned it in the commit message

reviewers_cleaned=${reviewers//@/}
reviewers_comma_separated=$(echo "$reviewers_cleaned" | tr ' ' ',')
echo "Requesting review from: $reviewers_comma_separated"
#echo gh pr edit ${{ github.event.pull_request.number }} --add-reviewer $reviewers_comma_separated
Copy link
Member

Choose a reason for hiding this comment

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

commented code, is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooops, nope. That's how I tested it. Will fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

FWIW way I test GHA is i create fork and enable workflows there, for small actions it'll do :)

@OhmSpectator OhmSpectator force-pushed the feature/auto-request-codeowners-review branch from dc36222 to b60ef7c Compare September 28, 2023 08:25
@OhmSpectator
Copy link
Member Author

FYI @europaul

@europaul
Copy link
Contributor

@OhmSpectator you can use https://github.com/nektos/act to test the GH action. I'm not a big fan of it, because it usually fails on not having access to the right secrets, but here you can use your own GitHub tocken, so I think it should work fine

@OhmSpectator
Copy link
Member Author

@OhmSpectator you can use https://github.com/nektos/act to test the GH action. I'm not a big fan of it, because it usually fails on not having access to the right secrets, but here you can use your own GitHub tocken, so I think it should work fine

Thanks! I'll take a look!

Copy link
Member

@uncleDecart uncleDecart left a comment

Choose a reason for hiding this comment

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

LGTM, as long as @OhmSpectator tested it either way and it worked :)

@OhmSpectator
Copy link
Member Author

OhmSpectator commented Sep 28, 2023

LGTM, as long as @OhmSpectator tested it either way and it worked :)

Youth and rage! Be a rebel! Merge into master without tests!

Just kidding... I will try the approach proposed by @europaul later when I have time.

@dautovri dautovri marked this pull request as ready for review September 28, 2023 13:58
…ews.

This new GitHub Action automatically requests reviews from code owners when a
pull request is opened or updated. It fetches the necessary number of commits
related to the PR and identifies the appropriate code owners based on the
changed files. This is particularly useful as most of the code owners do not
have write access to the repository, and thus are not automatically assigned by
GitHub.

Signed-off-by: Nikolay Martyanov <nikolay@zededa.com>
@OhmSpectator OhmSpectator force-pushed the feature/auto-request-codeowners-review branch from b60ef7c to 7b14d83 Compare September 28, 2023 16:38
@OhmSpectator
Copy link
Member Author

I've tested it with the act tool and a handcrafted pull request event.
It kind of works, but who knows what a real PR event looks like during the action run...

@OhmSpectator
Copy link
Member Author

I suggest we merge it and see how it works with our real PRs. Since it does not touch any dangerous functionality, we can afford to test it under real conditions.

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

@europaul
Copy link
Contributor

I suggest we merge it and see how it works with our real PRs. Since it does not touch any dangerous functionality, we can afford to test it under real conditions.

I agree 👍

@rouming rouming merged commit 9862c3b into lf-edge:master Sep 29, 2023
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.

6 participants