Skip to content

Commit

Permalink
add Detekt's SARIF reports to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
RBusarow authored and kodiakhq[bot] committed Apr 28, 2022
1 parent de16cdc commit 2818dbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,21 @@ jobs:
fetch-depth: 0

- name: Set up JDK
uses : actions/setup-java@v2
with :
distribution : 'adopt'
java-version : '11'
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
cache: 'gradle'

- name: detekt
run: ./gradlew detekt --no-daemon

- name: Upload SARIF to Github using the upload-sarif action
uses: github/codeql-action/upload-sarif@v1
if: success() || failure()
with:
sarif_file: build/reports/detekt/merged.sarif

ktlint:

runs-on: ubuntu-latest
Expand Down
14 changes: 13 additions & 1 deletion build-logic/mcbuild/src/main/kotlin/mcbuild.detekt.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,36 @@
*/

import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.report.ReportMergeTask

plugins {
id("io.gitlab.arturbosch.detekt")
}

val reportMerge by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.buildDir.resolve("reports/detekt/merged.sarif"))
}

detekt {

parallel = true
config = files("$rootDir/detekt/detekt-config.yml")
buildUponDefaultConfig = true
}

tasks.withType<Detekt> {
tasks.withType<Detekt> detekt@{

finalizedBy(reportMerge)

reportMerge.configure {
input.from(this@detekt.sarifReportFile)
}

reports {
xml.required.set(true)
html.required.set(true)
txt.required.set(false)
sarif.required.set(true)
}

setSource(files(projectDir))
Expand Down

0 comments on commit 2818dbf

Please sign in to comment.