From 9d828059f81fb4bb1b4ec155f1b04c8b283d1022 Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Tue, 25 Jun 2024 15:47:56 +1000 Subject: [PATCH 1/3] TECH: add detekt to danger inline comments --- .danger/pr_detekt.df.kts | 24 ++++++++++++++++++++++++ .github/workflows/pull_request.yml | 11 ++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .danger/pr_detekt.df.kts diff --git a/.danger/pr_detekt.df.kts b/.danger/pr_detekt.df.kts new file mode 100644 index 000000000..90b940a07 --- /dev/null +++ b/.danger/pr_detekt.df.kts @@ -0,0 +1,24 @@ +@file:DependsOn("io.github.vacxe.danger.kotlin:detekt:1.1.0") + +import systems.danger.kotlin.danger +import systems.danger.kotlin.warn +import systems.danger.kotlin.register +import io.github.vacxe.danger.kotlin.detekt.DetektPlugin +import java.io.File +val detektPlugin = DetektPlugin { it.removePrefix("/home/runner/work/Kaspresso/Kaspresso/") } +register.plugin(detektPlugin) + +danger(args) { + detektReport() +} + +fun detektReport() { + val detektReportFile = File("build/reports/detekt/detekt.xml") + if (!detektReportFile.exists()) { + warn( + "Detekt report not exist", + ) + } else { + detektPlugin.parseAndReport(detektReportFile) + } +} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c79b85e04..5926888db 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -16,12 +16,21 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: 17 + cache: gradle - name: Run static analysis run: make static_analysis + - name: Detekt to Danger + uses: danger/kotlin@1.3.1 + if: always() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + dangerfile: ".danger/pr_detekt.df.kts" + args: "--failOnErrors --no-publish-check" - name: Run unit tests run: make unit_tests - name: Build project From 86436a356391787bc3c25af7e8dcf81a1fb724bc Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Tue, 25 Jun 2024 15:58:59 +1000 Subject: [PATCH 2/3] TECH: test danger detekt --- .../kaspresso/tutorial/afterlogin/AfterLoginActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/src/main/kotlin/com/kaspersky/kaspresso/tutorial/afterlogin/AfterLoginActivity.kt b/tutorial/src/main/kotlin/com/kaspersky/kaspresso/tutorial/afterlogin/AfterLoginActivity.kt index d2966645f..43fbd3749 100644 --- a/tutorial/src/main/kotlin/com/kaspersky/kaspresso/tutorial/afterlogin/AfterLoginActivity.kt +++ b/tutorial/src/main/kotlin/com/kaspersky/kaspresso/tutorial/afterlogin/AfterLoginActivity.kt @@ -1,6 +1,6 @@ package com.kaspersky.kaspresso.tutorial.afterlogin -import android.os.Bundle +import android.os.* import androidx.appcompat.app.AppCompatActivity import com.kaspersky.kaspresso.tutorial.databinding.ActivityAfterLoginBinding From 476e841c24d9def2fc8580cdc34ab620ea6659ce Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Tue, 25 Jun 2024 16:06:31 +1000 Subject: [PATCH 3/3] TECH: test danger detekt enable xml --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6073dce8d..a910341d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,7 +33,7 @@ val detektAll = tasks.register("detektAll") { exclude("**/resources/**") exclude("**/build/**") reports { - xml.required.set(false) + xml.required.set(true) html.required.set(false) } }