forked from openjournals/buffy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
365 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require_relative "../lib/responder" | ||
|
||
|
||
class ExternalStartReviewResponder < Responder | ||
|
||
keyname :external_start_review | ||
|
||
def define_listening | ||
required_params :external_call | ||
|
||
@event_action = "issue_comment.created" | ||
@event_regex = /\A@#{bot_name} start review\.?\s*\z/i | ||
end | ||
|
||
def process_message(message) | ||
return unless roles_and_issue? | ||
process_external_service(params[:external_call], locals_with_editor_and_reviewers) | ||
end | ||
|
||
def roles_and_issue? | ||
unless username?(reviewers_usernames.first.to_s) | ||
respond("Can't start a review without reviewers") | ||
return false | ||
end | ||
|
||
unless username?(editor_username) | ||
respond("Can't start a review without an editor") | ||
return false | ||
end | ||
|
||
if context.issue_title.match(title_regex) | ||
respond("Can't start a review when the review has already started") | ||
return false | ||
end | ||
|
||
true | ||
end | ||
|
||
def reviewers_usernames | ||
@reviewers_usernames ||= read_value_from_body("reviewers-list").split(",").map(&:strip) | ||
end | ||
|
||
def reviewers_logins | ||
@reviewers_logins ||= reviewers_usernames.map {|reviewer_username| user_login(reviewer_username)}.join(",") | ||
end | ||
|
||
def editor_username | ||
@editor_username ||= read_value_from_body("editor") | ||
end | ||
|
||
def editor_login | ||
@editor_login ||= user_login(editor_username) | ||
end | ||
|
||
def title_regex | ||
params[:review_title_regex] || /^\[REVIEW\]:/ | ||
end | ||
|
||
def locals_with_editor_and_reviewers | ||
locals.merge({ reviewers_usernames: reviewers_usernames, | ||
reviewers_logins: reviewers_logins, | ||
editor_username: editor_username, | ||
editor_login: editor_login }) | ||
end | ||
|
||
def description | ||
"Open the review issue" | ||
end | ||
|
||
def example_invocation | ||
"@#{@bot_name} start review" | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
External start review | ||
===================== | ||
|
||
This responder checks for the presence of editor and reviewers in an issue and then delegates the creation of a new review isuue to an external API call. | ||
|
||
## Listens to | ||
|
||
``` | ||
@botname start review | ||
``` | ||
|
||
## Requirements | ||
|
||
The parameters required for the responder to work are the ones configuring the external API call, nested under the `external_call` parameter. | ||
|
||
|
||
## Settings key | ||
|
||
`external_start_review` | ||
|
||
## Params | ||
|
||
```eval_rst | ||
:external_call: *Required*. Nested under this parameter is the configuration for the external call that will start the review. All available subparams are described in the `external_service docs`_. | ||
:review_title_regex: *Optional*. By default the responder will check that this command has not been triggered from a review issue by checking the title. If it starts with `[REVIEW]:` the command will be rejected. This parameter allows to specify a different string/regex to identify a review issue matching the title. | ||
.. _`external_service docs`: ./external_service.html#params | ||
``` | ||
|
||
|
||
## Examples | ||
|
||
**Restricted to editors, respond with a template and close the issue:** | ||
```yaml | ||
... | ||
external_start_review: | ||
only: editors | ||
external_call: | ||
url: "https://test.joss.theoj.org/papers/api_start_review" | ||
query_params: | ||
secret: <%= ENV['TEST_SECRET'] %> | ||
mapping: | ||
id: issue_id | ||
editor: editor_login | ||
reviewers: reviewers_logins | ||
silent: true | ||
template_file: "review_started.md" | ||
close: true | ||
... | ||
``` | ||
|
||
The responder will call https://test.joss.theoj.org/papers/api_start_review and the response will be passed to the _review_started.md_ template. | ||
|
||
## In action | ||
|
||
![](../images/responders/external_start_review.png "External start review responder in action") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.