-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dangerfile.df.kts
47 lines (41 loc) · 2.21 KB
/
Dangerfile.df.kts
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
45
46
47
import systems.danger.kotlin.*
import java.util.Locale
danger(args) {
with(github) {
val labelNames = issue.labels.map { it.name }.toSet()
/*
# --------------------------------------------------------------------------------------------------------------------
# Check if labels were added to the pull request
#--------------------------------------------------------------------------------------------------------------------
*/
val labelsToFilter = setOf("hold", "skip release notes")
val acceptableLabels = labelNames.filter { it !in labelsToFilter }
if(acceptableLabels.isEmpty() && pullRequest.head.ref != "bots/bump-version") {
fail("PR needs labels (hold and skip release notes don't count)")
}
/*
# --------------------------------------------------------------------------------------------------------------------
# Don't merge if there is a WIP or Hold label applied
# --------------------------------------------------------------------------------------------------------------------
*/
if("Hold" in labelNames) fail("This PR cannot be merged with a hold label applied")
/*
# --------------------------------------------------------------------------------------------------------------------
# Check if merge commits were added to the pull request
# --------------------------------------------------------------------------------------------------------------------
*/
val mergeCommitRegex = Regex("^Merge branch '${pullRequest.base.ref}'.*")
if(git.commits.any { it.message.matches(mergeCommitRegex) }) {
fail("Please rebase to get rid of the merge commits in this PR")
}
}
/*
# --------------------------------------------------------------------------------------------------------------------
# Make sure that no crash files or dumps are in the commit
# --------------------------------------------------------------------------------------------------------------------
*/
val touchedFiles = git.createdFiles + git.modifiedFiles
if(touchedFiles.any { it.startsWith("hs_err_pid") || it.startsWith("java_pid") }) {
fail("Please remove any error logs (hs_err_pid*.log) or heap dumps (java_pid*.hprof)")
}
}