Skip to content

Commit bc7121e

Browse files
authored
Add rule to notify if the API file was updated (#147)
1 parent 5cfb6b4 commit bc7121e

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Dangerfile.df.kts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
@file:Suppress("ktlint:standard:no-wildcard-imports")
22

33
import systems.danger.kotlin.*
4+
import systems.danger.kotlin.models.github.GitHubIssueLabel
45

56
danger(args) {
7+
if (git.modifiedFiles.any { it.contains("json-schema-validator/api/") }) {
8+
markdown(
9+
"## PR introduces changes to the public API\n" +
10+
"Please add **\"ABI breaking\"** label if **any line** in API file was changed or deleted.<br/>" +
11+
"Please add **\"API breaking\"** label if **any public method** in API file was changed or deleted.",
12+
)
13+
}
614
onGitHub {
715
val prLabels = issue.labels
8-
when (prLabels.size) {
9-
0 -> fail("PR must have labels")
10-
1 ->
11-
prLabels.find { it.name.equals("ignore", ignoreCase = true) }?.let {
12-
warn("PR must have labels other then '[${it.name}](${it.url})'")
13-
}
14-
else -> {}
15-
}
16+
checkPrLabels(prLabels)
17+
}
18+
}
19+
20+
fun checkPrLabels(prLabels: List<GitHubIssueLabel>) {
21+
when (prLabels.size) {
22+
0 -> fail("PR must have labels")
23+
1 ->
24+
prLabels.find { it.name.equals("ignore", ignoreCase = true) }?.let {
25+
warn("PR must have labels other then '[${it.name}](${it.url})'")
26+
}
27+
28+
else -> {}
1629
}
1730
}

0 commit comments

Comments
 (0)