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

Repo Gardening: check if PR owner is a member of the org to determine if they're an OSS Citizen #36860

Merged
merged 5 commits into from
Apr 15, 2024

Conversation

vcanales
Copy link
Contributor

@vcanales vcanales commented Apr 11, 2024

Proposed changes:

In some cases, PR authors within an organization might create a PR from a fork, in which case they will be mislabeled as an OSS Citizen. Here I propose an additional check for the PR Author's membership to the repo's organization.

Example of this occurring: Automattic/themes#7734 — The PR Author is a member of Automattic, but created a PR from a fork.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Testing instructions:

  • Create a repo within the organization, to avoid spamming existing repositories.
  • Add the repo gardening workflow to the new repo.
  • Create a PR from a fork, pointing to that repo.
  • You should not be flagged as an OSS Citizen.

Does this pull request change what data or activity we track or use?

No.

@github-actions github-actions bot added [Action] Repo Gardening Github Action: manage PR and issues in your Open Source project Actions GitHub actions used to automate some of the work around releases and repository management labels Apr 11, 2024
Copy link
Contributor

github-actions bot commented Apr 11, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 11, 2024
@vcanales vcanales force-pushed the try/check-for-org-membership-for-oss-citizen branch from 4fe6b90 to 8fa160c Compare April 11, 2024 20:03
@vcanales vcanales added [Status] Proposal [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Proposal labels Apr 11, 2024
@bindlegirl bindlegirl removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 12, 2024
Comment on lines 18 to 25
// Check if PR author is org member
// https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user
const orgMembershipRequest = await octokit.rest.orgs.checkMembershipForUser( {
org: owner.login,
username: head.user.login,
} );

if ( head.repo.full_name === base.repo.full_name || 204 === orgMembershipRequest.status ) {
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense, that would be a good addition I think.

That said, I wonder if we could save an API call in most scenarios, by keeping the 2 checks separate?

  1. We would start by checking if the PR is from a branch in the same remote, like we do today. If yes we bail, like today.
  2. Then, only when the PR is from a different remote we make the API call you're introducing here to figure out if the PR author is a member of the organization.

I believe it would avoid slowing things down for most of the PRs today.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Applied on 703a0b0

@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Pri] Normal and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Apr 12, 2024
@vcanales vcanales added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Apr 12, 2024
Copy link
Member

@jeherve jeherve left a 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. 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Apr 15, 2024
@vcanales vcanales merged commit be64b86 into trunk Apr 15, 2024
55 checks passed
@vcanales vcanales deleted the try/check-for-org-membership-for-oss-citizen branch April 15, 2024 15:20
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Action] Repo Gardening Github Action: manage PR and issues in your Open Source project Actions GitHub actions used to automate some of the work around releases and repository management [Pri] Normal [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants