Project

moj-danger

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Add Danger gems
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Danger

Danger runs during our CI process, and lets us ensure our commits, pull requests, and more meet a minimum level of quality.

Gem Version

Setup

Add Danger to your Ministry of Justice Ruby project

  1. Add the following to your Gemfile;
group :development do
  gem 'ministryofjustice-danger'
end
  1. bundle install

  2. Create a Dangerfile that imports the central MoJ Dangerfile

echo "danger.import_dangerfile(github: 'ministryofjustice/danger')" > Dangerfile

Commit and push your changes.

Run Danger via Travis CI

  1. Add Danger to your .travis.yml (use whatever ruby version (>= 2.3.0) is appropriate)
rvm: 2.3.3

script:
  - bundle exec danger

… or add it to your build matrix:

matrix:
  include:
    - rvm: 2.3.3
      script:
        - bundle exec danger

Commit and push the changes.

  1. Add the MoJ Dangerbot API token to Travis;

This assumes your project has already been added to Travis.

https://travis-ci.org/ministryofjustice/[your project]/settings

Add the environment variable DANGER_GITHUB_API_TOKEN, with the value from the password field of the MOJ Danger bot Github API token entry in Rattic.

Danger will now run against every PR which is raised, and will create comments about any errors that it finds (the comments will be removed once the issues are fixed).

Run Danger via CircleCI

Just add bundle exec danger to your circle.yml, either as an extra step in your test overrides, or in a new pre section. You'll need to add the DANGER_GITHUB_API_TOKEN to the environment variables, like with Travis, and Danger recommend setting “only build pull requests” in the advanced settings.

If you're not running Ruby

If Danger is your only Ruby dependency, you probably don't want to have a Gemfile cluttering up your repo. In that case, you can (probably) use this command in the Travis config above:

rbenv global 2.3.1 && gem install ministryofjustice-danger --version '~> 0.1' && danger

Updating the gem

e.g. to add new runtime dependencies

  1. Make your changes to ministryofjustice-danger.gemspec

  2. Update the version in ministryofjustice-danger.gemspec

  3. Build the gem

gem build ministryofjustice-danger.gemspec
  1. Publish to Rubygems
gem push ministryofjustice-danger-[VERSION].gem

Fixing your commits

To keep Danger happy, you will need to amend commits that you have already pushed.

This Github article describes a process for doing this. But, please use --force-with-lease instead of --force when pushing your amendments.