Skip to content

Commit 2818dbf

Browse files
RBusarowkodiakhq[bot]
authored andcommitted
add Detekt's SARIF reports to CI
1 parent de16cdc commit 2818dbf

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,21 @@ jobs:
7777
fetch-depth: 0
7878

7979
- name: Set up JDK
80-
uses : actions/setup-java@v2
81-
with :
82-
distribution : 'adopt'
83-
java-version : '11'
80+
uses: actions/setup-java@v2
81+
with:
82+
distribution: 'adopt'
83+
java-version: '11'
8484
cache: 'gradle'
8585

8686
- name: detekt
8787
run: ./gradlew detekt --no-daemon
8888

89+
- name: Upload SARIF to Github using the upload-sarif action
90+
uses: github/codeql-action/upload-sarif@v1
91+
if: success() || failure()
92+
with:
93+
sarif_file: build/reports/detekt/merged.sarif
94+
8995
ktlint:
9096

9197
runs-on: ubuntu-latest

build-logic/mcbuild/src/main/kotlin/mcbuild.detekt.gradle.kts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,36 @@
1414
*/
1515

1616
import io.gitlab.arturbosch.detekt.Detekt
17+
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
1718

1819
plugins {
1920
id("io.gitlab.arturbosch.detekt")
2021
}
2122

23+
val reportMerge by tasks.registering(ReportMergeTask::class) {
24+
output.set(rootProject.buildDir.resolve("reports/detekt/merged.sarif"))
25+
}
26+
2227
detekt {
2328

2429
parallel = true
2530
config = files("$rootDir/detekt/detekt-config.yml")
2631
buildUponDefaultConfig = true
2732
}
2833

29-
tasks.withType<Detekt> {
34+
tasks.withType<Detekt> detekt@{
35+
36+
finalizedBy(reportMerge)
37+
38+
reportMerge.configure {
39+
input.from(this@detekt.sarifReportFile)
40+
}
3041

3142
reports {
3243
xml.required.set(true)
3344
html.required.set(true)
3445
txt.required.set(false)
46+
sarif.required.set(true)
3547
}
3648

3749
setSource(files(projectDir))

0 commit comments

Comments
 (0)