-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rule to notify if the API file was updated (#147)
- Loading branch information
1 parent
5cfb6b4
commit bc7121e
Showing
1 changed file
with
21 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -> {} | ||
} | ||
} |