Skip to content

Commit

Permalink
chore: remove jacoco and migrate to kover (ACOL-139) (#2670)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Feb 7, 2024
1 parent 9a2b353 commit fd1b0e2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 69 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gradle-run-unit-tests.yml
Expand Up @@ -64,19 +64,19 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: report
path: app/build/reports/jacoco
path: app/build/reports/kover

- name: Download Test Reports Folder
uses: actions/download-artifact@v4
with:
name: report
path: app/build/reports/jacoco
path: app/build/reports/kover
merge-multiple: true

- name: Upload Test Report
uses: codecov/codecov-action@v3
with:
files: "app/build/reports/jacoco/jacocoReport/jacocoReport.xml"
files: "app/build/reports/kover/report.xml"

- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
Expand Down
1 change: 0 additions & 1 deletion AR-builder.groovy
Expand Up @@ -540,7 +540,6 @@ pipeline {
}
}

sh './gradlew jacocoReport'
wireSend(secret: env.WIRE_BOT_SECRET, message: "**[#${BUILD_NUMBER} Link](${BUILD_URL})** [${SOURCE_BRANCH}] - ✅ SUCCESS 🎉" + "\nLast 5 commits:\n```text\n$lastCommits\n```")
}

Expand Down
2 changes: 2 additions & 0 deletions buildSrc/build.gradle.kts
Expand Up @@ -19,6 +19,7 @@
private object Dependencies {
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
const val detektGradlePlugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0"
const val koverGradlePlugin = "org.jetbrains.kotlinx:kover-gradle-plugin:0.7.5"
const val junit = "junit:junit:4.13.2"
const val kluent = "org.amshove.kluent:kluent:1.73"
const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.1.2"
Expand All @@ -44,6 +45,7 @@ dependencies {
implementation("com.android.tools.build:gradle:${klibs.versions.agp.get()}")
implementation(Dependencies.kotlinGradlePlugin)
implementation(Dependencies.detektGradlePlugin)
implementation(Dependencies.koverGradlePlugin)
implementation(Dependencies.spotless)
implementation(Dependencies.junit5)

Expand Down
108 changes: 43 additions & 65 deletions buildSrc/src/main/kotlin/scripts/quality.gradle.kts
Expand Up @@ -23,8 +23,8 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

plugins {
id("com.android.application") apply false
id("jacoco")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.kotlinx.kover")
}

dependencies {
Expand Down Expand Up @@ -83,71 +83,49 @@ tasks.register("staticCodeAnalysis") {
dependsOn(detektAll)
}

// Jacoco Configuration
val jacocoReport by tasks.registering(JacocoReport::class) {
group = "Quality"
description = "Reports code coverage on tests within the Wire Android codebase"
val buildVariant = "devDebug" // It's not necessary to run unit tests on every variant so we default to "devDebug"
dependsOn("test${buildVariant.capitalize()}UnitTest")

val outputDir = "$buildDir/jacoco/html"
val classPathBuildVariant = buildVariant

reports {
xml.required.set(true)
html.required.set(true)
html.outputLocation.set(file(outputDir))
}

classDirectories.setFrom(
fileTree(project.buildDir) {
include(
"**/classes/**/main/**", // This probably can be removed
"**/tmp/kotlin-classes/$classPathBuildVariant/**"
)
exclude(
"**/R.class",
"**/R\$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/Manifest$*.class",
"**/*Test*.*",
"**/Injector.*",
"android/**/*.*",
"**/*\$Lambda$*.*",
"**/*\$inlined$*.*",
"**/di/*.*",
"**/*Database.*",
"**/*Response.*",
"**/*Application.*",
"**/*Entity.*",
"**/mock/**",
"**/*Screen*", // These are composable classes
"**/*Kt*", // These are "usually" kotlin generated classes
"**/theme/**/*.*", // Ignores jetpack compose theme related code
"**/common/**/*.*", // Ignores jetpack compose common components related code
"**/navigation/**/*.*" // Ignores jetpack navigation related code
)
}
)

sourceDirectories.setFrom(
fileTree(project.projectDir) {
include("src/main/java/**", "src/main/kotlin/**")
}
)

executionData.setFrom(
fileTree(project.buildDir) {
include("**/*.exec", "**/*.ec")
}
)

doLast { println("Report file: $outputDir/index.html") }
}

tasks.register("testCoverage") {
group = "Quality"
description = "Reports code coverage on tests within the Wire Android codebase."
dependsOn(jacocoReport)
dependsOn("koverXmlReport")
}

koverReport {
defaults {
mergeWith("devDebug")

filters {
excludes {
classes(
"*Fragment",
"*Fragment\$*",
"*Activity",
"*Activity\$*",
"*.databinding.*",
"*.BuildConfig",
"**/R.class",
"**/R\$*.class",
"**/Manifest*.*",
"**/Manifest$*.class",
"**/*Test*.*",
"*NavArgs*",
"*ComposableSingletons*",
"*_HiltModules*",
"*Hilt_*",
)
packages(
"hilt_aggregated_deps",
"com.wire.android.di",
"dagger.hilt.internal.aggregatedroot.codegen",
"com.wire.android.ui.home.conversations.mock",
)
annotatedBy(
"*Generated*",
"*HomeNavGraph*",
"*Destination*",
"*Composable*",
"*Preview*",
)
}
}
}
}

0 comments on commit fd1b0e2

Please sign in to comment.