Skip to content

Commit 18b0e80

Browse files
committed
[#494] Replace danger-ruby with danger-kotlin
1 parent c6cc06d commit 18b0e80

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

.github/workflows/review_pull_request.yml

+1-24
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,7 @@ jobs:
6969
working-directory: ./template-compose
7070
run: ./gradlew koverMergedXmlReport
7171

72-
- name: Set up Ruby
73-
uses: ruby/setup-ruby@v1
74-
with:
75-
ruby-version: '2.7'
76-
77-
- name: Cache gems
78-
uses: actions/cache@v2
79-
with:
80-
path: vendor/bundle
81-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
82-
restore-keys: |
83-
${{ runner.os }}-gems-
84-
85-
- name: Install Bundle and check environment versions
86-
run: |
87-
echo 'Install Bundle'
88-
bundle config path vendor/bundle
89-
bundle install
90-
echo 'Check environment setup versions'
91-
ruby --version
92-
gem --version
93-
bundler --version
94-
9572
- name: Run Danger
73+
uses: danger/kotlin@1.2.0
9674
env:
9775
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98-
run: bundle exec danger

Dangerfile.df.kts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)