-
Notifications
You must be signed in to change notification settings - Fork 4k
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
chore: add PR to R2 list only if there are 2 approvals #33283
Changes from all commits
0784c2e
dfc08a0
68b03d8
e9e870f
e16c0fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,10 @@ module.exports = async ({ github }) => { | |
console.log(`Total PRs fetched: ${allPRs.length}`); | ||
|
||
// Get project fields | ||
const projectFields = await fetchProjectFields({ | ||
github, | ||
const projectFields = await fetchProjectFields({ | ||
github, | ||
org: PROJECT_CONFIG.org, | ||
number: PROJECT_CONFIG.projectNumber | ||
number: PROJECT_CONFIG.projectNumber | ||
}); | ||
|
||
const priorityField = projectFields.organization.projectV2.fields.nodes.find( | ||
|
@@ -65,27 +65,27 @@ module.exports = async ({ github }) => { | |
|
||
for (const pr of allPRs) { | ||
try { | ||
|
||
console.log(`Processing PR #${pr.number}....`); | ||
|
||
// Check PR status | ||
const isApproved = pr.reviews.nodes.some( | ||
const approvals = pr.reviews.nodes.filter( | ||
(review) => review.state === "APPROVED" | ||
); | ||
|
||
// Skip if PR is not approved | ||
if (!isApproved) { | ||
if (approvals.length < 2) { | ||
console.log(`Observed approval count: ${approvals.length}. Skipping as it is less than 2...`); | ||
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking should we consider checking approval based on a maintainer list instead of just counting approvals? This would prevent PRs from being added to R2 when they have multiple community approvals but no maintainer approval with failing checks. We could use an approach similar to mergify configuration where:
For approved PR's from community and needs maintainer review with failing status check will be added to R3 list if I'm not wrong. Let me know if it makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thought about the same but as I went through a few PRs (very few as I was manually going through them), counting 2 approvals should cover most cases. Because of that, I didn't want to make this too complicated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking. Should be good then if most of the PRs falls under this behaviour. |
||
continue; | ||
} | ||
|
||
// Check status of checks | ||
const checksState = pr.commits.nodes[0]?.commit.statusCheckRollup?.state; | ||
const checksNotPassing = checksState !== "SUCCESS"; | ||
|
||
// Skip if PR checks is not passing | ||
if (!checksNotPassing) { | ||
console.log(`PR checks are failing. Skipping...`); | ||
continue; | ||
} | ||
|
||
console.log(`Processing PR #${pr.number} for ${PRIORITIES.R2} priority consideration`); | ||
|
||
// Get all projects the PR added to | ||
const result = await fetchProjectItem({ | ||
|
@@ -96,17 +96,17 @@ module.exports = async ({ github }) => { | |
// Filter our specific project | ||
const projectItem = result.node.projectItems.nodes | ||
.find(item => item.project.id === PROJECT_CONFIG.projectId); | ||
|
||
if (projectItem) { | ||
// PR already in project | ||
const currentPriority = projectItem.fieldValues.nodes | ||
.find(fv => fv.field?.name === 'Priority')?.name; | ||
|
||
if (currentPriority === PRIORITIES.R2) { | ||
console.log(`PR #${pr.number} already has ${PRIORITIES.R2} priority. Skipping.`); | ||
continue; | ||
} | ||
|
||
// Update priority only, maintain existing status | ||
console.log(`Updating PR #${pr.number} from ${currentPriority} to ${PRIORITIES.R2} priority`); | ||
await updateProjectField({ | ||
|
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.
Should we make it R3 if it only has one approval? Often I think if one community member is reviewing a PR then the others will leave it alone and wait for maintainer