From e53145fa3a157bb3c4af073ab7cf0fa28f9ade2a Mon Sep 17 00:00:00 2001 From: annezazu Date: Mon, 11 Jan 2021 15:18:16 -0700 Subject: [PATCH 1/5] Add a welcome comment to first time contributor PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR seeks to close out this project automation task by adding in a welcome message to first time contributors encouraging them to join WordPress.org slack and to review the core handbook: https://github.com/WordPress/gutenberg/issues/27423 Rather than creating a new file, decided to just latch onto our current setup for adding the first time contributor label. I'm no JS developer so, in a true inception moment, I'll need some "first time contributor" like guidance here to get this right 😄 and, per usual, welcome thoughts on what this message should say. Since we already have a message in place when a PR is merged to encourage folks to connect their WordPress.org profile, I'm leaving that out. --- .../tasks/first-time-contributor-label/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js index fdc16161db62c..141d24119f059 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js @@ -46,6 +46,22 @@ async function firstTimeContributorLabel( payload, octokit ) { issue_number: payload.pull_request.number, labels: [ 'First-time Contributor' ], } ); + +/** + * Adds a welcome comment to the first time PR + */ + + await octokit.issues.createComment( { + owner, + repo, + issue_number: payload.pull_request.number, + body: ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' + + author + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/), + + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.' + } ); +} } module.exports = firstTimeContributorLabel; From a65a334358c28ab490e0714510f7d9328310ba56 Mon Sep 17 00:00:00 2001 From: annezazu Date: Wed, 13 Jan 2021 14:12:00 -0700 Subject: [PATCH 2/5] Fix a missed quotation mark Co-authored-by: Daniel Richards --- .../lib/tasks/first-time-contributor-label/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js index 141d24119f059..e257b18bc6d30 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js @@ -57,7 +57,7 @@ async function firstTimeContributorLabel( payload, octokit ) { issue_number: payload.pull_request.number, body: ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' + author + - "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/), + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.' } ); From 9141c9894868f86f3b139ed1c1d1c2b294214d4a Mon Sep 17 00:00:00 2001 From: annezazu Date: Thu, 14 Jan 2021 21:38:07 -0700 Subject: [PATCH 3/5] Update packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js Co-authored-by: Daniel Richards --- .../lib/tasks/first-time-contributor-label/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js index e257b18bc6d30..ef05c5e34be70 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js @@ -62,6 +62,5 @@ async function firstTimeContributorLabel( payload, octokit ) { 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.' } ); } -} module.exports = firstTimeContributorLabel; From 0db6367a6e8f1a3bf067cc247f1e87d78b26da83 Mon Sep 17 00:00:00 2001 From: annezazu Date: Fri, 15 Jan 2021 13:43:39 -0700 Subject: [PATCH 4/5] Make the code prettier --- .../first-time-contributor-label/index.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js index ef05c5e34be70..5a5bf40978a1f 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js @@ -46,20 +46,21 @@ async function firstTimeContributorLabel( payload, octokit ) { issue_number: payload.pull_request.number, labels: [ 'First-time Contributor' ], } ); - -/** - * Adds a welcome comment to the first time PR - */ - + + /** + * Adds a welcome comment to the first time PR + */ + await octokit.issues.createComment( { owner, repo, issue_number: payload.pull_request.number, - body: ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' + - author + - "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + - 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + - 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.' + body: + ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' + + author + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.', } ); } From 3e4855b46a6803b419d7e520580bdee4e02913d1 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 8 Feb 2021 14:28:24 +0800 Subject: [PATCH 5/5] Update test to take into account new comment feature --- .../first-time-contributor-label/test/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js index 83e356bb7bca8..b1710ab585325 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js @@ -32,6 +32,7 @@ describe( 'firstTimeContributorLabel', () => { }, issues: { addLabels: jest.fn(), + createComment: jest.fn(), }, }; @@ -43,6 +44,7 @@ describe( 'firstTimeContributorLabel', () => { author: 'ghost', } ); expect( octokit.issues.addLabels ).not.toHaveBeenCalled(); + expect( octokit.issues.createComment ).not.toHaveBeenCalled(); } ); it( 'adds the First Time Contributor label if the user has no commits', async () => { @@ -56,9 +58,16 @@ describe( 'firstTimeContributorLabel', () => { }, issues: { addLabels: jest.fn(), + createComment: jest.fn(), }, }; + const expectedComment = + ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ghost' + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.'; + await firstTimeContributorLabel( payload, octokit ); expect( octokit.repos.listCommits ).toHaveBeenCalledWith( { @@ -72,5 +81,11 @@ describe( 'firstTimeContributorLabel', () => { issue_number: 123, labels: [ 'First-time Contributor' ], } ); + expect( octokit.issues.createComment ).toHaveBeenCalledWith( { + owner: 'WordPress', + repo: 'gutenberg', + issue_number: 123, + body: expectedComment, + } ); } ); } );