Skip to content

indigotech/danger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 

Repository files navigation

danger-taqtile

Danger base file for Taqtile projects

Instalation

On your project root folder:

  1. Create a Gemfile with
source "https://rubygems.org"
gem "danger", "4.2.1"
  1. Execute $ bundle install
  2. Create a Dangerfile with
@platform = "nodejs" # Possible platforms are "nodejs", "ios", "android" and "web"
danger.import_dangerfile(github: "indigotech/danger")

Usage Locally

Setup

To execute Danger on your project referencing a local file instead of Github you can use the following command

danger.import_dangerfile(path: "/absolute/path/to/your/Dangerfile-folder")

Execution

There are currently two ways of working with your dangerfile locally

  1. Run danger locally against a PR on github
$ bundle exec danger pr <link to github PR>
  1. Run danger locally against the last merged PR on the current branch. Please note that Danger detects the last merged PR, and not the last merge. So you'll need to have a PR setup on github anyways.
$ bundle exec danger local

Usage on CI

  1. Add angithub access token as DANGER_GITHUB_API_TOKEN environment variable to enable Danger to access Github PR and add comments.
  • If you already have a token variable you can use something like the following:
export DANGER_GITHUB_API_TOKEN=$YOUR_CURRENT_GITHUB_TOKEN_VARIABLE
  1. To execute on CI, add the following command preferably before building your code and after the environment variable was defined.
$ bundle exec danger --dangerfile=path/to/Dangerfile

What is currently being checked

Common

  • Warn if some files/folders to be changed/committed like .gitignore, Gemfile, Gemfile.lock, .travis.yml
  • >>> Strings to make sure rebase was successful
  • Big PRs
  • Warn when Gemfile was modified and Gemfile.lock was not
  • Fail when no description is provided
  • Warn when Amazon Secret Key is hardcoded
  • Warn when Dangerfile was modified
  • Warn when http:// is used

Node

  • Warn if some files/folders to be changed/committed like yarn.lock, docker-compose.yml, Procfile, npm-shrinkwrap.json, node_modules, env.coffee
  • Warn when npm install -g is used
  • Warn when .env or .nvmrc files are modified
  • Warn when console.log is added
  • Warn when package.json was modified and yarn.lock or shrinkwrap was not
  • Warn if node version is different between .travis.yml, .nvmrc, package.json and README (or just warn if node version has change just in one of these locations)
  • At packages.json every package should have its version fixed (do not use ^ or ~), or explicitly set the major and minor versions (ie.: 1.2.x)
  • [TypeScript] Warn if using <any> as return type.

iOS

  • Warn if some files/folders to be changed/committed like Cakefile, settings.yml.erb, Fastfile
  • Warn when Podfile was modified and Podfile.lock was not
  • Warn if changes made in Cakefile may 'break' provisionings and sign certificates configurations
  • Warn when ATS Exception is set in plist
  • Warn when Landscape orientation is set in plist
  • Warn when Facebook ID is hardcoded in plist
  • Warn when pod is being loaded from external git repos
  • Warn when TODO is added
  • Warn when print(“”) is added
  • Warn when fatalError is added
  • Warn if Podfile has pods should not using fixed versions
  • [Swift] Warn if forced unwrapping was found
  • Warn if hardcoded font is used in .xib
  • Warn if hardcoded color is used in .xib

Android

  • Warn when .gradle or Manifest.xml files are modified

Web

  • Warn if some files/folders to be changed/committed like yarn.lock, docker-compose.yml, Procfile, npm-shrinkwrap.json, node_modules, env.coffee
  • Warn when npm install -g is used
  • Warn when .env or .nvmrc files are modified
  • Warn when console.log is added
  • Warn when package.json was modified and yarn.lock or shrinkwrap was not
  • Warn if node version is different between .travis.yml, .nvmrc, package.json and README (or just warn if node version has change just in one of these locations)
  • At packages.json every package should have its version fixed (do not use ^ or ~), or explicitly set the major and minor versions (ie.: 1.2.x)
  • [TypeScript] Warn if using <any> as return type.
  • Warn if CSS files were changed

Troubleshooting

It is asking me for a DANGER_GITHUB_API_TOKEN

Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through DANGER_GITHUB_API_TOKEN environment variable.

  1. Create a github Personal Access Token
  2. Export it to an environment variable
$ export DANGER_GITHUB_API_TOKEN=your token here