-
Notifications
You must be signed in to change notification settings - Fork 213
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 codeowners pre-commit check #3570
Conversation
…t uses the codeowners-validator package. Adding .pre-commit-config.yaml. �
hi @dhruvkb, could please give me some feedback here I was not able to add any label to this pr? Is there anything that you might me waiting from my side? |
@gmottajr the labels are automatically added but since you did not follow the PR template, the labeller could not work. I've manually applied them now, so that should be resolved 👍. We're a little short-staffed because of the holidays so reviews on the PR might be a little slow, but if you want, you are welcome to pick another issue to work on while we review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read through the requirements for the mszostok/codeowners-validator
repo and it seems like the image needs GitHub credentials to work properly. Since that is not something every contributor will have access to, the better approach will be to use the package as the official GitHub Action workflow: https://github.com/mszostok/codeowners-validator/blob/main/docs/gh-action.md
Hi @dhruvkb, I would say I did not fully get what you said about the mszostok/codeowners-validator needing GitHub credentials to work properly. You can check both files, the .pre-commit-config.yaml and also codeowners-validator.sh, there is no reference for the use of credentials. And It seems had worked for me when I performed the git commit. What I'm trying to say is, do you see any chance, when I started com commit this change, the validator would have not worked properly? Would I be able to commit and push my changes if it had not? |
I went back, took a look at the codeowner validator link you just gave me and something is not really making sense for me 🤔. Please @dhruvkb, I need you clarifying for me, anyway, no matter what I'm ready to adjust, and depending on the clarification you are going to give me, I may either continue with your current Docker-based pre-commit setup or switch to implementing the GitHub Action, as per your last comment. Do you know what I mean? |
Sorry for taking so long to respond, I will need to check the @gmottajr I don't want to block you from contributing so feel free to pick up another issue and work on it in the meantime. Thanks for contributing this PR, we will try to review it asap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a comment explaining the required changes. We can bypass the concern about the access token entirely, I think. @dhruvkb, can you give a 👍 or 👎 on whether you are okay with leaving out the "owners" check (which is the one that causes the access token issue)?
Please make the changes I've requested to move the hook into the existing repo: local
group, and to change it to use the pre-built image, allowing us to remove the new dockerfile and the shell script.
Thanks for the contribution!
.pre-commit-config.yaml
Outdated
- repo: local | ||
hooks: | ||
- id: codeowners-validator | ||
name: CODEOWNERS Validator | ||
entry: ./codeowners-validator.sh | ||
language: script | ||
files: ^CODEOWNERS$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add this to the existing group of repo: local
hooks.
Additionally, we don't need to use a shell script and a custom docker file to build from. We can just use the image from the project itself: https://github.com/mszostok/codeowners-validator/pkgs/container/codeowners-validator
For that we can use the docker_image
pre-commit language:
- id: codeowners-validator
name: CODEOWNERS validator
language: docker_image
pass_filenames: false
files: CODEOWNERS$
entry: >
-e REPOSITORY_PATH="."
-e CHECKS="files,duppatterns,syntax"
ghcr.io/mszostok/codeowners-validator:v0.7.4
We can leave out the "owners" check. I don't think it's much of a concern, and the original issue is only trying to fix the issue where files move around and are no longer included in the codeowners. If we want to include it, that's fine, and it should work because the GITHUB_ACCESS_TOKEN
is not required, and all our codeowner teams are public. It would only cause an issue if someone hit the rate limit locally. In CI we can use it from the environment variable like we do other things... but I really don't think the owners
check is a real concern for us and we can ignore the access token issue altogether.
My only outstanding question is whether we should enable the two experimental checks, notowned, which ensures there are no "unowned" files, and "avoid-shadowing", which helps make the codeowners file easier to reason about. I don't think they're necessary for this PR though. Getting the basic checks in would be better than delaying this to decide about the experimental ones.
Based on the low urgency of this PR, the following reviewers are being gently reminded to review this PR: @krysal Excluding weekend1 days, this PR was ready for review 10 day(s) ago. PRs labelled with low urgency are expected to be reviewed within 5 weekday(s)2. @gmottajr, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes
|
@gmottajr, I'm drafting this until we get confirmation that you read Sara's comments. |
…ing group of repo: local hooks. - id: codeowners-validator name: CODEOWNERS validator language: docker_image pass_filenames: false files: CODEOWNERS$ entry: > -e REPOSITORY_PATH='.' -e CHECKS='files,duppatterns,syntax' ghcr.io/mszostok/codeowners-validator:v0.7.4'
…ript and a custom docker file to build from. We can just use the image from the project itself: https://github.com/mszostok/codeowners-validator/pkgs/container/codeowners-validator
Hi @sarayourfriend, I do appreciate you assistance over this matter. |
Great, thanks @gmottajr. It looks like there are some fixes we can apply to the CODEOWNERS file 🎉 Here's the output I get locally, which matches that of the CI job:
To fix these, I think the best thing to do would be to remove the explicit files assigned to I tried using the @dhruvkb What do you think? Should we just use a wildcard at the end to catch everything that isn't explicitly assigned to one of the three sub-groups or should we require explicit assignments of all files to one of the groups and add a second So to wrap this up @gmottajr please do the following:
|
… that the lines referencing .flake8 and .isort.cfg in the CODEOWNERS file do not match any files in the repositor.
I have completed and pushed all change requests from @sarayourfriend. This PR is ready for another round of review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me now, thanks @gmottajr. I left a comment with one change and immediately committed it via the GitHub UI, it's just a small change to make sure this runs in the correct cases (I had this wrong in my example code I shared earlier).
Thanks very much for your effort on this contribution 🙏
Just double checking guys, is there anything you might be expecting from my side to be done for this change? @sarayourfriend , @dhruvkb ? May I have a feedback about what is going to come next? I mean, is it good to be merged? |
It looks great, we're just waiting for a second maintainer to review the change. A lot of the core maintainers are on holiday or sick, so there's been a delay in getting things reviewed. @krysal Do you think you'd be able to review this PR soon? |
.github/CODEOWNERS
Outdated
justfile @WordPress/openverse-maintainers | ||
LICENSE @WordPress/openverse-maintainers | ||
README.md @WordPress/openverse-maintainers | ||
* @WordPress/openverse-maintainers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to avoid using this *
all pattern because together with the previous lines it will make require reviews for more people than intended. Please leave the specific lines for the rest of files and folders associated with the @WordPress/openverse-maintainers
group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put the all at the top, would the more specific patterns not over-ride them? Or does it just combine them?
If that is the case, then it would indeed be good to add the notowned
check so we can check that all files are owned, but it adds a lot of complexity to this check because of the reasons I mentioned in my other comments.
entry: > | ||
-e REPOSITORY_PATH="." | ||
-e CHECKS="files,duppatterns,syntax" | ||
ghcr.io/mszostok/codeowners-validator:v0.7.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to include the checks for notowned
and avoid-shadowing
once they pass the experimental phase. Also, the description of the latter suggest than the *
pattern may work as we want if it's specified before the more specific line but I haven't confirmed it 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notowned
check requires the branch to not have any uncommited changes, and so cannot run in our normal pre-commit
stage. It's flaky to run it in pre-push
as well because it will still complain if there are uncommitted changes (like you have something you would have otherwise stashed).
It's a good check but not currently easily usable. We'd need to add a separate step for it altogether, probably just in CI. I couldn't find an easy way to do that in pre-commit other than adding it with the manual
stage and then adding it to the CI lint job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for enumerating the quirks of the notowned
check. I assumed there would be some complications, but nothing so disrupting 🤯 Anyway, my comment here was just a desire (though at first, I thought it was the whole reason to add it to pre-commit); I wasn't requesting changes for this to be clear.
…jr/openverse into fix/posix-path-separators
…ern because together with the previous lines it will make require reviews for more people than intended. Modifying by leaving the specific lines for the rest of files and folders associated with the @WordPress/openverse-maintainers group.
…ern because together with the previous lines it will make require reviews for more people than intended. Modifying by leaving the specific lines for the rest of files and folders associated with the @WordPress/openverse-maintainers group.
Hello guys, I hope you all are having a marvelous day! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some folders and files and sorted the entries by file type and name. This looks great, thank you @gmottajr!
Hey guys (@dhruvkb , @krysal , @sarayourfriend), |
Fixes
Related to #3554 by @dhruvkb
Description
Integrating codeowners-validator into openverse lint hooks (managed by pre-commit in the .pre-commit-config.yaml file). In order they can use the Docker approach codeowners-validator.