From 09ad3c10c6509db740108e8d317f71f2c3ba9832 Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Tue, 25 Jun 2024 15:32:43 +1000 Subject: [PATCH] feat(ci): add danger-detekt integration --- .danger/pr_detekt.df.kts | 24 ++++++++++++++++++++++++ .github/workflows/pr-checks.yml | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) 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 00000000..b4f4f448 --- /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.* +import systems.danger.kotlin.models.github.* +import io.github.vacxe.danger.kotlin.detekt.* +import java.io.File + +val detektPlugin = DetektPlugin { it.removePrefix("/home/runner/work/Kakao/Kakao/") } +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/pr-checks.yml b/.github/workflows/pr-checks.yml index 54964f4e..01ad02d3 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -11,9 +11,24 @@ jobs: with: distribution: "temurin" java-version: 17 + cache: gradle - name: detekt run: | ./gradlew clean detekt + - name: Upload Detekt Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: detektArtifacts + path: build/reports/detekt + - name: 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" assemble-debug-apk: needs: [ detekt ] @@ -26,6 +41,7 @@ jobs: with: distribution: "temurin" java-version: 17 + cache: gradle - name: Assemble Debug APK run: bash ./gradlew sample:assembleDebug - name: Upload app APK @@ -45,6 +61,7 @@ jobs: with: distribution: "temurin" java-version: 17 + cache: gradle - name: Assemble Instrumental APK run: bash ./gradlew sample:assembleDebugAndroidTest - name: Upload app APK