Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/BuildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ on:
pull_request:
branches:
- 'staging'

- 'epic/**'
jobs:
build_test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -68,10 +71,23 @@ jobs:
path: lib/build/test-results/testDebugUnitTest

- name: Run Lib Compose Unit Test
run: ./gradlew lib-compose:testDebugUnitTest
run: ./gradlew lib-compose:jacocoTestReport

- name: Upload Lib Compose Test Results
uses: actions/upload-artifact@v4
with:
name: lib-compose-test-results
path: lib-compose/build/test-results/testDebugUnitTest
path: lib-compose/build/reports/jacoco/jacocoTestReport

- name: Jacoco Report to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/**/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 60
min-coverage-changed-files: 60
title: ':lobster: Coverage Report'
update-comment: true
pass-emoji: ':green_square:'
fail-emoji: ':red_square:'
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
classpath(libs.ktlint.gradle)
classpath(libs.sonarqube.gradle.plugin)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.jacoco.core)
}
}

Expand Down
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ junit4 = "4.13.2"
mockk = "1.13.10"
androidxCoreTesting = "1.6.1"
androidArchCoreTesting = "2.2.0"
jacocoVersion = "0.8.11"

#Compose
androidxComposeBom = "2024.10.00"
Expand Down Expand Up @@ -66,6 +67,7 @@ androidx-core-testing = { module = "androidx.arch.core:core-testing", version.re
junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }
jacoco-core = { module = "org.jacoco:org.jacoco.core", version.ref = "jacocoVersion" }

#Compose
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
Expand Down Expand Up @@ -106,4 +108,5 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
maven-publish = { id = "maven-publish" }
signing = { id = "signing" }
kotlin-parcelize = { id = "kotlin-parcelize" }
kotlin-parcelize = { id = "kotlin-parcelize" }
jacoco = { id = "jacoco" }
45 changes: 45 additions & 0 deletions lib-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.dokka)
alias(libs.plugins.compose.compiler)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id(libs.plugins.jacoco.get().pluginId)
}

/**
Expand Down Expand Up @@ -38,6 +39,9 @@ android {
"proguard-rules.pro"
)
}
debug {
enableUnitTestCoverage = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -59,6 +63,47 @@ android {
}
}

jacoco {
toolVersion = libs.versions.jacocoVersion.get()
}

tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(tasks.withType<Test>().named("testDebugUnitTest"))

reports {
xml.required.set(true)
html.required.set(true)
}

val fileFilter = listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/buttons/**",
"**/providers/**",
"**/utils/**",
"**/models/**",
"**/MapProvider*.*",
"**/state/camera/**",
"**/W3WMapComponent*.*",
"**/W3WMapDefaults*.*",
)

val javaTree = fileTree("${buildDir}/intermediates/javac/debug") {
exclude(fileFilter)
}
val kotlinTree = fileTree("${buildDir}/tmp/kotlin-classes/debug") {
exclude(fileFilter)
}

sourceDirectories.setFrom(files("${project.projectDir}/src/main/java", "${project.projectDir}/src/main/kotlin"))
classDirectories.setFrom(files(javaTree, kotlinTree))
executionData.setFrom(fileTree("${buildDir}/outputs/unit_test_code_coverage/debugUnitTest").apply {
include("testDebugUnitTest.exec")
})
}

tasks.register("checkSnapshotDependencies") {
doLast {
val snapshotDependencies = allprojects.flatMap { project ->
Expand Down
Loading