From 8b750b2454007dd0953f5da91701010164ff4702 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 6 Sep 2022 15:30:56 +0100 Subject: [PATCH 1/3] Try to use event array --- .github/workflows/testChecklists.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/testChecklists.yml b/.github/workflows/testChecklists.yml index 530c37fa692b..83ad7462475d 100644 --- a/.github/workflows/testChecklists.yml +++ b/.github/workflows/testChecklists.yml @@ -1,12 +1,6 @@ name: Contributor Checklist -on: - issue_comment: - types: [created, edited, deleted] - pull_request_review: - types: [submitted, edited, dismissed] - pull_request: - types: [opened, edited, synchronize] +on: [issue_comment, pull_request_review, pull_request] jobs: checklist: From 8d11a680435492ea1341b54152e19bd80278e468 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 6 Sep 2022 16:22:29 +0100 Subject: [PATCH 2/3] Split up C and C+ checklists into two different tests --- .../javascript/contributorChecklist/action.yml | 3 +++ .../contributorChecklist/contributorChecklist.js | 10 ++++++---- .../javascript/contributorChecklist/index.js | 10 ++++++---- .github/workflows/contributorChecklists.yml | 14 ++++++++++++++ .github/workflows/contributorPlusChecklists.yml | 14 ++++++++++++++ .github/workflows/testChecklists.yml | 14 -------------- 6 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/contributorChecklists.yml create mode 100644 .github/workflows/contributorPlusChecklists.yml delete mode 100644 .github/workflows/testChecklists.yml diff --git a/.github/actions/javascript/contributorChecklist/action.yml b/.github/actions/javascript/contributorChecklist/action.yml index 16a6dbea0b04..787fac8182ce 100644 --- a/.github/actions/javascript/contributorChecklist/action.yml +++ b/.github/actions/javascript/contributorChecklist/action.yml @@ -4,6 +4,9 @@ inputs: GITHUB_TOKEN: description: Auth token for New Expensify Github required: true + CHECKLIST: + description: The checklist to look for, either 'contributor' or 'contributorPlus' + required: true runs: using: 'node16' main: './index.js' diff --git a/.github/actions/javascript/contributorChecklist/contributorChecklist.js b/.github/actions/javascript/contributorChecklist/contributorChecklist.js index 5c5da39afd81..9ff8c0f5da32 100644 --- a/.github/actions/javascript/contributorChecklist/contributorChecklist.js +++ b/.github/actions/javascript/contributorChecklist/contributorChecklist.js @@ -97,6 +97,8 @@ const completedContributorPlusChecklist = `- [x] I have verified the author chec - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected. - [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.`; +// True if we are validating a contributor checklist, otherwise we are validating a contributor+ checklist +const verifyingContributorChecklist = core.getInput('CHECKLIST', {required: true}) === 'contributor'; const issue = github.context.payload.issue ? github.context.payload.issue.number : github.context.payload.pull_request.number; const combinedData = []; @@ -150,17 +152,17 @@ getPullRequestBody() } } - if (!contributorChecklistComplete) { + if (verifyingContributorChecklist && !contributorChecklistComplete) { 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('Contributor checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); return; } - if (!contributorPlusChecklistComplete) { + if (!verifyingContributorChecklist && !contributorPlusChecklistComplete) { 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('Contributor plus checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); + core.setFailed('Contributor+ checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); return; } - console.log('All checklists are complete 🎉'); + console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} is complete 🎉`); }); diff --git a/.github/actions/javascript/contributorChecklist/index.js b/.github/actions/javascript/contributorChecklist/index.js index 932594155e29..d9b200078e20 100644 --- a/.github/actions/javascript/contributorChecklist/index.js +++ b/.github/actions/javascript/contributorChecklist/index.js @@ -107,6 +107,8 @@ const completedContributorPlusChecklist = `- [x] I have verified the author chec - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected. - [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.`; +// True if we are validating a contributor checklist, otherwise we are validating a contributor+ checklist +const verifyingContributorChecklist = core.getInput('CHECKLIST', {required: true}) === 'contributor'; const issue = github.context.payload.issue ? github.context.payload.issue.number : github.context.payload.pull_request.number; const combinedData = []; @@ -160,19 +162,19 @@ getPullRequestBody() } } - if (!contributorChecklistComplete) { + if (verifyingContributorChecklist && !contributorChecklistComplete) { 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('Contributor checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); return; } - if (!contributorPlusChecklistComplete) { + if (!verifyingContributorChecklist && !contributorPlusChecklistComplete) { 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('Contributor plus checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); + core.setFailed('Contributor+ checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.'); return; } - console.log('All checklists are complete 🎉'); + console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} is complete 🎉`); }); diff --git a/.github/workflows/contributorChecklists.yml b/.github/workflows/contributorChecklists.yml new file mode 100644 index 000000000000..692ba8944956 --- /dev/null +++ b/.github/workflows/contributorChecklists.yml @@ -0,0 +1,14 @@ +name: Contributor Checklist + +on: pull_request + +jobs: + checklist: + runs-on: ubuntu-latest + if: github.actor != 'OSBotify' && (github.event_name == 'pull_request' && contains(github.event.pull_request.body, '- [')) + steps: + - name: contributorChecklist.js + uses: Expensify/App/.github/actions/javascript/contributorChecklist@andrew-checklist-3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CHECKLIST: 'contributor' diff --git a/.github/workflows/contributorPlusChecklists.yml b/.github/workflows/contributorPlusChecklists.yml new file mode 100644 index 000000000000..5acffb511386 --- /dev/null +++ b/.github/workflows/contributorPlusChecklists.yml @@ -0,0 +1,14 @@ +name: Contributor+ Checklist + +on: issue_comment + +jobs: + checklist: + runs-on: ubuntu-latest + if: github.actor != 'OSBotify' && (contains(github.event.issue.pull_request.url, 'http') && github.event_name == 'issue_comment' && contains(github.event.comment.body, '- [')) + steps: + - name: contributorChecklist.js + uses: Expensify/App/.github/actions/javascript/contributorChecklist@andrew-checklist-3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CHECKLIST: 'contributorPlus' diff --git a/.github/workflows/testChecklists.yml b/.github/workflows/testChecklists.yml deleted file mode 100644 index 83ad7462475d..000000000000 --- a/.github/workflows/testChecklists.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Contributor Checklist - -on: [issue_comment, pull_request_review, pull_request] - -jobs: - checklist: - runs-on: ubuntu-latest - # Only run when a comment, PR, or PR review comment contains a checklist item - if: github.actor != 'OSBotify' && (contains(github.event.issue.pull_request.url, 'http') && github.event_name == 'issue_comment' && contains(github.event.comment.body, '- [') || github.event_name == 'pull_request_review' && contains(github.event.review.body, '- [') || github.event_name == 'pull_request' && contains(github.event.pull_request.body, '- [')) - steps: - - name: contributorChecklist.js - uses: Expensify/App/.github/actions/javascript/contributorChecklist@main - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4c84ee9c3a5b9205ec25b8ad267328f20454584f Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 6 Sep 2022 16:32:36 +0100 Subject: [PATCH 3/3] Update success message --- .../javascript/contributorChecklist/contributorChecklist.js | 2 +- .github/actions/javascript/contributorChecklist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/contributorChecklist/contributorChecklist.js b/.github/actions/javascript/contributorChecklist/contributorChecklist.js index 9ff8c0f5da32..62036078d24c 100644 --- a/.github/actions/javascript/contributorChecklist/contributorChecklist.js +++ b/.github/actions/javascript/contributorChecklist/contributorChecklist.js @@ -164,5 +164,5 @@ getPullRequestBody() return; } - console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} is complete 🎉`); + console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} checklist is complete 🎉`); }); diff --git a/.github/actions/javascript/contributorChecklist/index.js b/.github/actions/javascript/contributorChecklist/index.js index d9b200078e20..1041b6906cfd 100644 --- a/.github/actions/javascript/contributorChecklist/index.js +++ b/.github/actions/javascript/contributorChecklist/index.js @@ -174,7 +174,7 @@ getPullRequestBody() return; } - console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} is complete 🎉`); + console.log(`${verifyingContributorChecklist ? 'Contributor' : 'Contributor+'} checklist is complete 🎉`); });