forked from tapexyz/tape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.ts
40 lines (35 loc) · 1.33 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
import { danger, warn, markdown, message, fail } from 'danger'
// No PR is too small to include a description of why you made a change
if (danger.github.pr.body.length < 10) {
warn('Please include a description of your PR changes.')
}
// Keep Lockfile up to date
const packageChanged = danger.git.modified_files.includes('package.json')
const lockfileChanged = danger.git.modified_files.includes('yarn.lock')
if (packageChanged && !lockfileChanged) {
const msg = 'Changes were made to package.json, but not to yarn.lock'
const idea = 'Perhaps you need to run `yarn install`?'
warn(`${msg} - <i>${idea}</i>`)
}
// Warn when there is a big PR
const bigPRThreshold = 500
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(':exclamation: Big PR')
markdown(
'> Pull Request size seems relatively large. If PR contains multiple changes, split each into separate PRs for faster, easier reviews.'
)
}
// Congratulate when code was deleted
if (danger.github.pr.additions < danger.github.pr.deletions) {
message(
`✂️ Thanks for removing ${
danger.github.pr.deletions - danger.github.pr.additions
} lines!`
)
}
// Always ensure we assign someone
if (danger.github.pr.assignee === null) {
fail(
'Please assign someone to merge this PR, and optionally include people who should review.'
)
}