build: migrate unit test coverage from JaCoCo to Kover - #994
Merged
Merged
Conversation
Replaces the manual JaCoCo wiring in PublishingConventionPlugin with kotlinx-kover 0.9.9. The old jacocoTestReport task hardcoded AGP 9 internal intermediate paths (intermediates/built_in_kotlinc) to work around JaCoCo not understanding the built-in Kotlin compiler output; Kover integrates through AGP's variant APIs so none of that is needed. Also removes the unused com.mxalbert.gradle:jacoco-android classpath dependency (last released for AGP 8.x). CI now runs koverXmlReportDebug for the library modules. The instrumented-test coverage in instrumentation-test.yml is unchanged: it uses AGP's built-in on-device JaCoCo, which Kover does not cover.
kikoso
force-pushed
the
build/migrate-jacoco-to-kover
branch
from
September 10, 2026 13:07
aabb831 to
a990ea6
Compare
Contributor
Code Coverage
|
dkhawk
approved these changes
Sep 10, 2026
kikoso
added a commit
that referenced
this pull request
Sep 15, 2026
* ci: record unit and instrumentation test coverage history
Coverage was reported per run but never retained, so there was no way to
see how it moves over time. This adds an append-only history that is
updated after every merge to main.
coverage/history.csv holds one row per module per suite per merged commit.
coverage/COVERAGE.md is regenerated from it with the current numbers and a
trend table. Both are produced by .github/scripts/coverage_history.py,
which parses the JaCoCo-format XML that both Kover and AGP emit.
Two suites are tracked separately, since they instrument different code
and cannot be merged from their XML reports:
unit koverXmlReportDebug, covering the library modules
instrumentation createDebugCoverageReport, covering maps-app and
maps-compose-widgets
Instrumentation tests are not re-run after merge. The emulator already
runs on every pull request, so instrumentation-test.yml now publishes its
reports as an artifact and the post-merge workflow downloads it. That
keeps the added CI cost at roughly zero. If the run is missing or the
artifact has expired, only unit coverage is recorded for that commit.
Pull requests also get a sticky comment showing the unit coverage delta
against main. Instrumentation already has its own comment.
Release-please commits are skipped so releases do not add entries.
Also corrects a stale jacocoTestReport reference in AGENTS.md left over
from the Kover migration in #994.
* ci: bind workflow expressions through env to fix template injection
zizmor flagged github.base_ref being expanded directly into a run block in
test.yml as a high severity template-injection finding. Branch names can
contain shell metacharacters, so the value is now passed through the step
environment and referenced as a shell variable instead.
github.sha in coverage-history.yml is bound the same way. It was not
flagged, since it is always a hex digest, but this keeps run blocks free
of any template expansion.
Also notes why the checkout in coverage-history.yml keeps its credentials:
the job pushes the updated history back to main.
* ci: add thousands separators to coverage tables
Large line counts were hard to read at a glance: 2731/5405 rather than
2,731/5,405. Only the rendered markdown changes; history.csv keeps raw
numbers so it stays machine readable.
A comma is used rather than a dot because the tables already spell
percentages with a decimal point, and reusing the dot for both roles would
make a number like 2.731 ambiguous.
Also regenerates COVERAGE.md, which had been committed with a timestamp
one render out of step with history.csv.
* ci: limit instrumentation coverage to modules that own androidTest
createDebugCoverageReport emits a report for every module with
enableAndroidTestCoverage, including maps-compose and maps-compose-utils,
which have no androidTest sources at all. Those reports list every class
at 0%, which reads as "untested" when the code is in fact exercised by
maps-app's tests and simply attributed there.
Recording them dragged the instrumentation total from 20.83% down to
10.08% and said something false about the libraries. The suite now tracks
maps-app and maps-compose-widgets, the two modules that actually own
instrumentation tests, which also matches the figure the existing coverage
comment reports.
Verified against the real artifact from run 34986287391 rather than a
fixture: maps-app 21.73%, maps-compose-widgets 6.71%, total 20.83%.
Adds a --modules override ("all" records every module) so the scope can be
changed without editing the parsing code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates unit test coverage from JaCoCo to kotlinx-kover 0.9.9.
Why: the
jacocoTestReporttask inPublishingConventionPluginhardcoded AGP 9 internal intermediate paths (intermediates/built_in_kotlinc/debug) to work around JaCoCo not understanding the built-in Kotlin compiler output. Those paths are implementation details that can break on any AGP update. Kover (first-party JetBrains, actively maintained against AGP 9) integrates through AGP's variant APIs, so the manual report wiring is deleted. The unusedcom.mxalbert.gradle:jacoco-androidclasspath dependency (last released for AGP 8.x) is removed as well.Changes
PublishingConventionPluginappliesorg.jetbrains.kotlinx.koverwithandroidGeneratedClasses()excluded, replacing the hand-rolledjacocoTestReporttask.test.ymlrunskoverXmlReportDebuginstead ofjacocoTestReport.instrumentation-test.yml(createDebugCoverageReportonmaps-app) uses AGP's built-in on-device JaCoCo, which Kover does not replace, so it stays as is.Verification
Full CI command
./gradlew build koverXmlReportDebug -x :maps-app:generateDebugScreenshotTestConfig -x :maps-app:generateReleaseScreenshotTestConfig --stacktracepasses locally (11m 51s). Kover reports generate for all three library modules;maps-compose-utils(the only module with host unit tests) shows captured coverage, and the modules without host tests report 0% exactly as JaCoCo did.