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 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) } } 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