Skip to content

Commit

Permalink
Add a welcome comment to first time contributor PR (#28118)
Browse files Browse the repository at this point in the history
* Add a welcome comment to first time contributor PR

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: #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.

* Fix a missed quotation mark

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

* Update packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

* Make the code prettier

* Update test to take into account new comment feature

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
  • Loading branch information
annezazu and talldan authored Feb 8, 2021
1 parent f622315 commit 24552b9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe( 'firstTimeContributorLabel', () => {
},
issues: {
addLabels: jest.fn(),
createComment: jest.fn(),
},
};

Expand All @@ -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 () => {
Expand All @@ -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( {
Expand All @@ -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,
} );
} );
} );

0 comments on commit 24552b9

Please sign in to comment.