Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove jacoco and migrate to kover (ACOL-139) #2670

Merged
merged 1 commit into from
Feb 7, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/gradle-run-unit-tests.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ pipeline {
}
}

sh './gradlew jacocoReport'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code, not used, since coverage runs on gh actions.

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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*",
)
}
}
}
}
Loading