-
Notifications
You must be signed in to change notification settings - Fork 2
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: update workflow to not close unreviewed stale PRs #3
Changes from 1 commit
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 |
---|---|---|
|
@@ -154,8 +154,10 @@ export class StalePrFinder { | |
console.log(' Stale since: ', stale.since.toISOString()); | ||
console.log(' Warnings: ', Object.fromEntries(warnings)); // Prints nicer | ||
|
||
const memberReviewed = await this.memberReviewed(pull.number); | ||
|
||
const warning = warnings.get('STALE PR'); | ||
if (!warning || warning < stale.since) { | ||
if (!warning || warning < stale.since || !memberReviewed) { | ||
// Beginning a new staleness period | ||
action = 'warn'; | ||
} else if (warnings && this.outOfGracePeriod(warning)) { | ||
|
@@ -340,6 +342,28 @@ export class StalePrFinder { | |
|
||
return ret; | ||
} | ||
|
||
/** | ||
* Returns true if the PR has been reviewed or commented on by a core member. | ||
*/ | ||
private async memberReviewed(pull_number: number): Promise<Boolean> { | ||
const reviews = (await this.client.paginate(this.client.rest.pulls.listReviews, { ...this.repo, pull_number })); | ||
|
||
const comments = await this.client.paginate(this.client.rest.issues.listComments, { | ||
...this.repo, | ||
issue_number: pull_number, | ||
}); | ||
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. Will all reviews leave comments? If so do we need to look through the reviews? 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. Nit: these lines are formatted differently. 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. Ya I wasn't 100% sure if |
||
|
||
// Reviews by team members | ||
// Filtering out instances where submitted_at is empty | ||
const memberReviews = reviews.filter(r => r.author_association === 'MEMBER').filter(r => r.submitted_at); | ||
|
||
// Comments by team members | ||
// Filtering out instances where submitted_at is empty | ||
const memberComments = comments.filter(r => r.author_association === 'MEMBER').filter(r => r.submitted_at); | ||
|
||
return memberComments.length > 0 || memberReviews.length > 0; | ||
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. If we are looking for either reviews or comments, can we do them one at a time. Why do we need to request all of the reviews and all of the comments all at once? Say we find a comment from a core team member, then we do not need to make a request for the reviews. 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. Good point, I'll change this to only check reviews if after confirming there are no core member comments. |
||
} | ||
} | ||
|
||
interface ReviewState { | ||
|
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.
Is this correct?
This is saying:
THEN we should add a warning and start the timer for closing.
For fresh PRs, the 3rd condition will be automatically true, because at the start nobody will have looked at it yet.
So this would add a staleness warning immediately on every new PR!
I think what you probably want is to have
memberReviewed
factor into the value ofstale
: a PR should not be considered stale if it hasn't been reviewed yet.Have a look at line 115, and think about how your change would interact with the conditions that are laid out there -- then make the changes over there.
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.
Oh good catch, I was thinking this would only be run if the PR is already stale but the
stale
variable includes any build failures and merge conflicts as well. I'll update it with your suggestion.