Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add danger to start automating some code review tasks #1251

Merged
merged 5 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ script:
- npm run lint
- npm run test -- --coverage
- npm run coverage
- npm run danger
git:
depth: 1
env:
global:
- CXX=g++-4.8
- secure: cAde4wBX75KtTWcyOOLAG3Z9ODdqvmbkL7+8fVNj/+QkZZWE8pFa3deaTIHF9NyVO2h6/jutSkzmsz/nOyBYVPHhGsxBTmsyXoko48Wg+iNm7epoH5uts/kmAPiwpzaWGXwuiAvsOGZjYYFzM335jyaOAcZW3f0C5gIJ5XCCdWBQRaFFLq+ZLKsLSME6xTfV2OMVH24hxXvbF9wvO0aj6p/GaT0cS8Rpg4sQ9eeih2IM/uLiqWzp9UUM2m8SUiFfveqYJFkBtzqAus9pbwsoQjnAT5e3CKJUpPiruCAe5FOt57Hl+mH1N1xqP1ei8j2ZNF+E6zuDdAcMpArTIMM69L+D7wzJYDoF2PuF+jeet7ytAFxSgnZHSTsBJn5cZMPh2tuX7aWwgrpMknVe3bdoINwkyVCaIW+Ur6vc37l/Kuw25eiMBtRDyMhUf4V3FAFi3PV1XKn+34cR4kvpOHt6vk8v5CobBHfQdwU+6FMZMo3GFIkDBcLydLn3WLQ3jKa4OcLqWws6o85k+bHZkLhlADjbiX/PzG23D+sT7Inzj//Tef93SIL02yN+ooZdIUtDus3+qZzhcSrDeSb2octjLXRzPiGn5cFNI86HVcu7qF0+4zCPconhM4+mfAh5S19fmnRdTQctQQxbsObuT9jcMvgJdhIX89aA7Ry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BhUgmUW5KPH4v73mLUlHroywQUU3iiMiCvVMmTd5Xy0o0X0ks5mvXAXWHTmnQkvPyy/V6cwcUfgJC5k3M/V1hDCRMeMVPZsmh73lZffwpAkfx3xJsNf46f7h9aN9Q++danf9JryoS9YsdRBtjfJTtNaO2uH+iUMNSNzAbJmgxtsi3NuX+G+2N02mtaUCzN/SOmKKoZsuPfKVcpHgVa41mgio6QJs7wy9/VWYYASNZddj2HnvLGLBLnJpv+uKKpdSB0Xe6k8dOl1MbaWJT4Xy0/NUD3gawLCvhfN9qL0+QnlJAXCbOoms6EoAyc6fY=
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-4.8
26 changes: 26 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { fail, danger } from 'danger';
import { flatten, intersection, isEmpty, includes } from 'lodash';

const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import
const prLogConfig = pkg['pr-log'];

const checkRequiredLabels = labels => {
const requiredLabels = flatten([
prLogConfig.skipLabels || [],
Object.keys(prLogConfig.validLabels || {}),
]);

if (includes(labels, 'do not merge')) {
fail('PR is marked with "do not merge" label.');
}

const foundLabels = intersection(requiredLabels, labels);
if (isEmpty(foundLabels)) {
fail(`PR is not labeled with one of: ${JSON.stringify(requiredLabels)}`);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, but only if you consider that an org contributor can set labels - so an OSS contribution wouldn't be able to do this - so it might be worth changing it to warn ( or to check whether the PR author is in the storybooks org )

};

if (prLogConfig) {
const { labels } = danger.github.issue;
checkRequiredLabels(labels.map(l => l.name));
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"changelog": "pr-log --sloppy",
"precommit": "lint-staged",
"coverage": "codecov",
"danger": "danger",
"dev": "lerna exec --parallel -- babel src -d dist --ignore tests,__tests__,test.js,stories/,story.jsx --plugins \"transform-runtime\" --copy-files -w",
"docs:build": "cd docs && npm run build",
"docs:deploy:ci": "cd docs && npm run deploy:ci",
Expand All @@ -36,6 +37,7 @@
"babel-preset-stage-0": "^6.24.1",
"chalk": "^1.1.3",
"codecov": "^2.2.0",
"danger": "^0.21.0",
"enzyme": "^2.8.2",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
Expand Down