Last active
November 13, 2017 18:23
-
-
Save ruralocity/a01fe5daa345e250a7e5e06a8dfe9e2c to your computer and use it in GitHub Desktop.
Hack to automate style guide reviews during pull requests
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
# Prerequisites: | |
# | |
# * Add pronto, pronto-rubocop, and any other pronto runners to Gemfile's | |
# development group (TODO: how to run using standalone gems?) | |
# Add dotenv to project's Gemfile, if necessary (dotenv-rails includes | |
# it by default) | |
# * Create a GitHub API token: https://github.com/settings/tokens. | |
# Give it the following scopes: repo, repo:status | |
# See this tutorial for more info: | |
# https://christoph.luppri.ch/articles/2017/03/05/how-to-automatically-review-your-prs-for-style-violations-with-pronto-and-rubocop/ | |
class PR < Thor | |
include Thor::Actions | |
# Usage: | |
# Note pull request ID in the GitHub UI or URL | |
# cd path/to/app | |
# git checkout <branch-to-review> | |
# thor pr:review | |
desc "review", "automated code review for style guide issues" | |
def review | |
if (token = ENV["PRONTO_GITHUB_ACCESS_TOKEN"]) | |
puts "PRONTO_GITHUB_ACCESS_TOKEN found in ENV" | |
else | |
token = ask "GitHub access token:" | |
end | |
id = ask "Pull request ID:" | |
base = ask "Base for comparison:", default: "origin/master" | |
run "PRONTO_GITHUB_ACCESS_TOKEN=#{token} PULL_REQUEST_ID=#{id} pronto run -f github_status github_pr -c #{base}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment