Repository navigation
Expand file tree
/
Copy pathshow-issues.js
More file actions
434 lines (382 loc) · 17 KB
/
Copy pathshow-issues.js
File metadata and controls
434 lines (382 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
const fs = require('fs');
const bertyStaff = ['D4ryl00', 'dependabot[bot]', 'dework-integration[bot]',
'gfanton', 'jefft0', 'moul', 'berty-assistant'];
// coreDevs should track https://github.com/orgs/gnolang/teams/tech-staff + lbrown2007
const coreDevs = ['jaekwon', 'tbruyelle', 'moul', 'thehowl', 'aeddi', 'ltzmaxwell', 'alexiscolin', 'gfanton', 'dongwon8247',
'lbrown2007', /* former: */ 'jeronimoalbi', 'ajnavarro'];
const triageReviewers = ['aronpark1007', 'davd-gzl', 'jefft0', 'notJoon', 'omarsy'];
// gnolangMembers overlaps with coreDevs and triageReviewers. Should track https://github.com/orgs/gnolang/people
const gnolangMembers = [
'adr-sk',
'aeddi',
'albttx',
'alexiscolin',
'aronpark1007',
'clockworkgr',
'D4ryl00',
'davd-gzl',
'dongwon8247',
'gfanton',
'giunatale',
'Gno2D2',
'jaekwon',
'jefft0',
'jinoosss',
'julienrbrt',
'junghoon-vans',
'lbrown2007',
'louis14448',
'ltzmaxwell',
'moul',
'moul-bot',
'moul-sudo',
'notJoon',
'omarsy',
'tbruyelle',
'thehowl',
'Villaquiranm',
'WaDadidou',
'wookja-0',
'zxxma'];
function main() {
const headers = ["NEEDS QA ATTENTION", "MORE INFO NEEDED", "HAS DEV FOCUS", "BACKLOG OR DRAFT"]
const repos = ["berty", "weshnet", "weshnet-expo", "weshnet-expo-examples", "go-orbit-db", "go-ipfs-log", "go-ipfs-repo-encrypted", "ui-components",
"gnonative", "gnokey-mobile", "dsocial", "boards2-mobile", "www.berty.tech", "www.wesh.network"];
for (const header of headers) {
let total = 0;
let oldest = new Date();
for (const repo of repos) {
result = showIssues(repo, header);
total += result.total;
if (result.oldest < oldest)
oldest = result.oldest;
}
if (total == 0)
console.log("\n" + header + ":")
console.log("\n Total: " + total);
console.log(" Oldest: " + oldest.toISOString().substring(0, 10));
}
showNextAfterMainnetBeta();
showGnoPRs();
}
/**
* Read the JSON files for the repo and show all the issues for the header.
* @returns An object with total and oldest for the shown issues.
*/
function showIssues(repo, header) {
let showBacklogOrDraft = false;
let showMoreInfoNeeded = false;
let showHasDevFocus = false;
if (header == "BACKLOG OR DRAFT")
showBacklogOrDraft = true;
else if (header == "MORE INFO NEEDED")
showMoreInfoNeeded = true;
else if (header == "HAS DEV FOCUS")
showHasDevFocus = true;
else {
if (header != "NEEDS QA ATTENTION") {
console.log("ERROR: Unrecognised header: " + header);
return;
}
}
const issues = readJsonFile(repo + ".issues.json");
const pulls = readJsonFile(repo + ".pulls.json");
let total = 0;
let now = new Date();
let oldest = now;
let showedHeader = false;
for (const issue of issues) {
const isBacklog = hasLabel(issue, "backlog");
const isPullRequest = (issue.pull_request !== undefined);
const isBug = hasLabel(issue, "bug");
const isFeatureRequest = hasLabel(issue, ":rocket: feature-request");
const isQuestion = hasLabel(issue, "question");
const isApproved = hasLabel(issue, "✅ Approved");
const isVerified = hasLabel(issue, "verified");
const isMoreInfoNeeded = hasLabel(issue, "more info needed");
const url = "https://github.com/" +
(repo == "gnonative" || repo == "gnokey-mobile" ? "gnolang" : (repo == "dsocial" || repo == "boards2-mobile" ? "gnoverse" : "berty")) +
"/" + repo + (isPullRequest ? "/pull/" : "/issues/") + issue.number;
const user = issue.user.login;
const createdAt = new Date(issue.created_at);
const updatedAt = new Date(issue.updated_at);
let daysSinceUpdate = (now - updatedAt) / (1000 * 3600 * 24);
const assignee = (issue.assignee ? issue.assignee.login : null);
let pull = null;
let hasReviewer = false;
let isDraft = false;
if (isPullRequest) {
pull = getPull(pulls, issue.number);
if (pull == null)
// (We don't expect this.)
console.log(" WARNING: Can't find pull request detail: " + url);
else {
hasReviewer = (pull.requested_reviewers.length > 0);
isDraft = pull.draft;
}
}
const isBacklogOrDraft = (isBacklog || isDraft);
const hasDevFocus = (isPullRequest ? hasReviewer : !!assignee);
if (isBacklogOrDraft != showBacklogOrDraft)
continue;
if (!isBacklogOrDraft) {
if (isMoreInfoNeeded != showMoreInfoNeeded)
continue;
if (!isMoreInfoNeeded) {
if (hasDevFocus != showHasDevFocus)
continue;
}
}
let category = " ";
if (isPullRequest)
category = "pull";
else if (isBug)
category = isVerified ? "vbug" : "bug ";
else if (isFeatureRequest)
category = isApproved ? "appf" : "feat";
else if (isQuestion)
category = "ques";
if (category == " " && (hasLabel(issue, "Feature") ||
hasLabel(issue, "chore") ||
hasLabel(issue, "🔬 R&D Study") ||
hasLabel(issue, "Toolkit")))
// Don't show GitHub Project tracking issues.
continue;
++total;
if (!showedHeader) {
console.log("\n" + header + ": " + repo);
showedHeader = true;
}
if (createdAt < oldest)
oldest = createdAt;
// Wait until 21 days pass for a response.
const daysRemaining = (isMoreInfoNeeded ? String(Math.max(0, Math.ceil(21 - daysSinceUpdate))).padStart(2, '0') + "d " : "")
console.log(daysRemaining + category + " " + url + " ".repeat(4 - ("" + issue.number).length) +
(isPullRequest ? " " : " ") + createdAt.toISOString().substring(0, 10) + ", " +
String(Math.ceil(daysSinceUpdate)).padStart(2, ' ') + "d idle, " +
issue.comments + " cmts, " + user + ", " + issue.title);
if (assignee && !bertyStaff.includes(assignee))
if (issue.number != 127) // temporary until resolved
console.log(" WARNING: #" + issue.number + " is assigned to non staff member " + assignee);
if (showBacklogOrDraft) {
if (isBacklogOrDraft && isMoreInfoNeeded)
console.log(" WARNING: #" + issue.number + " has both backlog (or draft) and more-info-needed");
if (isBacklogOrDraft && hasDevFocus && isPullRequest) {
if (isDraft)
console.log(" WARNING: draft PR #" + issue.number + " has a reviewer");
else
console.log(" WARNING: backlog PR #" + issue.number + " has a reviewer");
}
}
if (isVerified && !isBug)
console.log(" WARNING: non-bug #" + issue.number + " has the 'verified' label");
if (isApproved && !isFeatureRequest)
console.log(" WARNING: non-feature request #" + issue.number + " has the 'approved' label");
if (showHasDevFocus && !isPullRequest && issue.assignees.length > 1)
console.log(" WARNING: #" + issue.number + " is assigned to multiple devs: " + issue.assignees.length);
if (isPullRequest && pull.requested_reviewers.length > 1)
console.log(" WARNING: PR #" + issue.number + " has multiple reviewers: " + pull.requested_reviewers.length);
if (isPullRequest && pull.requested_teams.length > 0)
console.log(" WARNING: PR #" + issue.number + " has a team as a reviewer");
if (isPullRequest && isBacklog)
console.log(" WARNING: PR #" + issue.number + " has the 'backlog' label");
if (isPullRequest && isBug)
console.log(" WARNING: PR #" + issue.number + " has the 'bug' label");
if (category == " ")
console.log(" WARNING: issue/PR #" + issue.number + " doesn't have a label for 'bug', 'question', etc.");
}
return { total: total, oldest: oldest}
}
function showNextAfterMainnetBeta() {
const repo = "gno";
console.log("\nNext After Mainnet Beta");
const issues = readJsonFile(repo + ".issues.json");
let total = 0;
let now = new Date();
let messages = [];
for (const issue of issues) {
// Follow https://github.com/gnolang/gno/milestones
if (!(issue.milestone && issue.milestone.html_url == "https://github.com/gnolang/gno/milestone/12"))
continue;
const isPullRequest = (issue.pull_request !== undefined);
const url = "https://github.com/" + "gnolang" + "/" + repo + (isPullRequest ? "/pull/" : "/issues/") + issue.number;
const user = issue.user.login;
const createdAt = new Date(issue.created_at);
const updatedAt = new Date(issue.updated_at);
const daysSinceUpdate = (now - updatedAt) / (1000 * 3600 * 24);
const assignee = (issue.assignee ? issue.assignee.login : null);
let message = String(Math.ceil(daysSinceUpdate)).padStart(3, ' ') + "d idle, " +
url + " ".repeat(4 - ("" + issue.number).length) + (isPullRequest ? " " : " ") +
createdAt.toISOString().substring(0, 10) + ", " +
issue.comments + " cmts, " + user + ", " + issue.title;
if (assignee && !gnolangMembers.includes(assignee))
message += "\n WARNING: #" + issue.number + " is assigned to non-member " + assignee;
messages.push(message);
++total;
}
messages.sort();
for (const message of messages)
console.log(message);
console.log("\n Total: " + total);
}
function showGnoPRs() {
const repo = "gno";
console.log("\n" + repo);
const issues = readJsonFile(repo + ".issues.json");
const pulls = readJsonFile(repo + ".pulls.json");
let total = 0;
let now = new Date();
let oldest = now;
let fetchMessages = "";
for (const issue of issues) {
if ([4886].includes(issue.number)) continue; // Already approved by a former core dev or member of triageReviewers. Ignore until closed/merged.
const isReviewTriagePending = hasLabel(issue, "review/triage-pending");
const isStale = hasLabel(issue, "Stale");
const isPullRequest = (issue.pull_request !== undefined);
if (!isPullRequest)
continue;
const url = "https://github.com/" + "gnolang" + "/" + repo + (isPullRequest ? "/pull/" : "/issues/") + issue.number;
let milestone = " ";
if (issue.milestone) {
// Follow https://github.com/gnolang/gno/milestones
if (issue.milestone.html_url == "https://github.com/gnolang/gno/milestone/14")
milestone = "MS1 ";
else if (issue.milestone.html_url == "https://github.com/gnolang/gno/milestone/12")
milestone = "MS2 ";
else if (issue.milestone.html_url == "https://github.com/gnolang/gno/milestone/13")
milestone = "MS3 ";
}
const user = issue.user.login;
const createdAt = new Date(issue.created_at);
const updatedAt = new Date(issue.updated_at);
let daysSinceUpdate = (now - updatedAt) / (1000 * 3600 * 24);
const message = url + " ".repeat(4 - ("" + issue.number).length) + " " + milestone +
createdAt.toISOString().substring(0, 10) + ", " +
(isStale ? "STALE " : "") + String(Math.ceil(daysSinceUpdate)).padStart(2, ' ') + "d idle, " +
issue.comments + " cmts, " + user + ", " + issue.title;
let isDraft = false;
if (isPullRequest) {
const pull = getPull(pulls, issue.number);
if (pull == null) {
// (We don't expect this.)
console.log(message + "\n WARNING: Can't find pull request detail: " + url);
continue;
}
else {
isDraft = pull.draft;
if (pull.base.ref != "master")
continue;
}
}
if (isDraft) {
if (isReviewTriagePending)
console.log(message + "\n WARNING: #" + issue.number + " is draft but has the 'review/triage-pending' label");
continue;
}
if (coreDevs.includes(user)) {
if (isReviewTriagePending)
console.log(message + "\n WARNING: #" + issue.number + " was created by a core dev but has the 'review/triage-pending' label");
continue;
}
let hasGnoDevPullComment = false;
{
const comments = readJsonFile(repo + ".pull-comments/" + issue.number + ".json");
for (const comment of comments) {
if (coreDevs.includes(comment.user.login)) {
hasGnoDevPullComment = true;
break;
}
}
}
let hasGnoDevPullReview = false;
let hasTriageReviewerApproval = false;
let unrecognizedApprovers = "";
{
const comments = readJsonFile(repo + ".pull-reviews/" + issue.number + ".json");
for (const comment of comments) {
if (coreDevs.includes(comment.user.login))
hasGnoDevPullReview = true;
if (comment.state == "APPROVED" && triageReviewers.includes(comment.user.login))
hasTriageReviewerApproval = true;
if (comment.state == "APPROVED" && !coreDevs.includes(comment.user.login) && !triageReviewers.includes(comment.user.login)) {
if (unrecognizedApprovers != "")
unrecognizedApprovers += ","
unrecognizedApprovers += comment.user.login
}
}
}
if (hasTriageReviewerApproval) {
if (isReviewTriagePending) {
// Need to know if a new review is an approval or new comment is from a core dev.
fetchMessages += makeFetchMessages(repo, issue.number);
console.log(message + "\n WARNING: #" + issue.number + " was approved by a triage reviewer but has the 'review/triage-pending' label");
}
continue;
}
else if (hasGnoDevPullComment || hasGnoDevPullReview) {
if (isReviewTriagePending)
console.log(message + "\n WARNING: #" + issue.number + " was " + (hasGnoDevPullReview ? "reviewed" : "commented") + " by a core dev but has the 'review/triage-pending' label");
continue;
}
else {
if (!isReviewTriagePending) {
// Need to know if a new review is an approval or new comment is from a core dev.
fetchMessages += makeFetchMessages(repo, issue.number);
}
}
++total;
if (createdAt < oldest)
oldest = createdAt;
console.log(message);
if (!isReviewTriagePending) {
if (unrecognizedApprovers)
// If approved by a dev or review member, we did continue above.
console.log(" WARNING: #" + issue.number + " was approved by UNRECOGNIZED user " + unrecognizedApprovers + " and doesn't have the 'review/triage-pending' label");
else
console.log(" WARNING: #" + issue.number + " doesn't have the 'review/triage-pending' label");
}
if (milestone != " " && isStale)
console.log(" WARNING: #" + issue.number + " is stale but is on milestone " + milestone);
}
console.log("\n Total: " + total);
console.log("Oldest: " + oldest.toISOString().substring(0, 10));
if (fetchMessages != "")
console.log(fetchMessages);
}
function makeFetchMessages(repo, issueNumber) {
fetchMessages = '\ncurl "https://api.github.com/repos/gnolang/' + repo + '/pulls/' + issueNumber + '/comments" > ' + repo + '.pull-comments/' + issueNumber + '.json';
fetchMessages += '\ncurl "https://api.github.com/repos/gnolang/' + repo + '/pulls/' + issueNumber + '/reviews" > ' + repo + '.pull-reviews/' + issueNumber + '.json';
return fetchMessages;
}
function readJsonFile(filePath) {
let text = "";
try {
text = fs.readFileSync(filePath, 'utf8');
} catch (e) {
return [];
}
const blankResult = "[\n\n]\n";
while (text.endsWith(blankResult))
// The ending fetched "page" of issues is blank.
text = text.substring(0, text.length - blankResult.length);
// Replace the boundary between two pages of results.
text = text.replaceAll('\n]\n[\n', ',\n');
if (text == "")
text = "[]";
return JSON.parse(text);
}
function getPull(pulls, number) {
for (const pull of pulls) {
if (pull.number == number)
return pull;
}
return null;
}
function hasLabel(issue, labelName) {
for (const label of issue.labels) {
if (label.name == labelName)
return true;
}
return false;
}
main();