-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.js
36 lines (29 loc) · 1.25 KB
/
dangerfile.js
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
const { danger, fail, warn } = require('danger')
const _ = require('lodash/fp')
const log = (f, s) => console.log(f.name, s) & f(s)
const changed = {
changelog: _.includes('CHANGELOG.md', danger.git.modified_files),
packageJSON: _.includes('package.json', danger.git.modified_files)
}
// No PR is too small to warrant a paragraph or two of summary
if (danger.github.pr.body.length === 0) {
log(fail, 'Please add a description to your PR.')
}
// Always ensure we assign someone, so that our Slackbot can do its work correctly
if (danger.github.pr.assignee === null) {
log(fail, 'Please assign someone to merge this PR, and optionally include people who should review.')
}
// Requires CHANGELOG entries
if (!changed.changelog) {
log(fail, 'Please add a changelog entry for your changes.')
}
// Requires a version update in package.json
const packageDiff = danger.git.diffForFile('package.json')
if (!changed.packageJSON && packageDiff && packageDiff.includes('version')) {
log(fail, 'Please bump up the version')
}
// Warns when PR size is large
const bigPRThreshold = 600
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
log(warn, `:exclamation: This PR is BIG (+${danger.github.pr.additions} -${danger.github.pr.deletions})`)
}