From 9e0f64814b8e45c14e6c945b6a9eb7e1c4cb8fe5 Mon Sep 17 00:00:00 2001 From: Imre Kaszab Date: Tue, 22 Oct 2024 15:27:16 +0200 Subject: [PATCH] fix: fix kover config --- .github/workflows/PR.yml | 32 +++++++++++---------------- build.gradle.kts | 48 ++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 5eb15f0..4de7a59 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -36,6 +36,17 @@ jobs: env: WORKING_DIRECTORY: ./iosApp + - name: Tests + uses: gradle/gradle-build-action@v2.6.1 + with: + arguments: test + + - name: Kover XML Report + uses: ./.github/actions/kover_report + id: kover_report + with: + artifacts_name: android-test-report + build-android: needs: pre-conditions runs-on: ubuntu-24.04 @@ -57,21 +68,6 @@ jobs: - name: Build run: ./gradlew build --stacktrace - - name: Kover XML Report - uses: ./.github/actions/kover_report - id: kover_report - with: - kover_report_path: ${{ github.workspace }}/composeApp/build/reports/kover/reportDebug.xml - artifacts_name: android-test-report - - - name: Upload Kover Report - if: steps.kover_report.outputs.kover_report_available == 'true' - uses: actions/upload-artifact@v3.1.2 - with: - name: ${{ steps.kover_report.outputs.artifacts_name }} - path: ${{ github.workspace }}/composeApp/build/reports/kover/reportDebug.xml - retention-days: 5 - build-ios: needs: pre-conditions runs-on: macos-14 @@ -110,11 +106,10 @@ jobs: DEVELOPMENT_TEAM=${{ secrets.APPLE_TEAM_ID }} comment-test-report: - needs: [build-android] + needs: [pre-conditions] if: | always() && - github.event_name == 'pull_request' && - needs.build-android.outputs.kover_report_available == 'true' + github.event_name == 'pull_request' runs-on: ubuntu-24.04 permissions: actions: read @@ -126,5 +121,4 @@ jobs: - name: Comment Kover Report to PR uses: ./.github/actions/comment_kover_report_to_pr with: - platform: Android report_name: android-test-report diff --git a/build.gradle.kts b/build.gradle.kts index 472d62c..91b5830 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,6 +47,7 @@ allprojects { ) val koverIncludeList = listOf("*.viewmodel.*", "*.data.service.*") + val koverProjectNames = listOf("data", "viewmodel", "composeApp") extensions.configure { autoCorrect = true @@ -83,38 +84,31 @@ allprojects { tasks.withType().configureEach { jvmTarget = libs.versions.javaTargetCompatibility.get() } - - kover { - currentProject { - instrumentation { - excludedClasses.addAll(koverExcludeList) - } - sources { - excludeJava = true - } - } - reports { - filters { - excludes { classes(koverExcludeList) } - includes { classes(koverIncludeList) } - } - - total { + if (koverProjectNames.any { project.name.contains(it) }) { + kover { + reports { filters { excludes { classes(koverExcludeList) } includes { classes(koverIncludeList) } } - verify { - rule("Minimum coverage verification error") { - disabled = false - groupBy = kotlinx.kover.gradle.plugin.dsl.GroupingEntityType.APPLICATION - bound { - minValue.set(defaultRequiredMinimumCoverage) - maxValue.set(defaultRequiredMaximumCoverage) - coverageUnits.set(CoverageUnit.LINE) - aggregationForGroup = - kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE + total { + filters { + excludes { classes(koverExcludeList) } + includes { classes(koverIncludeList) } + } + verify { + rule("Minimum coverage verification error") { + disabled = false + groupBy = kotlinx.kover.gradle.plugin.dsl.GroupingEntityType.APPLICATION + + bound { + minValue.set(defaultRequiredMinimumCoverage) + maxValue.set(defaultRequiredMaximumCoverage) + coverageUnits.set(CoverageUnit.LINE) + aggregationForGroup = + kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE + } } } }