From 5ad3a3023b9f20aafb6105af0c5a9027dd825c62 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 29 Sep 2020 12:12:21 +0100 Subject: [PATCH 1/4] repokitteh: Add welcome message for new contributors Signed-off-by: Ryan Northey --- ci/repokitteh/modules/newcontributor.star | 31 +++++++++++++++++++++++ repokitteh.star | 1 + 2 files changed, 32 insertions(+) create mode 100644 ci/repokitteh/modules/newcontributor.star diff --git a/ci/repokitteh/modules/newcontributor.star b/ci/repokitteh/modules/newcontributor.star new file mode 100644 index 000000000000..8070a560619e --- /dev/null +++ b/ci/repokitteh/modules/newcontributor.star @@ -0,0 +1,31 @@ + +# not sure if this is needed, or whether `pull_request` below has info already +def get_pr_author_association(issue_number): + return github.call( + method="GET", + path="repos/envoyproxy/envoy/pulls/%s" % issue_number)["json"]["author_association"] + +def is_newcontributor(pull_request): + # check for any existing open PRs from user ? + return pull_request["author_association"] == "FIRST_TIME_CONTRIBUTOR" + +def should_message_newcontributor(action, pull_request): + return ( + action == 'opened' + and is_newcontributor(pull_request)) + +def send_newcontributor_message(sender): + github.issue_create_comment(""" +hi @%s, welcome and thankyou for your contribution. + +We will try to review your Pull Request as quickly as possible. + +In the meantime, please take a look at the [contribution guidelines](https://github.com/envoyproxy/envoy/blob/master/CONTRIBUTING.md) if you have not done so already. + +""" % sender) + +def _pr(action, pull_request, sender, config): + if should_message_newcontributor(action, pull_request): + send_newcontributor_message(sender) + +handlers.pull_request(func=_pr) diff --git a/repokitteh.star b/repokitteh.star index f71320677c31..be663fdd4207 100644 --- a/repokitteh.star +++ b/repokitteh.star @@ -5,6 +5,7 @@ use("github.com/repokitteh/modules/review.star") use("github.com/repokitteh/modules/wait.star") use("github.com/repokitteh/modules/circleci.star", secret_token=get_secret('circle_token')) use("github.com/envoyproxy/envoy/ci/repokitteh/modules/azure_pipelines.star", secret_token=get_secret('azp_token')) +use("github.com/envoyproxy/envoy/ci/repokitteh/modules/newcontributor.star") use( "github.com/envoyproxy/envoy/ci/repokitteh/modules/ownerscheck.star", paths=[ From 0490dd9c3b7f26ef5f295716695db34f9f0cac43 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 5 Oct 2020 18:23:32 +0100 Subject: [PATCH 2/4] cleanup: fix getting pr/author association Signed-off-by: Ryan Northey --- ci/repokitteh/modules/newcontributor.star | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ci/repokitteh/modules/newcontributor.star b/ci/repokitteh/modules/newcontributor.star index 8070a560619e..17005743c86c 100644 --- a/ci/repokitteh/modules/newcontributor.star +++ b/ci/repokitteh/modules/newcontributor.star @@ -1,31 +1,31 @@ -# not sure if this is needed, or whether `pull_request` below has info already +NEW_CONTRIBUTOR_MESSAGE = """ +hi @%s, welcome and thankyou for your contribution. + +We will try to review your Pull Request as quickly as possible. + +In the meantime, please take a look at the [contribution guidelines](https://github.com/envoyproxy/envoy/blob/master/CONTRIBUTING.md) if you have not done so already. + +""" + def get_pr_author_association(issue_number): return github.call( method="GET", path="repos/envoyproxy/envoy/pulls/%s" % issue_number)["json"]["author_association"] -def is_newcontributor(pull_request): - # check for any existing open PRs from user ? - return pull_request["author_association"] == "FIRST_TIME_CONTRIBUTOR" +def is_newcontributor(issue_number): + return get_pr_author_association(issue_number) == "FIRST_TIME_CONTRIBUTOR" -def should_message_newcontributor(action, pull_request): +def should_message_newcontributor(action, issue_number): return ( action == 'opened' - and is_newcontributor(pull_request)) + and is_newcontributor(issue_number)) def send_newcontributor_message(sender): - github.issue_create_comment(""" -hi @%s, welcome and thankyou for your contribution. - -We will try to review your Pull Request as quickly as possible. - -In the meantime, please take a look at the [contribution guidelines](https://github.com/envoyproxy/envoy/blob/master/CONTRIBUTING.md) if you have not done so already. - -""" % sender) + github.issue_create_comment(NEW_CONTRIBUTOR_MESSAGE % sender) -def _pr(action, pull_request, sender, config): - if should_message_newcontributor(action, pull_request): +def _pr(action, issue_number, sender, config): + if should_message_newcontributor(action, issue_number): send_newcontributor_message(sender) handlers.pull_request(func=_pr) From ffd43e991d442f37050f04a559f6089158c6b69e Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 11 Oct 2020 18:19:24 +0100 Subject: [PATCH 3/4] thankyou -> thank you Signed-off-by: Ryan Northey --- ci/repokitteh/modules/newcontributor.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/repokitteh/modules/newcontributor.star b/ci/repokitteh/modules/newcontributor.star index 17005743c86c..59f894519368 100644 --- a/ci/repokitteh/modules/newcontributor.star +++ b/ci/repokitteh/modules/newcontributor.star @@ -1,6 +1,6 @@ NEW_CONTRIBUTOR_MESSAGE = """ -hi @%s, welcome and thankyou for your contribution. +hi @%s, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. From a107b5fea60beb5df8e18c2b82f0df1f9a7e7cbd Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 11 Oct 2020 18:22:21 +0100 Subject: [PATCH 4/4] capitalize Hi Signed-off-by: Ryan Northey --- ci/repokitteh/modules/newcontributor.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/repokitteh/modules/newcontributor.star b/ci/repokitteh/modules/newcontributor.star index 59f894519368..4cf644bc200f 100644 --- a/ci/repokitteh/modules/newcontributor.star +++ b/ci/repokitteh/modules/newcontributor.star @@ -1,6 +1,6 @@ NEW_CONTRIBUTOR_MESSAGE = """ -hi @%s, welcome and thank you for your contribution. +Hi @%s, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible.