Formalize your Pull Request etiquette.
Note: Not ready for public usage yet - unless you're willing to look inside the codebase. This is a Work in progress, though it is active use on Artsy/Eigen and fastlane/fastlane-core.
Installation • Usage • DSL • Constraints • Advanced • Contributing
Add this line to your application's Gemfile:
gem 'danger'
and then run the following to set up danger
for your repository
danger init
In CI run bundle exec danger
. This will look at your Dangerfile
and provide some feedback based on that.
Danger 🚫 | ||
---|---|---|
✨ | lines_of_code |
The total amount of lines of code in the diff |
✏️ | files_modified |
The list of files modified |
🚢 | files_added |
The list of files added |
♻️ | files_removed |
The list of files removed |
🔤 | pr_title |
The title of the PR |
📖 | pr_body |
The body of the PR |
👥 | pr_author |
The author who submitted the PR |
🔖 | pr_labels |
The labels added to the PR |
You can then create a Dangerfile
like the following:
# Easy checks
warn("PR is classed as Work in Progress") if pr_title.include? "[WIP]"
if lines_of_code > 50 && files_modified.include?("CHANGELOG.yml") == false
fail("No CHANGELOG changes made")
end
# Stop skipping some manual testing
if lines_of_code > 50 && pr_title.include?("📱") == false
fail("Needs testing on a Phone if change is non-trivial")
end
message("This pull request adds #{lines_of_code} new lines")
warn("Author @#{pr_author} is not a contributor") unless ["KrauseFx", "orta"].include?(pr_author)
- GitHub - Built with same-repo PRs in mind
You can access more detailed information by accessing the following variables
Danger 🚫 | |
---|---|
env.request_source.pr_json |
The full JSON for the pull request |
env.scm.diff |
The full GitDiff file for the diff. |
env.ci_source |
To get information like the repo slug or pull request ID |
Using danger local
will look for the last merged pull request in your git history, and apply your current
Dangerfile
against that Pull Request. Useful when editing.
- You can set the base branch in the command line arguments see:
bundle exec danger --help
. - Currently master doesn't work on a Mac without running
brew install cmake
before the installation, it's on my TODO to work around this sometime before the next release.
This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs.