Skip to content

Commit

Permalink
ci(test-coverage): Setup kover (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
warnyul authored Mar 14, 2024
1 parent adfa346 commit 3ef31f9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
45 changes: 44 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
build:
runs-on: ubuntu-22.04
permissions:
actions: write
contents: read

steps:
Expand All @@ -22,4 +23,46 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew build
run: ./gradlew build koverXmlReport
- name: Upload coverage report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ hashFiles('build/reports/kover/report.xml') != '' }}
with:
name: kover-report
path: ${{ github.workspace }}/build/reports/kover/report.xml
retention-days: 5
kover:
runs-on: ubuntu-22.04
needs:
- build
permissions:
actions: read
checks: write
contents: read
pull-requests: write

steps:
- name: Download coverage report
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: kover-report
- name: Comment branch coverage report to PR
uses: mi-kas/kover-report@0befa22b2291fedc1eefd9ff8f9d5e3a9412168c # v1.8
if: ${{hashFiles('report.xml') != '' }}
with:
path: ${{ github.workspace }}/report.xml
title: Branch Coverage
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 70
coverage-counter-type: BRANCH
- name: Comment line coverage report to PR
uses: mi-kas/kover-report@0befa22b2291fedc1eefd9ff8f9d5e3a9412168c # v1.8
if: ${{hashFiles('report.xml') != '' }}
with:
path: ${{ github.workspace }}/report.xml
title: Line Coverage
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 70
coverage-counter-type: LINE
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
plugins {
alias(libs.plugins.kotlinxKover)
}

allprojects {
group = 'tech.apter.junit5.jupiter'
version = '1.0-SNAPSHOT'
}

dependencies {
kover(project(':robolectric-extension'))
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ junit4 = "4.13.2"
junit5 = "5.10.2"
jvmToolchain = "17"
kotlin = "1.9.23"
kover = "0.7.6"
robolectric = "4.11.1"
robolectricAndroidAll = "14-robolectric-10818077"
# Use when bom also added to the dependencies
Expand All @@ -32,6 +33,7 @@ androidJUnit5 = { id = "de.mannodermaus.android-junit5", version.ref = "androidJ
androidLibrary = { id = "com.android.library", version.ref = "androidBuildTools" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinxKover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }

[bundles]
junit5 = [
Expand Down
9 changes: 1 addition & 8 deletions robolectric-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.robolectric.gradle.AarDepsPlugin

plugins {
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.kotlinxKover)
}

apply plugin: AarDepsPlugin
Expand Down Expand Up @@ -36,11 +37,3 @@ dependencies {
testImplementation libs.junit5JupiterParams
testRuntimeOnly libs.junit5JupiterEngine
}

kotlin {
jvmToolchain(libs.versions.jvmToolchain.get().toInteger())
}

test {
useJUnitPlatform()
}

0 comments on commit 3ef31f9

Please sign in to comment.