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 71850e362444..a594fa69d1a1 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,10 +31,14 @@ function getNumberOfItemsFromReviewerChecklist() { }); res.on('end', () => { const numberOfChecklistItems = (fileContents.match(/- \[ \]/g) || []).length; + console.log(`There are ${numberOfChecklistItems} items in the reviewer checklist.`); resolve(numberOfChecklistItems); }); }) - .on('error', reject); + .on('error', (err) => { + console.error(err); + reject(err); + }); }); } @@ -42,10 +47,17 @@ function getNumberOfItemsFromReviewerChecklist() { */ function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) - .then(reviewComments => combinedComments.push(...reviewComments)) + .then((reviewComments) => { + console.log(`Pulled ${reviewComments.length} 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 ${comments.length} comments, now adding them to the list...`); + combinedComments.push(...comments); + }) .then(() => { + console.log(`Looking through all ${combinedComments.length} comments for the reviewer checklist...`); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -60,14 +72,22 @@ 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!'); foundReviewerChecklist = true; numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length; numberOfUnfinishedChecklistItems = (comment.match(/- \[ \]/g) || []).length; } } + if (!foundReviewerChecklist) { + core.setFailed('No PR Reviewer Checklist was found'); + return; + } + const maxCompletedItems = numberOfChecklistItems + 2; const minCompletedItems = numberOfChecklistItems - 2; @@ -86,8 +106,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..7fb27e5b5a5a 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,10 +21,14 @@ function getNumberOfItemsFromReviewerChecklist() { }); res.on('end', () => { const numberOfChecklistItems = (fileContents.match(/- \[ \]/g) || []).length; + console.log(`There are ${numberOfChecklistItems} items in the reviewer checklist.`); resolve(numberOfChecklistItems); }); }) - .on('error', reject); + .on('error', (err) => { + console.error(err); + reject(err); + }); }); } @@ -32,10 +37,17 @@ function getNumberOfItemsFromReviewerChecklist() { */ function checkIssueForCompletedChecklist(numberOfChecklistItems) { GitHubUtils.getAllReviewComments(issue) - .then(reviewComments => combinedComments.push(...reviewComments)) + .then((reviewComments) => { + console.log(`Pulled ${reviewComments.length} 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 ${comments.length} comments, now adding them to the list...`); + combinedComments.push(...comments); + }) .then(() => { + console.log(`Looking through all ${combinedComments.length} comments for the reviewer checklist...`); let foundReviewerChecklist = false; let numberOfFinishedChecklistItems = 0; let numberOfUnfinishedChecklistItems = 0; @@ -50,14 +62,22 @@ 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!'); foundReviewerChecklist = true; numberOfFinishedChecklistItems = (comment.match(/- \[x\]/gi) || []).length; numberOfUnfinishedChecklistItems = (comment.match(/- \[ \]/g) || []).length; } } + if (!foundReviewerChecklist) { + core.setFailed('No PR Reviewer Checklist was found'); + return; + } + const maxCompletedItems = numberOfChecklistItems + 2; const minCompletedItems = numberOfChecklistItems - 2; @@ -76,6 +96,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) { } getNumberOfItemsFromReviewerChecklist() - .then(checkIssueForCompletedChecklist, (err) => { + .then(checkIssueForCompletedChecklist) + .catch((err) => { console.error(err); + core.setFailed(err); });