Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Add console logs to investigate where the Reviewer Checklist check is failing #12771

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
}

getNumberOfItemsFromAuthorChecklist()
.then(checkIssueForCompletedChecklist, (err) => {
.then(checkIssueForCompletedChecklist)
.catch((err) => {
console.error(err);
core.setFailed(err);
});
4 changes: 3 additions & 1 deletion .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
}

getNumberOfItemsFromAuthorChecklist()
.then(checkIssueForCompletedChecklist, (err) => {
.then(checkIssueForCompletedChecklist)
.catch((err) => {
console.error(err);
core.setFailed(err);
});


Expand Down
30 changes: 26 additions & 4 deletions .github/actions/javascript/reviewerChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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.`);
dangrous marked this conversation as resolved.
Show resolved Hide resolved
resolve(numberOfChecklistItems);
});
})
.on('error', reject);
.on('error', (err) => {
console.error(err);
reject(err);
});
});
}

Expand All @@ -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;
Expand All @@ -60,14 +72,22 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
const whitespace = /([\n\r])/gm;
const comment = combinedComments[i].replace(whitespace, '');

dangrous marked this conversation as resolved.
Show resolved Hide resolved
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;
dangrous marked this conversation as resolved.
Show resolved Hide resolved
}
}

if (!foundReviewerChecklist) {
core.setFailed('No PR Reviewer Checklist was found');
return;
}

const maxCompletedItems = numberOfChecklistItems + 2;
const minCompletedItems = numberOfChecklistItems - 2;

Expand All @@ -86,8 +106,10 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
}

getNumberOfItemsFromReviewerChecklist()
.then(checkIssueForCompletedChecklist, (err) => {
.then(checkIssueForCompletedChecklist)
.catch((err) => {
console.error(err);
core.setFailed(err);
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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);
});
});
}

Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -76,6 +96,8 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems) {
}

getNumberOfItemsFromReviewerChecklist()
.then(checkIssueForCompletedChecklist, (err) => {
.then(checkIssueForCompletedChecklist)
dangrous marked this conversation as resolved.
Show resolved Hide resolved
.catch((err) => {
console.error(err);
core.setFailed(err);
});