Conversation
Closes #241. The coverage history added in #1000 already records a TOTAL row per suite on every merge to main, so the badge only needs to expose it. A new 'badge' subcommand emits shields.io endpoint JSON next to COVERAGE.md on the coverage-history branch, and README.md points an endpoint badge at it. The badge reports the instrumentation suite, not unit. This library is a Compose wrapper around a map, so JVM unit tests structurally cannot cover much of it: unit line coverage is 0.42% against 20.87% instrumented. The label says 'coverage (instrumented)' so the number is not mistaken for a whole-project figure. push_coverage_history.sh needed two fixes to carry the new file: it hard-coded history.csv and COVERAGE.md in both its change detection and its git add, and it checked for changes with 'git diff' before staging, which cannot see an untracked file and would have skipped the badge's first commit entirely.
Coverage (unit tests)No unit baseline recorded in
Line and branch coverage from unit test reports. History is recorded in |
Contributor
Code Coverage
|
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.
Closes #241 (open since December 2022).
Why this is small now
#1000 already does the hard part:
coverage-history.ymlrecords aTOTALrow per suite intohistory.csvon thecoverage-historybranch after every merge tomain. The badge just has to expose a number that is already being collected.Which number, and why
The badge reports the instrumentation suite, not unit. Current totals:
This library is a Compose wrapper around a
MapView, so JVM unit tests structurally cannot cover much of it (11 covered lines out of 2,639). A badge wired to the default suite would put "coverage 0%" on the front page and would be actively misleading about how tested this library is.The label reads
coverage (instrumented)rather than plaincoverage, so the figure is not mistaken for a whole-project number, and the badge links toCOVERAGE.mdon the data branch where both suites are broken out per module.Happy to switch to two badges (unit alongside instrumented) if you would rather show both.
Changes
coverage_history.py: newbadgesubcommand emitting shields.io endpoint JSON from the latestTOTALrow. Standard library only, consistent with the rest of the script. A suite with no recorded entry renders as a grey "unknown" rather than failing, so the badge degrades quietly instead of breaking the README.coverage-history.yml: regenerate the badge alongsideCOVERAGE.mdin both record steps, so the file exists even before the first instrumentation entry lands and refreshes as soon as one does.README.md: one endpoint badge, next to the existing Tests/Build badge.Two bugs found in
push_coverage_history.shwhile testingWorth calling out, because without these the feature would have silently done nothing:
history.csv COVERAGE.mdin both its change detection and itsgit add, so the badge file would have been generated and then never committed.git diffbefore staging.git diffdoes not see untracked files, so on the badge's very first run the guard would have reported "unchanged" and exited before committing it. Now it stages first and compares the index.Both paths (initial push and the push-rejected retry) are fixed, and the file list is a single
FILESarray so the next added output does not repeat this.Verification
badgeexercised against the realhistory.csvfrom the data branch: renders21%/ orange.unknown/ lightgrey.coverage-history, confirming it now stages and would commit the new file (it reported "would SKIP commit" before the fix).Sequencing note
coverage-badge.jsondoes not exist on the data branch yet, so until the first post-merge run of "Record coverage history" the shields endpoint returnscustom badge: resource not found. The workflow already hasworkflow_dispatch, so triggering it once right after merge populates the file immediately and avoids that window.