diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07599efb6..da45f38d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,6 +110,8 @@ jobs: unit-test: name: Unit Tests runs-on: ubuntu-latest + permissions: + pull-requests: write env: USERNAME: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -127,10 +129,22 @@ jobs: - name: Run Unit Tests run: > ./gradlew - :pillarbox-analytics:testDebugUnitTest - :pillarbox-core-business:testDebugUnitTest - :pillarbox-player:testDebugUnitTest - :pillarbox-ui:testDebugUnitTest + :pillarbox-analytics:koverXmlReportDebug + :pillarbox-core-business:koverXmlReportDebug + :pillarbox-player:koverXmlReportDebug + :pillarbox-ui:koverXmlReportDebug + - name: Report Code Coverage + if: ${{ github.event_name == 'pull_request' }} + uses: madrapps/jacoco-report@v1.6.1 + with: + paths: ${{ github.workspace }}/**/build/reports/kover/**.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 0 + min-coverage-changed-files: 0 + update-comment: true + title: Code Coverage + pass-emoji: 🟢 + fail-emoji: 🔴 android-tests: name: Android Tests diff --git a/build.gradle.kts b/build.gradle.kts index f3d620cd0..305d8bfb2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,6 +12,7 @@ plugins { alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.detekt) alias(libs.plugins.dependency.analysis.gradle.plugin) + alias(libs.plugins.kotlinx.kover) } apply(plugin = "android-reporting") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 40ac3e88a..3160eaf37 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,10 +21,12 @@ comscore = "6.10.0" dependency-analysis-gradle-plugin = "1.29.0" detekt = "1.23.4" guava = "31.1-android" +jacoco = "0.8.11" json = "20231013" junit = "4.13.2" kotlin = "1.9.22" kotlinx-coroutines = "1.7.3" +kotlinx-kover = "0.7.5" kotlinx-serialization = "1.6.2" ktor = "2.3.7" mockk = "1.13.9" @@ -126,3 +128,4 @@ dependency-analysis-gradle-plugin = { id = "com.autonomousapps.dependency-analys detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kotlinx-kover" } diff --git a/pillarbox-analytics/build.gradle.kts b/pillarbox-analytics/build.gradle.kts index c8fbf63bf..eb5ef7d5a 100644 --- a/pillarbox-analytics/build.gradle.kts +++ b/pillarbox-analytics/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlinx.kover) `maven-publish` } @@ -71,6 +72,10 @@ dependencies { androidTestImplementation(libs.kotlinx.coroutines.test) } +kover { + useJacoco(libs.versions.jacoco.get()) +} + publishing { publications { diff --git a/pillarbox-core-business/build.gradle.kts b/pillarbox-core-business/build.gradle.kts index 45a8edb08..2ba8499de 100644 --- a/pillarbox-core-business/build.gradle.kts +++ b/pillarbox-core-business/build.gradle.kts @@ -6,6 +6,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.kotlinx.kover) `maven-publish` } @@ -86,6 +87,10 @@ dependencies { androidTestImplementation(libs.kotlinx.coroutines.test) } +kover { + useJacoco(libs.versions.jacoco.get()) +} + publishing { publications { register("gpr") { diff --git a/pillarbox-player/build.gradle.kts b/pillarbox-player/build.gradle.kts index ca0be5b0f..6730d5159 100644 --- a/pillarbox-player/build.gradle.kts +++ b/pillarbox-player/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlinx.kover) `maven-publish` } @@ -95,6 +96,10 @@ dependencies { androidTestImplementation(libs.mockk.dsl) } +kover { + useJacoco(libs.versions.jacoco.get()) +} + publishing { publications { register("gpr") { diff --git a/pillarbox-ui/build.gradle.kts b/pillarbox-ui/build.gradle.kts index b39b8fd19..0dbb442e9 100644 --- a/pillarbox-ui/build.gradle.kts +++ b/pillarbox-ui/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlinx.kover) `maven-publish` } @@ -75,6 +76,10 @@ dependencies { debugImplementation(libs.androidx.compose.ui.tooling) } +kover { + useJacoco(libs.versions.jacoco.get()) +} + publishing { publications { register("gpr") {