diff --git a/.github/actions/javascript/contributorChecklist/contributorChecklist.js b/.github/actions/javascript/contributorChecklist/contributorChecklist.js
index 7411fbf88bd71..7cb201bdbbac3 100644
--- a/.github/actions/javascript/contributorChecklist/contributorChecklist.js
+++ b/.github/actions/javascript/contributorChecklist/contributorChecklist.js
@@ -127,37 +127,58 @@ function getAllComments() {
}, response => _.map(response.data, comment => comment.body));
}
+function countCheckedBoxes(string) {
+ return string.toLowerCase().match(/\[x\]/g).length;
+}
+
+function getChecklistSectionOfPullRequestBody(pullRequestBody) {
+ const processed = pullRequestBody.match(/#### PR Author Checklist(.*)
PR Reviewer Checklist<\/h4>/);
+ return processed ? processed[1] : '';
+}
+
getPullRequestBody()
- .then(pullRequestBody => combinedData.push(pullRequestBody))
+ .then(pullRequestBody => combinedData.push(getChecklistSectionOfPullRequestBody(pullRequestBody)))
.then(() => getAllReviewComments())
.then(reviewComments => combinedData.push(...reviewComments))
.then(() => getAllComments())
.then(comments => combinedData.push(...comments))
.then(() => {
- let authorChecklistComplete = false;
- let reviewerChecklistComplete = false;
+ let authorChecklistComment = null;
+ let reviewerChecklistComment = null;
+
+ const authorChecklistNumber = countCheckedBoxes(completedAuthorChecklist);
+ const reviewerChecklistNumber = countCheckedBoxes(completedReviewerChecklist);
- // Once we've gathered all the data, loop through each comment and look to see if it contains a completed checklist
+ // Once we've gathered all the data, loop through each comment and look to see if it contains enough completed checkboxes
for (let i = 0; i < combinedData.length; i++) {
- const whitespace = /([\n\r])/gm;
- const comment = combinedData[i].replace(whitespace, '');
+ const comment = combinedData[i];
+ const commentChecklistNumber = countCheckedBoxes(comment);
- if (comment.includes(completedAuthorChecklist.replace(whitespace, ''))) {
- authorChecklistComplete = true;
+ if (
+ commentChecklistNumber >= authorChecklistNumber - 2
+ && commentChecklistNumber <= authorChecklistNumber + 2
+ && !comment.includes('[ ]')
+ ) {
+ authorChecklistComment = i;
}
- if (comment.includes(completedReviewerChecklist.replace(whitespace, ''))) {
- reviewerChecklistComplete = true;
+ if (
+ authorChecklistComment !== i
+ && commentChecklistNumber >= reviewerChecklistNumber - 2
+ && commentChecklistNumber <= reviewerChecklistNumber + 2
+ && !comment.includes('[ ]')
+ ) {
+ reviewerChecklistComment = i;
}
}
- if (verifyingAuthorChecklist && !authorChecklistComplete) {
+ if (verifyingAuthorChecklist && authorChecklistComment === null) {
console.log('Make sure you are using the most up to date checklist found here: https://raw.githubusercontent.com/Expensify/App/main/.github/PULL_REQUEST_TEMPLATE.md');
core.setFailed('PR Author Checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.');
return;
}
- if (!verifyingAuthorChecklist && !reviewerChecklistComplete) {
+ if (!verifyingAuthorChecklist && reviewerChecklistComment === null) {
console.log('Make sure you are using the most up to date checklist found here: https://raw.githubusercontent.com/Expensify/App/main/.github/PULL_REQUEST_TEMPLATE.md');
core.setFailed('PR Reviewer Checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.');
return;
diff --git a/.github/actions/javascript/contributorChecklist/index.js b/.github/actions/javascript/contributorChecklist/index.js
index ecf8f6ecd625f..23879c3b08989 100644
--- a/.github/actions/javascript/contributorChecklist/index.js
+++ b/.github/actions/javascript/contributorChecklist/index.js
@@ -137,37 +137,58 @@ function getAllComments() {
}, response => _.map(response.data, comment => comment.body));
}
+function countCheckedBoxes(string) {
+ return string.toLowerCase().match(/\[x\]/g).length;
+}
+
+function getChecklistSectionOfPullRequestBody(pullRequestBody) {
+ const processed = pullRequestBody.match(/#### PR Author Checklist(.*)PR Reviewer Checklist<\/h4>/);
+ return processed ? processed[1] : '';
+}
+
getPullRequestBody()
- .then(pullRequestBody => combinedData.push(pullRequestBody))
+ .then(pullRequestBody => combinedData.push(getChecklistSectionOfPullRequestBody(pullRequestBody)))
.then(() => getAllReviewComments())
.then(reviewComments => combinedData.push(...reviewComments))
.then(() => getAllComments())
.then(comments => combinedData.push(...comments))
.then(() => {
- let authorChecklistComplete = false;
- let reviewerChecklistComplete = false;
+ let authorChecklistComment = null;
+ let reviewerChecklistComment = null;
- // Once we've gathered all the data, loop through each comment and look to see if it contains a completed checklist
- for (let i = 0; i < combinedData.length; i++) {
- const whitespace = /([\n\r])/gm;
- const comment = combinedData[i].replace(whitespace, '');
+ const authorChecklistNumber = countCheckedBoxes(completedAuthorChecklist);
+ const reviewerChecklistNumber = countCheckedBoxes(completedReviewerChecklist);
- if (comment.includes(completedAuthorChecklist.replace(whitespace, ''))) {
- authorChecklistComplete = true;
+ // Once we've gathered all the data, loop through each comment and look to see if it contains enough completed checkboxes
+ for (let i = 0; i < combinedData.length; i++) {
+ const comment = combinedData[i];
+ const commentChecklistNumber = countCheckedBoxes(comment);
+
+ if (
+ commentChecklistNumber >= authorChecklistNumber - 2
+ && commentChecklistNumber <= authorChecklistNumber + 2
+ && !comment.includes('[ ]')
+ ) {
+ authorChecklistComment = i;
}
- if (comment.includes(completedReviewerChecklist.replace(whitespace, ''))) {
- reviewerChecklistComplete = true;
+ if (
+ authorChecklistComment !== i
+ && commentChecklistNumber >= reviewerChecklistNumber - 2
+ && commentChecklistNumber <= reviewerChecklistNumber + 2
+ && !comment.includes('[ ]')
+ ) {
+ reviewerChecklistComment = i;
}
}
- if (verifyingAuthorChecklist && !authorChecklistComplete) {
+ if (verifyingAuthorChecklist && authorChecklistComment === null) {
console.log('Make sure you are using the most up to date checklist found here: https://raw.githubusercontent.com/Expensify/App/main/.github/PULL_REQUEST_TEMPLATE.md');
core.setFailed('PR Author Checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.');
return;
}
- if (!verifyingAuthorChecklist && !reviewerChecklistComplete) {
+ if (!verifyingAuthorChecklist && reviewerChecklistComment === null) {
console.log('Make sure you are using the most up to date checklist found here: https://raw.githubusercontent.com/Expensify/App/main/.github/PULL_REQUEST_TEMPLATE.md');
core.setFailed('PR Reviewer Checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.');
return;