Skip to content

Commit 678deca

Browse files
authored
[ci] more logging in docs_pr_nudge.yaml (#17588)
1 parent 8bdc27a commit 678deca

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

.github/workflows/docs_pr_nudge.yaml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
env:
2323
AUTHOR_RESPONSE_THRESHOLD_HOURS: 24 # when to nudge reviewers after author
2424
REVIEWER_RESPONSE_THRESHOLD_DAYS: 7 # when to nudge author after reviewer
25-
REVIEWER_NUDGE_COOLDOWN_HOURS: 24 # min hours between reviewernudges
26-
AUTHOR_NUDGE_COOLDOWN_DAYS: 7 # min days between authornudges
25+
REVIEWER_NUDGE_COOLDOWN_HOURS: 24 # min hours between reviewer-nudges
26+
AUTHOR_NUDGE_COOLDOWN_DAYS: 7 # min days between author-nudges
2727
steps:
2828
- uses: actions/github-script@v7
2929

@@ -48,13 +48,13 @@ jobs:
4848
(month === 5 && date <= 7) ||
4949
(month === 1 && date <= 7)
5050
) {
51-
console.log('Skip run: weekend or first week of May/year');
51+
console.log(`Skip run: weekend or first-week (month=${month}, date=${date}, day=${day})`);
5252
return;
5353
}
5454

5555
const isWeekend = d => d.getUTCDay() === 0 || d.getUTCDay() === 6;
5656

57-
// sum only businesshours between two dates
57+
// sum only business-hours between two dates
5858
function businessMsBetween(start, end) {
5959
let ms = 0;
6060
let cur = new Date(start);
@@ -65,7 +65,7 @@ jobs:
6565
return ms;
6666
}
6767

68-
// count only businessdays between two dates
68+
// count only business-days between two dates
6969
function businessDaysBetween(start, end) {
7070
let days = 0;
7171
let cur = new Date(start);
@@ -79,7 +79,7 @@ jobs:
7979
return days;
8080
}
8181

82-
// 1) search open, nondraft docs PRs
82+
// 1) search open, non-draft docs PRs
8383
const q = [
8484
`repo:${owner}/${repo}`,
8585
`type:pr`,
@@ -158,14 +158,20 @@ jobs:
158158
) {
159159
const { data: comment } = await github.rest.issues.createComment({
160160
owner, repo, issue_number: prNum,
161-
body: `Hey ${assignees.map(a=>`@${a}`).join(', ')}, it has been ${hoursSinceAuthor} businesshours since the author's last update, could you please review? ${BOT_MARKER}`
161+
body: `Hey ${assignees.map(a=>`@${a}`).join(', ')}, it has been ${hoursSinceAuthor} business-hours since the author's last update, could you please review? ${BOT_MARKER}`
162162
});
163163
console.log(`Comment posted on PR #${prNum}: ${comment.html_url}`);
164164
continue;
165+
} else {
166+
const reasons = [];
167+
if (!(lastAuthorActivity > lastReviewerActivity)) reasons.push(`lastAuthor(${lastAuthorActivity.toISOString()})≤lastReviewer(${lastReviewerActivity.toISOString()})`);
168+
if (!(msSinceAuthor > authorThresholdH * 3600e3)) reasons.push(`hoursSinceAuthor=${hoursSinceAuthor}h≤${authorThresholdH}h`);
169+
if (!(msSinceLastRevNudge > reviewerCooldownH * 3600e3)) reasons.push(`hoursSinceLastNudge=${Math.floor(msSinceLastRevNudge/3600e3)}h≤${reviewerCooldownH}h`);
170+
console.log(`Reviewer nudge skipped: ${reasons.join('; ')}`);
165171
}
166172

167173
// RULE 2: nudge author
168-
const daysSinceReviewer = businessDaysBetween(lastReviewerActivity, now);
174+
const daysSinceReviewer = businessDaysBetween(lastReviewerActivity, now);
169175
const daysSinceLastAuthNudge = businessDaysBetween(lastNudgeTime, now);
170176

171177
if (
@@ -175,8 +181,14 @@ jobs:
175181
) {
176182
const { data: comment } = await github.rest.issues.createComment({
177183
owner, repo, issue_number: prNum,
178-
body: `Headsup: it's been ${daysSinceReviewer} businessdays since a reviewer comment. @${author}, any updates? ${assignees.map(a=>`@${a}`).join(' ')}, please check the status with the author. ${BOT_MARKER}`
184+
body: `Heads-up: it's been ${daysSinceReviewer} business-days since a reviewer comment. @${author}, any updates? ${assignees.map(a=>`@${a}`).join(' ')}, please check the status with the author. ${BOT_MARKER}`
179185
});
180186
console.log(`Comment posted on PR #${prNum}: ${comment.html_url}`);
187+
} else {
188+
const reasons = [];
189+
if (!(lastReviewerActivity > lastAuthorActivity)) reasons.push(`lastReviewer(${lastReviewerActivity.toISOString()})≤lastAuthor(${lastAuthorActivity.toISOString()})`);
190+
if (!(daysSinceReviewer > reviewerThresholdD)) reasons.push(`daysSinceReviewer=${daysSinceReviewer}d≤${reviewerThresholdD}d`);
191+
if (!(daysSinceLastAuthNudge > authorCooldownD)) reasons.push(`daysSinceLastAuthNudge=${daysSinceLastAuthNudge}d≤${authorCooldownD}d`);
192+
console.log(`Author nudge skipped: ${reasons.join('; ')}`);
181193
}
182194
}

0 commit comments

Comments
 (0)