diff --git a/.github/workflows/diktat.yml b/.github/workflows/diktat.yml index a3b1015d..bf9775d3 100644 --- a/.github/workflows/diktat.yml +++ b/.github/workflows/diktat.yml @@ -12,18 +12,31 @@ jobs: GRADLE_OPTS: -Dorg.gradle.daemon=false steps: - - uses: actions/checkout@v2.3.3 + - uses: actions/checkout@v2.4.0 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: - java-version: 1.11 - - name: Gradle build with remote cache - uses: burrunan/gradle-cache-action@v1 + java-version: 11 + distribution: zulu + - uses: burrunan/gradle-cache-action@v1 with: - arguments: diktatCheckAll - properties: | - org.gradle.caching=true gradle-version: wrapper # additional files to calculate key for dependency cache gradle-dependencies-cache-key: | buildSrc/**/Versions.kt + arguments: | + diktatCheckAll + properties: | + diktat.githubActions=true + - name: Copy SARIF reports into a single directory + if: ${{ always() }} + # `find` cmd is a workaround for https://github.com/analysis-dev/diktat/issues/1213 + run: | + mkdir -p build/diktat-sarif-reports + i=0 + find . -regex '.*\(/[^/]*\)\1' | while read -r f; do echo "$f -> diktat-$i.sarif" && cp $f build/diktat-sarif-reports/diktat-$i.sarif || echo Cannot copy && echo Copied && i=$((i+1)); done + - name: Upload SARIF report to Github + uses: github/codeql-action/upload-sarif@v1 + if: ${{ always() }} + with: + sarif_file: build/diktat-sarif-reports diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5ac877d5..45e63f22 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,7 +10,7 @@ dependencies { // this hack prevents the following bug: https://github.com/gradle/gradle/issues/9770 implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - implementation("org.cqfn.diktat:diktat-gradle-plugin:1.0.2") + implementation("org.cqfn.diktat:diktat-gradle-plugin:1.0.3") implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0") implementation("io.github.gradle-nexus:publish-plugin:1.1.0") implementation("org.ajoberstar.reckon:reckon-gradle:0.13.0") diff --git a/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/DiktatConfiguration.kt b/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/DiktatConfiguration.kt index 8f080457..cc30bd67 100644 --- a/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/DiktatConfiguration.kt +++ b/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/DiktatConfiguration.kt @@ -17,6 +17,7 @@ fun Project.configureDiktat() { apply() configure { diktatConfigFile = rootProject.file("diktat-analysis.yml") + githubActions = findProperty("diktat.githubActions")?.toString()?.toBoolean() ?: false inputs { include("src/**/*.kt", "*.kts", "src/**/*.kts") exclude("$projectDir/build/**", "src/commonTest/**/*.kt") @@ -33,6 +34,7 @@ fun Project.createDiktatTask() { apply() configure { diktatConfigFile = rootProject.file("diktat-analysis.yml") + githubActions = findProperty("diktat.githubActions")?.toString()?.toBoolean() ?: false inputs { include( "$rootDir/buildSrc/src/**/*.kt",