|
| 1 | +// Dangerfile.df.kts |
| 2 | + |
| 3 | +import io.gitlab.arturbosch.detekt.detekt |
| 4 | +import systems.danger.kotlin.* |
| 5 | + |
| 6 | +// Set up the Danger Kotlin object |
| 7 | +val danger = danger(args) |
| 8 | + |
| 9 | +// Make it more obvious that a PR is a work in progress and shouldn't be merged yet |
| 10 | +if (github.prTitle.contains("WIP")) { |
| 11 | + warn("PR is classed as Work in Progress") |
| 12 | +} |
| 13 | + |
| 14 | +// Warn when there is a big PR |
| 15 | +if (git.linesOfCode > 500) { |
| 16 | + warn("Big PR") |
| 17 | +} |
| 18 | + |
| 19 | +// Warn to encourage a PR description |
| 20 | +if (github.prBody.isEmpty()) { |
| 21 | + warn("Please provide a summary in the PR description to make it easier to review") |
| 22 | +} |
| 23 | + |
| 24 | +// Warn to encourage that labels should have been used on the PR |
| 25 | +if (github.prLabels.isEmpty()) { |
| 26 | + warn("Please add labels to this PR") |
| 27 | +} |
| 28 | + |
| 29 | +// Check commits lint and warn on all checks (instead of failing) |
| 30 | +commitLint.check(warn = CheckSeverity.All, disable = listOf(CheckId.SubjectLength)) |
| 31 | + |
| 32 | +// Detekt output check |
| 33 | +val detektDir = "**/build/reports/detekt/detekt-result.xml" |
| 34 | +detektDir.listFiles().forEach { file -> |
| 35 | + kotlinDetekt.skipGradleTask = true |
| 36 | + kotlinDetekt.reportFile = file |
| 37 | + kotlinDetekt.detekt(inlineMode = true) |
| 38 | +} |
| 39 | + |
| 40 | +// Android Lint output check |
| 41 | +val lintDir = "**/**/build/reports/lint/lint-result.xml" |
| 42 | +lintDir.listFiles().forEach { file -> |
| 43 | + androidLint.skipGradleTask = true |
| 44 | + androidLint.reportFile = file |
| 45 | + androidLint.lint(inlineMode = true) |
| 46 | +} |
| 47 | + |
| 48 | +// Show Danger test coverage report from Kover for templates |
| 49 | +// Report coverage of modified files, warn if total project coverage is under 80% |
| 50 | +// or if any modified file's coverage is under 90% |
| 51 | +val koverFileTemplateXml = "template-xml/build/reports/kover/merged/xml/report.xml" |
| 52 | +markdown("## Kover report for template-xml:") |
| 53 | +shroud.reportKover("Template - XML Unit Tests", koverFileTemplateXml, 80, 95, false) |
| 54 | + |
| 55 | +val koverFileTemplateCompose = "template-compose/build/reports/kover/merged/xml/report.xml" |
| 56 | +markdown("## Kover report for template-compose:") |
| 57 | +shroud.reportKover("Template - Compose Unit Tests", koverFileTemplateCompose, 80, 95, false) |
0 commit comments