Skip to content

Add rule to notify if the API file was updated #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -> {}
}
}
Loading