Movatterモバイル変換


[0]ホーム

URL:


Looking for or?a project fromorta therox,Juanito Fatas
andthe 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 changesif!git.modified_files.include?("CHANGELOG.md")&&has_app_changesfail("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 issuesprose.lint_filesmarkdown_files# Look for spelling issuesprose.ignored_words=["orta","artsy","cocoapods"]prose.check_spellingmarkdown_files
# Ensure a clean commits historyifgit.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 accidentfail("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']ifusername&&project_name&&build_number# submit message giving the coverage report that was generated by coverage.pymessage('[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 specmade_analytics_changes=modified_files.include?("/Artsy/App/ARAppDelegate+Analytics.m")made_analytics_specs_changes=modified_files.include?("/Artsy_Tests/Analytics_Tests/ARAppAnalyticsSpec.m")ifmade_analytics_changesfail("Analytics changes should have reflected specs changes")if!made_analytics_specs_changes# And pay extra attention anywaymessage('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 aDangerfile. You set up aDangerfile per-project. TheDangerfile contains a collection of home-grown rules specific to your project.

Danger should be installed via a Gemfile. Addgem "danger" to your Gemfile, then runbundle.

You canintegrate Danger into your own project on any available CI service. She will run through the process with you if you rundanger 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

SCMFeedbackInline
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 withdanger 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 theproselint 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 disabledprose.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 PRprose.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 ofthem heredefaults 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 numbersas spelling errors. Defaults tofalse, switch it totrueif you wish to ignore numbers.

ignore_acronyms - Allows you to specify that you want to ignore acronyms as spellingerrors. Defaults tofalse, switch it totrue if you wishto ignore acronyms.

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

Methods

lint_files - Lints the globbed markdown files. Will fail ifproselint cannot be installed correctly.Generates amarkdown 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 theAPI Reference as you build out your Dangerfile.

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


[8]ページ先頭

©2009-2025 Movatter.jp