A Hubot script for GitHub code review on Slack.
This project is no longer maintained. Alley is no longer using this project internally (we moved all code review workflows onto our other (free) Slack app Helperbot for a more integrated experience).
We are leaving it up for historical purposes. If you are interested in taking over maintenance, please reach out to us.
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:
- Hubot ^3
- hubot-slack ^4
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",
...
]
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 you set
HUBOT_ENTERPRISE_GITHUB_URL
tohttps://<your_enterprise_url>
, Hubot will use it as your enterprise URL instead of the default:https://github.com
-
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 -
HUBOT_CODE_REVIEW_EMOJI_APPROVE
an Alley Interactive cultural relic before the days GitHub incorporated pull request reviews. If this variable istrue
, a comment (excluding acomment.user.type
ofBot
) on the PR that includes one or more emoji conveys PR approval and will DM the submitter accordingly. -
Set
HUBOT_CODE_REVIEW_FILE_EXTENSIONS
to a space separated list of file extensions (default "coffee css html js jsx md php rb scss sh txt yml") to configure what file types you prefer to group together in theHUBOT_CODE_REVIEW_META
information alongside the PR slug in channel. Note that this requires aHUBOT_GITHUB_TOKEN
for hubot-code-review -
Set
HUBOT_CODE_REVIEW_KARMA_DISABLED
totrue
to prevent Hubot from listening for any code review karma commands. -
Set
HUBOT_CODE_REVIEW_KARMA_MONTHLY_AWARD_ROOM
to automatically display a monthly resetting code review leaderboard to a particular room (for more info, check out the code review karma docs) -
Set
HUBOT_CODE_REVIEW_META
to one of [files
,title
,none
,both
(defaultfiles
) ] to configure whether to display the pull request title, file types, or both alongside the PR slug in channel. Note that this requires aHUBOT_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_HOUR_MESSAGE
to customize the message that is displayed for the first-hour warning.
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.