-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDangerfile.df.kts
51 lines (41 loc) · 1.65 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
48
49
50
51
// Copyright (C) 2024 r0adkll
// SPDX-License-Identifier: Apache-2.0
import systems.danger.kotlin.*
danger(args) {
val allSourceFiles = git.modifiedFiles + git.createdFiles
val changelogChanged = allSourceFiles.any { it.contains("CHANGELOG.md") }
val sourceChanges = allSourceFiles.firstOrNull { it.contains("src") }
val testChanges = allSourceFiles.firstOrNull { it.contains("test") }
val isRenovatePr = git.commits.any { it.author.name.contains("renovate") }
onGitHub {
val isTrivial = pullRequest.title.contains("#trivial")
if (isRenovatePr) {
message("Renovate PR - Ignoring checks")
} else {
message("This PR has been checked by Danger")
}
// Changelog
if (!isTrivial && !isRenovatePr && !changelogChanged) {
fail(
"any changes to library code should be reflected in the Changelog.\n\n" +
"Please add your change there and adhere to the " +
"[Changelog Guidelines](https://github.com/Moya/contributors/blob/master/Changelog%20Guidelines.md).",
)
}
// Testing
if (!isRenovatePr && sourceChanges != null && testChanges == null) {
fail("any changes to library code should have accompanied tests. Please add tests to cover your changes.")
}
// Big PR Check
if ((pullRequest.additions ?: 0) - (pullRequest.deletions ?: 0) > 300) {
warn("Big PR, try to keep changes smaller if you can")
}
// Work in progress check
if (pullRequest.title.contains("WIP", false)) {
warn("PR is classed as Work in Progress")
}
if (git.linesOfCode > 500) {
warn("This PR is original Xbox Huge! Consider breaking into smaller PRs")
}
}
}