-
-
Notifications
You must be signed in to change notification settings - Fork 781
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
Verify that PR creator is a member of the website-write team #6971
Verify that PR creator is a member of the website-write team #6971
Conversation
Fix Conflicts
…verify-pr-author-3906 Syncing with gh-pages
…verify-pr-author-3906 Re-sync with upstream repository
…verify-pr-creator-3906 Sync with upstream
Want to review this pull request? Take a look at this documentation for a step by step guide! From your project repository, check out a new branch and test the changes.
|
availability: |
Availability: Weekdays 5PM - 9PM |
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.
Hey @ajb176 Great job with this- I tested in my repo with both a my name and a non-hfla name. The PR authored by the non-member was closed and the message was posted on the issue. So everything works well.
I have some comments:
- I think that I could see this both ways, but here is the question: did you consider adding this as another job in the
pull-request-trigger.yml
workflow? It seems this job could belong there, but the counter-argument is thatpr-instructions.yml
is independent so why not this one? - Regarding the job itself, there are other times that we need to check team membership and I believe that this should be pulled into a javascript file in the utils folder,
check-team-membership.js
or something. Then we can reuse this module in other workflows. - Assuming that you do create the js file, owner could be defined in terms of
context.repo.owner
and repo in terms ofcontext.repo.repo
- minor thing, but notice you are using the earlier version of the API on line 19 with
await github.rest.teams.getMembershipForUserInOrg
instead of the current version similar to lines 27 and 33., e.g.await github.request('GET /orgs/{org}/teams/{team_slug}/memberships/{username}
- (FYI we might(???) need to convert the API over to GraphQL in several months. But not worrying about that right now...)
Again, everything is looking good and thanks for working on this!
Hey @t-will-gillis, thanks for the feedback.
Do you mean the entire job, or just get membership API call? I'm not sure if I see much re-usability in the script here, beyond discretizing the API calls themselves which wouldn't make much sense. Can you expand on this a little? |
Hey @ajb176
|
|
It was yes, but that's because I edited the verify-pr.js file to add a random string in place of prAuthor, so it was the expected result. In my testing the action's worked as expected. And in my tests before writing the PR I don't recall ever getting those error messages, I was getting a 403 error when the permissions weren't configured properly. I just googled that error message and it seems like that happens when the admin boxes aren't checked. Have you tried creating a new secret with the same permissions and trying that? If that doesn't work, how did you set up the github actions bot in your repository? That seems like the major difference, so I can try configuring it and seeing if somehow my handle posting/closing vs the actions bot is the cause of the different results. But that doesn't make too much sense given the bot has had no problem closing/commenting when the token wasn't supplied. |
Hey @ajb176
I have been experimenting in my repo and I continue having essentially the same results as I have been. I think that your observation about your handle posting/closing vs. the actions bot doing it is significant.
|
I've done a lot of testing with different permissions, and the only way the action breaks is if I uncheck the topmost repo (full control of private repositories). If I uncheck public_repo I get a 403 admin rights error, if I check everything individually but not the top repo box, I get a 404 error from the membership API call. It works for me without the admin boxes checked. I don't seem to need anything except repo access, the action works in my origin repo even without admin:org hook or admin:write. Even if it's not my handle obtained dynamically from the PR, if I hardcode another website-write member's username when calling check-membership the PR becomes verified, if I hardcode a non team member it gets a 404 and closes the PR.
When you first tested the PR with everything in the yml file, it was working for you, wasn't it? Could you try creating a new branch, pulling from pr-creator-3906 again, creating a token with only repo permissions, and copy pasting that secret to the repo? I'm just not able to replicate the error unless I mess with the token permissions. |
I did what you suggested above and this appears to work for both cases. I don't completely understand why the workflow only runs when the token has fewer permissions, but good call regardless. |
…verify-pr-creator-3906 Syncing with upstream
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.
Hi @ajb176 I have tested this again and everything appears to be working correctly. I am ready to approve and merge this, and have a couple final requests:
- if you would, please replace the hard-coded variables with context variables (ie.
context.repo.owner
, etc. (and of course addcontext
to params inisMemberOfTeam()
) - I think that a negative
console.log()
statement inverify-pr.js
(complement to the positive statement on line 10) would be helpful for reviewing logs
I know this has been a very long process, but thank you for working on this.
Yeah, I can add a log statement I mentioned this earlier, but I don't see any context.repo object. If I saw one I would've used it so testers wouldn't have to manually add their name. There's context.repository.owner whose value is just [Object] in this context and context.repository.full_name which is a string |
The variables for closing and commenting are now taken from the context, seems like it's working. That was my mistake, I would've done it earlier but I had to manually print some objects to see their values, in the logs it just showed As for checking team membership, I think it's better to keep that 'hackforla' hard-coded if the goal is to be able to use it elsewhere. I'm not sure the same context variables will be available in different workflows. |
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.
Hi @ajb176 Great- thanks for making the final changes!
Fixes #3906
What changes did you make?
Why did you make the changes (we will use this info to test)?
Instructions for Reviewers: