diff --git a/.danger/pr_detekt.df.kts b/.danger/pr_detekt.df.kts new file mode 100644 index 000000000..fc502fff6 --- /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.plugin +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