Pronto runs analysis quickly by checking only the relevant changes. Created to be used on GitHub pull requests, but also works locally and integrates with GitLab and Bitbucket. Perfect if you want to find out quickly if a branch introduces changes that conform to your styleguide, are DRY, don't introduce security holes and more.
This README might be ahead of the latest release. Find the README for v0.8.2 here.
Pronto's installation is standard for a Ruby gem:
$ gem install pronto
You'll also want to install some runners to go along with the main gem:
$ gem install pronto-rubocop
$ gem install pronto-flay
If you'd rather install Pronto using bundler
, you don't need to require it,
unless you're gonna run it from Ruby (via Rake task, for example):
gem 'pronto'
gem 'pronto-rubocop', require: false
gem 'pronto-flay', require: false
Pronto runs the checks on a diff between the current HEAD and the provided commit-ish (default is master).
Navigate to the repository you want to run Pronto on, and:
git checkout feature/branch
# Analyze diff of committed changes on current branch and master:
pronto run
# Analyze changes in git staging area
pronto run --staged
# Analyze diff of uncommitted changes and master:
pronto run --unstaged
# Analyze *all* changes since the *initial* commit (may take some time):
pronto run --commit=$(git log --pretty=format:%H | tail -1)
Just run pronto
without any arguments to see what Pronto is capable of.
Available Options
Command flag | Description |
---|---|
--exit-code |
Exits with non-zero code if there were any warnings/errors. |
-c/--commit |
Commit for the diff. |
--staged |
Analyze changes in git staging area |
--unstaged |
Analyze changes made, but not in git staging area |
-r/--runner |
Run only the passed runners. |
-f/--formatters |
Pick output formatters. |
You can run Pronto as a step of your CI builds and get the results as comments
on GitHub commits using GithubFormatter
or GithubPullRequestFormatter
.
Add Pronto runners you want to use to your Gemfile:
Set the PRONTO_GITHUB_ACCESS_TOKEN environment variable or value in .pronto.yml
to
OAuth token that has access to the repository.
Then just run it:
$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github -c origin/master
or, if you want comments to appear on pull request diff, instead of commit:
$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_pr -c origin/master
Use GithubStatusFormatter
to submit commit status:
$ PRONTO_GITHUB_ACCESS_TOKEN=token pronto run -f github_status -c origin/master
It's possible to combine multiple formatters. To get both pull request comments and commit status summary use:
$ PRONTO_GITHUB_ACCESS_TOKEN=token PULL_REQUEST_ID=id pronto run -f github_status github_pr -c origin/master
As an alternative, you can also set up a rake task:
Pronto::GemNames.new.to_a.each { |gem_name| require "pronto/#{gem_name}" }
formatter = Pronto::Formatter::GithubFormatter.new # or GithubPullRequestFormatter
status_formatter = Pronto::Formatter::GithubStatusFormatter.new
formatters = [formatter, status_formatter]
Pronto.run('origin/master', '.', formatters)
You can run Pronto as a step of your CI builds and get the results as comments
on GitLab commits using GitlabFormatter
.
note: this requires at least GitLab v7.5.0
Set the PRONTO_GITLAB_API_ENDPOINT
environment variable or value in .pronto.yml
to
your API endpoint URL. If you are using Gitlab.com's hosted service your
endpoint will be set by default.
Set the PRONTO_GITLAB_API_PRIVATE_TOKEN
environment variable or value in `.pronto.yml
to your Gitlab private token which you can find in your account settings.
Then just run it:
$ PRONTO_GITLAB_API_PRIVATE_TOKEN=token pronto run -f gitlab -c origin/master
You can run Pronto as a step of your CI builds and get the results as comments
on Bitbucket commits using BitbucketFormatter
or BitbucketPullRequestFormatter
.
Add Pronto runners you want to use to your Gemfile:
Set the PRONTO_BITBUCKET_USERNAME and PRONTO_BITBUCKET_PASSWORD environment variables or values in .pronto.yml
.
.
Then just run it:
$ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket -c origin/master
or, if you want comments to appear on pull request diff, instead of commit:
$ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bitbucket_pr -c origin/master
The behavior of Pronto can be controlled via the .pronto.yml
configuration
file. It must be placed in your project directory.
The file has the following format:
all:
exclude:
- 'spec/**/*'
# exclude files for single runner
eslint:
exclude:
- 'app/assets/**/*'
github:
slug: mmozuras/pronto
access_token: B26354
api_endpoint: https://api.github.com/
web_endpoint: https://github.com/
gitlab:
slug: 1234567 # gitlab's project ID
api_private_token: 46751
api_endpoint: https://api.vinted.com/gitlab
bitbucket:
slug: mmozuras/pronto
username: user
password: pass
web_endpoint: https://bitbucket.org/
max_warnings: 150
verbose: false
All properties that can be specified via .pronto.yml
, can also be specified
via environment variables. Their names will be the upcased path to the property.
For example: PRONTO_GITHUB_SLUG
or PRONTO_GITLAB_API_PRIVATE_TOKEN
. Environment variables
will always take precedence over values in configuration file.
Pronto allows you to configure the format of the messages that are produced. You can set a default format that will be used by all formatters, or you can configure a separate format per formatter, if you are using several.
To change the default format:
format: "%{runner} %{level} %{msg}"
To add the title of the Runner to the GitHub Pull Request formatter only:
github_pr:
format: "%{runner} - %{msg}"
The available values to be interpolated into the message are:
Key | Description |
---|---|
path |
File path. |
line |
Line number. |
level |
Message level. |
msg |
Message. |
commit_sha |
SHA. |
runner |
Runner name. |
The following values are available only to the text formatter:
Key | Description |
---|---|
color_level |
Colorized message level. |
color_location |
Colorized location. |
Pronto can run various tools and libraries, as long as there's a runner for it. Currently available:
- pronto-brakeman
- pronto-coffeelint
- pronto-clippy
- pronto-credo
- pronto-dialyzer
- pronto-dogma
- pronto-eslint (uses eslintrb)
- pronto-eslint_npm (uses eslint installed from npm)
- pronto-fasterer
- pronto-flay
- pronto-foodcritic
- pronto-haml
- pronto-jscs
- pronto-jshint
- pronto-json
- pronto-luacheck
- pronto-perl_lint
- pronto-phpcs
- pronto-phpmd
- pronto-poper
- pronto-rails_best_practices
- pronto-rails_schema
- pronto-reek
- pronto-rubocop
- pronto-scss
- pronto-shellcheck
- pronto-slim
- pronto-slim_lint
- pronto-spell
- pronto-stylelint
- pronto-swiftlint
- pronto-tailor
- pronto-textlint
Articles to help you to get started:
- Automating code review with Pronto (and friends)
- Setup Pronto with CircleCI
- Continuous Static Analysis using Pronto
- Pronto and git hooks
- How to end fruitless dev discussions about your project’s code style?
- Free automated code reviews using Pronto
- Automated Elixir code review with Github, Credo and Travis CI
- Running Rubocop before git commit
- Pronto, Codeship and GitHub for automatic code review
- How to automatically review your PRs for style violations with Pronto and RuboCop
Make a Pull Request to add something you wrote or found useful.
Pronto's changelog is available here.
Copyright (c) 2013-2017 Mindaugas Mozūras. See LICENSE for further details.