-
Notifications
You must be signed in to change notification settings - Fork 23
/
dangerfile.ts
30 lines (24 loc) · 1.13 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
import { danger, fail, warn } from "danger"
import * as fs from "fs"
// Setup
const pr = danger.github.pr
const modified = danger.git.modified_files
const newFiles = danger.git.created_files
const bodyAndTitle = (pr.body + pr.title).toLowerCase()
// Custom modifiers for people submitting PRs to be able to say "skip this"
const trivialPR = bodyAndTitle.includes("trivial")
const acceptedNoTests = bodyAndTitle.includes("skip new tests")
const filesOnly = (file: string) => fs.existsSync(file) && fs.lstatSync(file).isFile()
// Custom subsets of known files
const modifiedAppFiles = modified.filter(p => p.includes("lib/")).filter(p => filesOnly(p))
const modifiedTestFiles = modified.filter(p => p.includes("_tests")).filter(p => filesOnly(p))
// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = modified.includes("CHANGELOG.md")
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
fail("No CHANGELOG added.")
}
// No PR is too small to warrant a paragraph or two of summary
if (pr.body.length === 0) {
fail("Please add a description to your PR.")
}