Review Reminder Bot

review-bot sends a reminder message to Mattermost (Slack probably too) with all open pull/merge requests which need an approval. Well suitable for running as a cron-job, e.g. for daily reminders.
This tool is still a beta version. The Gitlab backend is more mature while the Github backend is an early preview.
Installation
go install github.com/sj14/review-bot
Example
Sample Output for Gitlab
How-To: Got reminded? Just normally review the given merge request with π/π or use π΄ if you don't want to receive a reminder about this merge request.
Support SHIELD
1 π¬ 3 π @hulk
Ask Deadpool to join us
3 π¬ 3 π @batman
Repair the Helicarrier
3 π¬ @hulk @batman @groot @iron_man
Find Kingpin
2 π¬ 4 π You got all reviews, @daredevil.
Configuration
The reviewers.json file contains the gitlab_user_id: "@mattermost_name" respectively github_user_name: "@mattermost_name".
{
"5": "@hulk",
"17": "@iron_man",
"92": "@groot",
"95": "@batman",
"123": "@daredevil"
}
Running
Get all open merge requests from the Gitlab project owner/repo and post the resulting reminder to the specified Mattermost channel:
review-bot -host=$GITLAB_HOST -token=$GITLAB_API_TOKEN -repo=owner/repo -webhook=$WEBHOOK_ADDRESS -channel=$MATTERMOST_CHANNEL
Command Line Flags
-channel string
Mattermost channel (e.g. MyChannel) or user (e.g. @AnyUser)
-host string
host address (e.g. github.com, gitlab.com or self-hosted gitlab url
-repo string
repository (format: 'owner/repo'), or project id (only gitlab)
-reviewers string
path to the reviewers file (default "examples/reviewers.json")
-template string
path to the template file
-token string
host API token
-webhook string
Mattermost webhook URL
Templates
We use the Go template package for parsing.
Depending on which backend you use, there are different fields you can use. Check the examples folder for a quick overview.
Gitlab
Accessing {{.Project}} gives you access to these fields.
While {{range .Reminders}} gives you access to {{.MR}} which is the merge request. {{.Missing}} is the Slack/Mattermost handle of the missing reviewer. {{.Discussions}} is the number of open discussion. {{.Owner}} is the Mattermost name of the assignee or otherwise the creator of the merge request. {{.Emojis}} is a map with the reacted emoji's and their count on this merge request.
The corresponding Go structs:
type data struct {
Project gitlab.Project
Reminders []reminder
}
type reminder struct {
MR *gitlab.MergeRequest
Missing []string
Discussions int
Owner string
Emojis map[string]int
}
Github
Accessing {{.Repository}} gives you access to these fields.
While {{range .Reminders}} gives you access to {{.PR}} which is the pull request. {{.Owner}} the Mattermost name of the PR creator or the Github login as fallback. {{.Missing}} is the Slack/Mattermost handle of the missing reviewer.
type data struct {
Repository *github.Repository
Reminders []reminder
}
type reminder struct {
PR *github.PullRequest
Missing []string
Owner string
}