hubot-code-review
A Hubot script for GitHub code review on Slack.
tldr;
Drop a GitHub pull request url into a room, and Hubot adds the pull request to the room's queue (each room has its own queue)...
Every 5 minutes, Hubot reports the current code review queue to the room (after an hour of no interaction, it messages @here with a warning and switches to hourly reminders)...
A co-worker can claim it for review...
Once the review is complete, a GitHub webhook listener catches approvals and Direct Messages the submitter:
Requirements
You'll need Hubot and hubot-slack > 4
Installation via NPM
Run the following command to install this module as a Hubot dependency
npm install hubot-code-review --save
Confirm that hubot-code-review appears as a dependency in your Hubot package.json file.
"dependencies": {
...
"hubot-code-review": "*",
...
}
To enable the script, add the hubot-code-review entry to the external-scripts.json file (you may need to create this file).
[
...
"hubot-code-review",
...
]
Configuration
Code review queuing and notifications will work out of the box, but magic like file type lookups or DMs when your PR is approved/rejected require 2 things:
- Create a
hubot-code-review
webhook in GitHub so that Hubot can notice any changes
- Set Environmental variables:
-
If
HUBOT_GITHUB_TOKEN
is set, Hubot can query the GitHub api for file type information on PR submission. Check out the instructions for configuringHUBOT_GITHUB_TOKEN
for hubot-code-review -
Set
HUBOT_CODE_REVIEW_REMINDER_MINUTES
to customize the number of minutes between pending code review prompts during the first hour of inactivity (the default is 5, and the effective max is 60). Note that hourly reminders will still take effect after the first 60 minutes. -
Set
HUBOT_CODE_REVIEW_KARMA_DISABLED
totrue
to prevent Hubot from listening for any code review karma commands. -
HUBOT_CODE_REVIEW_EMOJI_APPROVE
an Alley Interactive cultural relic before the days GitHub incorporated pull request reviews. If this variable istrue
, a comment on the PR that includes one or more emoji conveys PR approval and will DM the submitter accordingly.
Usage
hubot help crs
- See a help document explaining how to use.
{GitHub pull request URL} [@user] Add PR to queue and (optionally) notify @user or #channel
[hubot ]on it Claim the oldest _new_ PR in the queue
[hubot ]userName is on it Tell hubot that userName has claimed the oldest _new_ PR in the queue
on * Claim all _new_ PRs
[userName is ]on cool-repo/123 Claim cool-repo/123 if no one else has claimed it
[userName is ]on cool Claim a _new_ PR whose slug matches cool
hubot (nm|ignore) cool-repo/123 Delete cool-repo/123 from queue regardless of status
hubot (nm|ignore) cool Delete most recently added PR whose slug matches cool
hubot (nm|ignore) Delete most recently added PR from the queue regardless of status
hubot redo cool-repo/123 Allow another review _without_ decrementing previous reviewer's score
hubot (unclaim|reset) cool-repo/123 Reset CR status to new/unclaimed _and_ decrement reviewer's score
hubot list crs List all _unclaimed_ CRs in the queue
hubot list [status] crs List CRs with matching optional status
Note that some commands require direct @hubot, some don't, and some work either way.
Code review statuses
new PR has just been added to the queue, no one is on it.
claimed Someone is on this PR
approved PR was approved. Requires GitHub webhook.
merged PR was merged and closed. Requires GitHub webhook.
closed PR was closed without merging. Requires GitHub webhook.