Looking for or ?a project from orta therox, Juanito Fatas
and the Danger org contributors.

Danger

Danger title image

What is Danger?

Danger runs during your CI process, and gives teams the chance to automate common code review chores.

This provides another logical step in your build, through this Danger can help lint your rote tasks in daily code review.

You can use Danger to codify your teams norms. Leaving humans to think about harder problems.

She does this by leaving messages inside your PRs based on rules that you create with the Ruby scripting language.

Over time, as rules are adhered to, the message is amended to reflect the current state of the code review.

For Example

# Add a CHANGELOG entry for app changes
if !git.modified_files.include?("CHANGELOG.md") && has_app_changes
  fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/realm/jazzy/blob/master/CHANGELOG.md).")
  message "Note, we hard-wrap at 80 chars and use 2 spaces after the last line."
end
# Look for prose issues
prose.lint_files markdown_files

# Look for spelling issues
prose.ignored_words = ["orta", "artsy", "cocoapods"]
prose.check_spelling markdown_files
# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch/ }
  fail('Please rebase to get rid of the merge commits in this PR')
end
# Don't let testing shortcuts get into master by accident
fail("fit left in tests") if `grep -r "fit" Demo/Tests/`.length > 1
username = ENV['CIRCLE_PROJECT_USERNAME']
project_name = ENV['CIRCLE_PROJECT_REPONAME']
build_number = ENV['CIRCLE_BUILD_NUM']
if username && project_name && build_number
  # submit message giving the coverage report that was generated by coverage.py
  message('[html coverage report](https://circleci.com/api/v1/project/'+username+'/'+project_name+'/'+build_number+'/artifacts/0/$CIRCLE_ARTIFACTS/htmlcov/index.html)')
end
# Did you make analytics changes? Well you should also include a change to our analytics spec
made_analytics_changes = modified_files.include?("/Artsy/App/ARAppDelegate+Analytics.m")
made_analytics_specs_changes = modified_files.include?("/Artsy_Tests/Analytics_Tests/ARAppAnalyticsSpec.m")
if made_analytics_changes
    fail("Analytics changes should have reflected specs changes") if !made_analytics_specs_changes

    # And pay extra attention anyway
    message('Analytics dict changed, double check for ?: `@""` on new entries')
    message('Also, double check the [Analytics Eigen schema](https://docs.google.com/spreadsheets/u/1/d/1bLbeOgVFaWzLSjxLOBDNOKs757-zBGoLSM1lIz3OPiI/edit#gid=497747862) if the changes are non-trivial.')
end

What magic is this?

How

Danger is ruby gem that runs a Dangerfile. You set up a Dangerfile per-project. The Dangerfile contains a collection of home-grown rules specific to your project.

Danger should be installed via a Gemfile. Add gem "danger" to your Gemfile, then run bundle.

You can integrate Danger into your own project on any available CI service. She will run through the process with you if you run danger init after installation.

Messaging Options

Comment a message to the table:
message("You have added 3 more gems to the app.")

Declares a CI warning:
warn("You have not included a CHANGELOG entry.")

Declares a CI blocking error:
fail("Our linter has failed.")

Outputs markdown under the table:
markdown("## ")

Outputs markdown at a line in the diff:
warn("Please add your name", file: "CHANGELOG.md", line: 4)

Supports

Can run on: Circle, Travis, Jenkins, Buildkite, BuddyBuild, Semaphore, TeamCity, Xcode Bots, Drone, Surf and Bitrise.

Can chat back on: GitHub, GitLab and Bitbucket.

Can handle diffs from: Git.

Features

SCM Feedback Inline
Comments
API
Access
GitHub
GitHub Enterprise
GitLab.com
GitLab CE
GitLab EE
Bitbucket.org 🚫 🚫 🚫
Bitbucket Server 🚫 🚫
VSTS 🚫 🚫

Plugins

Danger was built to be a small core, which allows others to extend her DSL via gems as plugins. You can create a new one with danger plugins create.

danger-prose

A description of danger-prose.

Installation

As a pre-requisite, danger-prose requires a node environment for spell checking and a python environment for linting. So, make sure your CI environment has support for either or both of those.

$ gem install danger-prose

prose

Lint markdown files inside your projects. This is done using the proselint python egg. Results are passed out as a table in markdown.

Running linter with custom disabled linters
# Runs a linter with comma style and tense present disabled
prose.disable_linters = ["misc.scare_quotes", "misc.tense_present"]
prose.lint_files "_posts/*.md"
Running linter with default linters
# Runs a linter with all styles, on modified and added markdown files in this PR
prose.lint_files
Running the spell checker
# Runs a spell checker on all files in `_post`
prose.check_spelling "_posts/*.md"
Running the spell checker, with some words whitelisted
prose.ignored_words = ["orta", "artsy"]
prose.check_spelling

Attributes

disable_linters - Allows you to disable a collection of linters from running. Doesn't work yet. You can get a list of them here defaults to ["misc.scare_quotes", "typography.symbols"] when it's nil.

ignored_words - Allows you to add a collection of words to skip in spellchecking. defaults to [""] when it's nil.

ignore_numbers - Allows you to specify that you want to ignore reporting numbers as spelling errors. Defaults to false, switch it to true if you wish to ignore numbers.

ignore_acronyms - Allows you to specify that you want to ignore acronyms as spelling errors. Defaults to false, switch it to true if you wish to ignore acronyms.

language - Allows you to specify dictionary language to use for spell-checking. Defaults to en-gb, switch to en-us, en-au or es-es, to override.

Methods

lint_files - Lints the globbed markdown files. Will fail if proselint cannot be installed correctly. Generates a markdown list of warnings for the prose in a corpus of .markdown and .md files.

proselint_installed? - Determine if proselint is currently installed in the system paths.

mdspell_installed? - Determine if mdspell is currently installed in the system paths.

check_spelling - Runs a markdown-specific spell checker, against a corpus of .markdown and .md files.

Show me some Dangerfiles

Danger is used in all sorts of projects: ruby gems, python apps, xcode projects, blogs, npm websites and modules. You can check out some Dangerfiles from the Open Source community here.

Lets do it

Your first step should probably be to “Getting Set Up”, then move on to the API Reference as you build out your Dangerfile.

If you come up with any novel uses for Danger, please tweet @orta - and make a plugin so everyone can try it.