From af523f3fee5af660e9056f3f998c5a4965b52c36 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Wed, 16 Nov 2022 09:50:18 -0500 Subject: [PATCH 1/3] add console logs to find where it is failing --- .../javascript/reviewerChecklist/index.js | 18 +++++++++++++++--- .../reviewerChecklist/reviewerChecklist.js | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index 71850e362444..0432fc85c4f1 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -22,6 +22,7 @@ const combinedComments = []; * @returns {Promise} */ function getNumberOfItemsFromReviewerChecklist() { + console.log('Getting the number of items in the reviewer checklist...'); return new Promise((resolve, reject) => { https.get(pathToReviewerChecklist, (res) => { let fileContents = ''; @@ -30,6 +31,7 @@ function getNumberOfItemsFromReviewerChecklist() { }); res.on('end', () => { const numberOfChecklistItems = (fileContents.match(/- \[ \]/g) || []).length; + console.log(`There are ${numberOfChecklistItems} items in the reviewer checklist.`); resolve(numberOfChecklistItems); }); }) @@ -42,10 +44,17 @@ function getNumberOfItemsFromReviewerChecklist() { */ function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) - .then(reviewComments => combinedComments.push(...reviewComments)) + .then((reviewComments) => { + console.log('Pulled all review comments, now adding them to the list...'); + combinedComments.push(...reviewComments); + }) .then(() => GitHubUtils.getAllComments(issue)) - .then(comments => combinedComments.push(...comments)) + .then((comments) => { + console.log('Pulled all comments, now adding them to the list...'); + combinedComments.push(...comments); + }) .then(() => { + console.log('Looking through all comments for the reviewer checklist...'); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -62,6 +71,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { // Found the reviewer checklist, so count how many completed checklist items there are if (comment.startsWith(reviewerChecklistStartsWith)) { + console.log('Found the reviewer checklist!'); foundReviewerChecklist = true; numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length; numberOfUnfinishedChecklistItems = (comment.match(/- \[ \]/g) || []).length; @@ -86,8 +96,10 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } getNumberOfItemsFromReviewerChecklist() - .then(checkIssueForCompletedChecklist, (err) => { + .then(checkIssueForCompletedChecklist) + .catch((err) => { console.error(err); + core.setFailed(err); }); diff --git a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js index c427ff536ae9..803ef9047526 100644 --- a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js +++ b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js @@ -12,6 +12,7 @@ const combinedComments = []; * @returns {Promise} */ function getNumberOfItemsFromReviewerChecklist() { + console.log('Getting the number of items in the reviewer checklist...'); return new Promise((resolve, reject) => { https.get(pathToReviewerChecklist, (res) => { let fileContents = ''; @@ -20,6 +21,7 @@ function getNumberOfItemsFromReviewerChecklist() { }); res.on('end', () => { const numberOfChecklistItems = (fileContents.match(/- \[ \]/g) || []).length; + console.log(`There are ${numberOfChecklistItems} items in the reviewer checklist.`); resolve(numberOfChecklistItems); }); }) @@ -32,10 +34,17 @@ function getNumberOfItemsFromReviewerChecklist() { */ function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) - .then(reviewComments => combinedComments.push(...reviewComments)) + .then((reviewComments) => { + console.log('Pulled all review comments, now adding them to the list...'); + combinedComments.push(...reviewComments); + }) .then(() => GitHubUtils.getAllComments(issue)) - .then(comments => combinedComments.push(...comments)) + .then((comments) => { + console.log('Pulled all comments, now adding them to the list...'); + combinedComments.push(...comments); + }) .then(() => { + console.log('Looking through all comments for the reviewer checklist...'); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -52,6 +61,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { // Found the reviewer checklist, so count how many completed checklist items there are if (comment.startsWith(reviewerChecklistStartsWith)) { + console.log('Found the reviewer checklist!'); foundReviewerChecklist = true; numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length; numberOfUnfinishedChecklistItems = (comment.match(/- \[ \]/g) || []).length; @@ -76,6 +86,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } getNumberOfItemsFromReviewerChecklist() - .then(checkIssueForCompletedChecklist, (err) => { + .then(checkIssueForCompletedChecklist) + .catch((err) => { console.error(err); + core.setFailed(err); }); From 4b21b7a7287148d8db0de0720848ffd6e89e55c3 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Thu, 17 Nov 2022 10:30:27 -0500 Subject: [PATCH 2/3] address comments --- .../authorChecklist/authorChecklist.js | 4 +++- .../javascript/authorChecklist/index.js | 4 +++- .../javascript/reviewerChecklist/index.js | 18 ++++++++++++++---- .../reviewerChecklist/reviewerChecklist.js | 18 ++++++++++++++---- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/authorChecklist.js b/.github/actions/javascript/authorChecklist/authorChecklist.js index 9e9b878c6a8f..52c4d1730978 100644 --- a/.github/actions/javascript/authorChecklist/authorChecklist.js +++ b/.github/actions/javascript/authorChecklist/authorChecklist.js @@ -62,6 +62,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } getNumberOfItemsFromAuthorChecklist() - .then(checkIssueForCompletedChecklist, (err) => { + .then(checkIssueForCompletedChecklist) + .catch((err) => { console.error(err); + core.setFailed(err); }); diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 1ca5748f92f2..ca221c043b50 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -72,8 +72,10 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } getNumberOfItemsFromAuthorChecklist() - .then(checkIssueForCompletedChecklist, (err) => { + .then(checkIssueForCompletedChecklist) + .catch((err) => { console.error(err); + core.setFailed(err); }); diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index 0432fc85c4f1..8155ac5836e6 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -35,7 +35,10 @@ function getNumberOfItemsFromReviewerChecklist() { resolve(numberOfChecklistItems); }); }) - .on('error', reject); + .on('error', (err) => { + console.error(err); + reject(); + }); }); } @@ -45,16 +48,16 @@ function getNumberOfItemsFromReviewerChecklist() { function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) .then((reviewComments) => { - console.log('Pulled all review comments, now adding them to the list...'); + console.log(`Pulled ${reviewComments.length} review comments, now adding them to the list...`); combinedComments.push(...reviewComments); }) .then(() => GitHubUtils.getAllComments(issue)) .then((comments) => { - console.log('Pulled all comments, now adding them to the list...'); + console.log(`Pulled ${comments.length} comments, now adding them to the list...`); combinedComments.push(...comments); }) .then(() => { - console.log('Looking through all comments for the reviewer checklist...'); + console.log(`Looking through all ${combinedComments.length} comments for the reviewer checklist...`); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -69,6 +72,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { const whitespace = /([\n\r])/gm; const comment = combinedComments[i].replace(whitespace, ''); + console.log(`Comment ${i} starts with: ${comment.slice(0, 20)}...`); + // Found the reviewer checklist, so count how many completed checklist items there are if (comment.startsWith(reviewerChecklistStartsWith)) { console.log('Found the reviewer checklist!'); @@ -78,6 +83,11 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } } + if (!foundReviewerChecklist) { + core.setFailed('No PR Reviewer Checklist was found'); + return; + } + const maxCompletedItems = numberOfChecklistItems + 2; const minCompletedItems = numberOfChecklistItems - 2; diff --git a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js index 803ef9047526..6a56603ec8f7 100644 --- a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js +++ b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js @@ -25,7 +25,10 @@ function getNumberOfItemsFromReviewerChecklist() { resolve(numberOfChecklistItems); }); }) - .on('error', reject); + .on('error', (err) => { + console.error(err); + reject(); + }); }); } @@ -35,16 +38,16 @@ function getNumberOfItemsFromReviewerChecklist() { function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) .then((reviewComments) => { - console.log('Pulled all review comments, now adding them to the list...'); + console.log(`Pulled ${reviewComments.length} review comments, now adding them to the list...`); combinedComments.push(...reviewComments); }) .then(() => GitHubUtils.getAllComments(issue)) .then((comments) => { - console.log('Pulled all comments, now adding them to the list...'); + console.log(`Pulled ${comments.length} comments, now adding them to the list...`); combinedComments.push(...comments); }) .then(() => { - console.log('Looking through all comments for the reviewer checklist...'); + console.log(`Looking through all ${combinedComments.length} comments for the reviewer checklist...`); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -59,6 +62,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { const whitespace = /([\n\r])/gm; const comment = combinedComments[i].replace(whitespace, ''); + console.log(`Comment ${i} starts with: ${comment.slice(0, 20)}...`); + // Found the reviewer checklist, so count how many completed checklist items there are if (comment.startsWith(reviewerChecklistStartsWith)) { console.log('Found the reviewer checklist!'); @@ -68,6 +73,11 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } } + if (!foundReviewerChecklist) { + core.setFailed('No PR Reviewer Checklist was found'); + return; + } + const maxCompletedItems = numberOfChecklistItems + 2; const minCompletedItems = numberOfChecklistItems - 2; From 9eff654c002389d1c4b4c01e46099cf39876bcb9 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Thu, 17 Nov 2022 11:45:21 -0500 Subject: [PATCH 3/3] pass down error --- .github/actions/javascript/reviewerChecklist/index.js | 2 +- .../actions/javascript/reviewerChecklist/reviewerChecklist.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index 8155ac5836e6..a594fa69d1a1 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -37,7 +37,7 @@ function getNumberOfItemsFromReviewerChecklist() { }) .on('error', (err) => { console.error(err); - reject(); + reject(err); }); }); } diff --git a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js index 6a56603ec8f7..7fb27e5b5a5a 100644 --- a/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js +++ b/.github/actions/javascript/reviewerChecklist/reviewerChecklist.js @@ -27,7 +27,7 @@ function getNumberOfItemsFromReviewerChecklist() { }) .on('error', (err) => { console.error(err); - reject(); + reject(err); }); }); }