Skip to content

Commit

Permalink
Add rule to notify if the API file was updated (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
OptimumCode authored Jun 27, 2024
1 parent 5cfb6b4 commit bc7121e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Dangerfile.df.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
@file:Suppress("ktlint:standard:no-wildcard-imports")

import systems.danger.kotlin.*
import systems.danger.kotlin.models.github.GitHubIssueLabel

danger(args) {
if (git.modifiedFiles.any { it.contains("json-schema-validator/api/") }) {
markdown(
"## PR introduces changes to the public API\n" +
"Please add **\"ABI breaking\"** label if **any line** in API file was changed or deleted.<br/>" +
"Please add **\"API breaking\"** label if **any public method** in API file was changed or deleted.",
)
}
onGitHub {
val prLabels = issue.labels
when (prLabels.size) {
0 -> fail("PR must have labels")
1 ->
prLabels.find { it.name.equals("ignore", ignoreCase = true) }?.let {
warn("PR must have labels other then '[${it.name}](${it.url})'")
}
else -> {}
}
checkPrLabels(prLabels)
}
}

fun checkPrLabels(prLabels: List<GitHubIssueLabel>) {
when (prLabels.size) {
0 -> fail("PR must have labels")
1 ->
prLabels.find { it.name.equals("ignore", ignoreCase = true) }?.let {
warn("PR must have labels other then '[${it.name}](${it.url})'")
}

else -> {}
}
}

0 comments on commit bc7121e

Please sign in to comment.