Skip to content

Commit 0760c8b

Browse files
authored
[ci] add logging to docs_pr_nudge.yaml (#17466)
1 parent 66bf91b commit 0760c8b

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.github/workflows/docs_pr_nudge.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,28 @@ jobs:
8888
`draft:false`
8989
].join(' ');
9090
const { data: { items: docsPRs } } = await github.rest.search.issuesAndPullRequests({ q, per_page: 100 });
91-
91+
console.log(`Found ${docsPRs.length} documentation PR(s)`);
92+
9293
// 2) fetch primary-docs-reviewers
9394
const members = await github.paginate(
9495
github.rest.teams.listMembersInOrg,
9596
{ org: owner, team_slug: 'primary-docs-reviewers', per_page: 100 }
9697
);
9798
const reviewerLogins = members.map(u => u.login);
98-
99+
console.log(`Loaded ${reviewerLogins.length} reviewer(s) from team`);
100+
99101
for (const prItem of docsPRs) {
100102
const prNum = prItem.number;
103+
console.log(`\n→ Processing PR #${prNum}`);
101104
const pr = (await github.rest.pulls.get({ owner, repo, pull_number: prNum })).data;
102-
105+
103106
// assign reviewer if none assigned
104107
if (!pr.assignees.some(a => reviewerLogins.includes(a.login))) {
105108
const pick = reviewerLogins[Math.floor(Math.random() * reviewerLogins.length)];
106109
await github.rest.issues.addAssignees({
107110
owner, repo, issue_number: prNum, assignees: [pick]
108111
});
112+
console.log(`Assigned reviewer @${pick} to PR #${prNum}`);
109113
}
110114

111115
// collect all events
@@ -143,34 +147,36 @@ jobs:
143147
const lastNudgeTime = nudgeTimes.length ? new Date(Math.max(...nudgeTimes)) : new Date(0);
144148

145149
// RULE 1: nudge reviewers
146-
const msSinceAuthor = businessMsBetween(lastAuthorActivity, now);
147-
const hoursSinceAuthor= Math.floor(msSinceAuthor / 3600e3);
148-
const msSinceLastRevNudge = businessMsBetween(lastNudgeTime, now);
150+
const msSinceAuthor = businessMsBetween(lastAuthorActivity, now);
151+
const hoursSinceAuthor = Math.floor(msSinceAuthor / 3600e3);
152+
const msSinceLastRevNudge= businessMsBetween(lastNudgeTime, now);
149153

150154
if (
151155
lastAuthorActivity > lastReviewerActivity &&
152156
msSinceAuthor > authorThresholdH * 3600e3 &&
153157
msSinceLastRevNudge > reviewerCooldownH * 3600e3
154158
) {
155-
await github.rest.issues.createComment({
159+
const { data: comment } = await github.rest.issues.createComment({
156160
owner, repo, issue_number: prNum,
157-
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}`
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}`
158162
});
163+
console.log(`Comment posted on PR #${prNum}: ${comment.html_url}`);
159164
continue;
160165
}
161166

162167
// RULE 2: nudge author
163-
const daysSinceReviewer = businessDaysBetween(lastReviewerActivity, now);
168+
const daysSinceReviewer = businessDaysBetween(lastReviewerActivity, now);
164169
const daysSinceLastAuthNudge = businessDaysBetween(lastNudgeTime, now);
165170

166171
if (
167172
lastReviewerActivity > lastAuthorActivity &&
168173
daysSinceReviewer > reviewerThresholdD &&
169174
daysSinceLastAuthNudge > authorCooldownD
170175
) {
171-
await github.rest.issues.createComment({
176+
const { data: comment } = await github.rest.issues.createComment({
172177
owner, repo, issue_number: prNum,
173-
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}`
178+
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}`
174179
});
180+
console.log(`Comment posted on PR #${prNum}: ${comment.html_url}`);
175181
}
176182
}

0 commit comments

Comments
 (0)