-
Notifications
You must be signed in to change notification settings - Fork 100
/
dangerfile.ts
44 lines (39 loc) · 1.34 KB
/
dangerfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import collectCoverage, { ReportType } from '@instabug/danger-plugin-coverage';
import { danger, fail, schedule, warn } from 'danger';
const hasSourceChanges = danger.git.modified_files.some((file) => file.startsWith('src/'));
const declaredTrivial =
!hasSourceChanges || danger.github.issue.labels.some((label) => label.name === 'trivial');
// Make sure PR has a description.
async function hasDescription() {
const linesOfCode = (await danger.git.linesOfCode()) ?? 0;
const hasNoDiscription = danger.github.pr.body.includes('> Description goes here');
if (hasNoDiscription && linesOfCode > 10) {
fail('Please provide a summary of the changes in the pull request description.');
}
if (!danger.git.modified_files.includes('CHANGELOG.md') && !declaredTrivial) {
warn(
'You have not included a CHANGELOG entry! \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-React-Native/blob/master/CHANGELOG.md).',
);
}
}
schedule(hasDescription());
collectCoverage([
{
label: 'JavaScript',
type: ReportType.LCOV,
filePath: 'coverage/lcov.info',
threshold: 90,
},
{
label: 'Android',
type: ReportType.JACOCO,
filePath: 'coverage/jacocoTestReport.xml',
threshold: 40,
},
{
label: 'iOS',
type: ReportType.XCODE,
filePath: 'coverage/xcode.json',
threshold: 30,
},
]);