Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit f1b50f8

Browse files
committed
Add Danger
1 parent 679f310 commit f1b50f8

8 files changed

+1518
-46
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ test-extend.js
2626
stats.json
2727
iris/.env
2828
.expo
29-
mobile/.expo
29+
mobile/.expo
30+
test-results.json

dangerfile.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// @flow
2+
import path from 'path';
3+
import { warn, fail, message, markdown, schedule, danger } from 'danger';
4+
import yarn from 'danger-plugin-yarn';
5+
import jest from 'danger-plugin-jest';
6+
import noTestShortcuts from 'danger-plugin-no-test-shortcuts';
7+
8+
const APP_FOLDERS = [
9+
'admin',
10+
'athena',
11+
'chronos',
12+
'hermes',
13+
'hyperion',
14+
'iris',
15+
'mercury',
16+
'shared',
17+
'src',
18+
'vulcan',
19+
];
20+
const CHECKBOXES = /^- \[[x]] *(.*)?$/gim;
21+
const possibleAutoLabels = {
22+
wip: 'WIP: Building',
23+
'needs testing': 'WIP: Needs Testing',
24+
'ready for review': 'WIP: Ready for Review',
25+
};
26+
27+
// Make sure people describe what their PR is about
28+
if (danger.github.pr.body.length < 10) {
29+
fail('Please add a description to your PR.');
30+
}
31+
32+
// Add automatic labels to the PR
33+
schedule(async () => {
34+
const pr = danger.github.pr;
35+
const api = danger.github.api;
36+
const checkedBoxes = pr.body.match(CHECKBOXES);
37+
if (!checkedBoxes || checkedBoxes.length === 0) return;
38+
39+
const matches = checkedBoxes.map(result => result[1]);
40+
41+
const matchingLabels = matches.filter(match =>
42+
Object.keys(possibleAutoLabels).includes(match.toLowerCase())
43+
);
44+
45+
if (!matchingLabels || matchingLabels.length === 0) return;
46+
47+
await api.issues.addLabels({
48+
owner: pr.owner,
49+
repo: pr.repo,
50+
number: pr.number,
51+
labels: matchingLabels,
52+
});
53+
});
54+
55+
// Make sure the yarn.lock file is updated when dependencies get added and log any added dependencies
56+
APP_FOLDERS.forEach(folder => {
57+
schedule(yarn(path.join(__dirname, folder, 'package.json')));
58+
});
59+
60+
// Log test failures if there are any
61+
jest();
62+
63+
// Make sure nobody does a it.only and blocks our entire test-suite from running
64+
noTestShortcuts({
65+
predicate: filePath => filePath.endsWith('.test.js'),
66+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// flow-typed signature: 0bc9953088789fa140d0772a738d8153
2+
// flow-typed version: <<STUB>>/danger-plugin-jest_v^1.1.0/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'danger-plugin-jest'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'danger-plugin-jest' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'danger-plugin-jest/dist/index' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'danger-plugin-jest/dist/types' {
30+
declare module.exports: any;
31+
}
32+
33+
// Filename aliases
34+
declare module 'danger-plugin-jest/dist/index.js' {
35+
declare module.exports: $Exports<'danger-plugin-jest/dist/index'>;
36+
}
37+
declare module 'danger-plugin-jest/dist/types.js' {
38+
declare module.exports: $Exports<'danger-plugin-jest/dist/types'>;
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// flow-typed signature: 6eac443fa8195b12d311468f9d3dfcb8
2+
// flow-typed version: <<STUB>>/danger-plugin-no-test-shortcuts_v^2.0.0/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'danger-plugin-no-test-shortcuts'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'danger-plugin-no-test-shortcuts' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'danger-plugin-no-test-shortcuts/dist/index' {
26+
declare module.exports: any;
27+
}
28+
29+
// Filename aliases
30+
declare module 'danger-plugin-no-test-shortcuts/dist/index.js' {
31+
declare module.exports: $Exports<'danger-plugin-no-test-shortcuts/dist/index'>;
32+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// flow-typed signature: 7b69917a67b22d12810ba89bc8ffdec2
2+
// flow-typed version: <<STUB>>/danger-plugin-yarn_v^1.2.1/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'danger-plugin-yarn'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'danger-plugin-yarn' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'danger-plugin-yarn/dist/danger-mock' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'danger-plugin-yarn/dist/index' {
30+
declare module.exports: any;
31+
}
32+
33+
declare module 'danger-plugin-yarn/dist/index.test' {
34+
declare module.exports: any;
35+
}
36+
37+
// Filename aliases
38+
declare module 'danger-plugin-yarn/dist/danger-mock.js' {
39+
declare module.exports: $Exports<'danger-plugin-yarn/dist/danger-mock'>;
40+
}
41+
declare module 'danger-plugin-yarn/dist/index.js' {
42+
declare module.exports: $Exports<'danger-plugin-yarn/dist/index'>;
43+
}
44+
declare module 'danger-plugin-yarn/dist/index.test.js' {
45+
declare module.exports: $Exports<'danger-plugin-yarn/dist/index.test'>;
46+
}

0 commit comments

Comments
 (0)