Permalink
Browse files

Add DangerJS (#2736)

Add DangerJS
  • Loading branch information...
johnBartos committed Feb 22, 2018
1 parent 2a007d2 commit 7e502400b25fdb201e93d231725a668cecf15b57
Showing with 282 additions and 5 deletions.
  1. +2 −1 .travis.yml
  2. +40 −0 dangerfile.js
  3. +1 −0 package.json
  4. +239 −4 yarn.lock
View
@@ -5,7 +5,8 @@ node_js:
cache: yarn
before_script:
- npm install -g grunt-cli
- yarn global add grunt-cli
- yarn danger ci
script:
- grunt
View
@@ -0,0 +1,40 @@
import { danger, error, message, schedule, warn } from 'danger';
const modifiedFiles = danger.git.modified_files;
const newFiles = danger.git.created_files;
const modifiedSrcFiles = modifiedFiles.filter(file => file.startsWith('src/'));
const modifiedTestFiles = modifiedFiles.filter(file => file.startsWith('test/unit/'));
const newSrcFiles = newFiles.filter(file => file.startsWith('src/'));
const newTestFiles = newFiles.filter(file => file.startsWith('test/unit/'));
const touchedSrcFiles = modifiedSrcFiles.concat(newSrcFiles).length > 0;
const touchedTestFiles = modifiedTestFiles.concat(newTestFiles).length > 0;
const pr = danger.github.pr;
if (touchedSrcFiles) {
if (!touchedTestFiles) {
warn(`🛠 There are modified src files, but no test changes. Add tests if you're able to.`);
}
}
if (!pr.assignees.length && !pr.requested_reviewers.length) {
warn(`🔎 Assign some reviewers or assignees.`);
}
if (!pr.milestone) {
warn(`🗿 Set a milestone. It should be the ticket's fix version in JIRA.`);
}
schedule(async () => {
await checkExactPackageVersion();
});
async function checkExactPackageVersion() {
const diff = await danger.git.diffForFile('package.json');
if (diff && diff.added && diff.added.match(/([\^~])/)) {
error(`🥕 Only save exact versions of a dependency, without a ~ or ^.`);
}
}
View
@@ -16,6 +16,7 @@
"babel-preset-es2015": "6.24.1",
"chai": "4.1.2",
"css-loader": "0.28.7",
"danger": "3.1.7",
"eslint": "4.14.0",
"eslint-plugin-no-for-of-loops": "1.0.0",
"esprima": "4.0.0",
Oops, something went wrong.

0 comments on commit 7e50240

Please sign in to comment.