Export coverage as Cobertura XML - #118
Merged
Merged
Conversation
GitHub Code Quality stores coverage itself now -- a bot comment on the pull request with aggregate and per-file line coverage against the default branch, and a `Restrict code coverage` ruleset that can gate merges on it. It takes Cobertura XML and nothing else, and this package could only write LCOV. `write_cobertura(io_or_path, result; root)` is the sibling of `write_lcov`: same `root` relativization through `_report_path`, same `/` separators, same "returns `false` and writes nothing when the run collected no coverage" contract, so a caller can drive both from one `if`. Cobertura describes branch and method coverage too. Julia's line-count instrumentation produces neither and the consumer this exists for reads line coverage only, so those attributes are present -- the format's consumers expect them -- and always zero. A line Julia could not instrument is left out rather than reported as a line nobody ran: Cobertura has no "not applicable" hit count. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`round(Int, time() * 1000)` is `round(Int32, ...)` on a 32-bit Julia, and epoch milliseconds passed what an Int32 can hold in 1970. Every x86 leg therefore threw `InexactError: Int32(1.7898e12)` out of `write_cobertura` and produced no report at all. The test now pins the attribute: it has to parse as an integer larger than `typemax(Int32)`, which is true on every platform and is what the 32-bit legs were failing to reach. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Opened by Claude.
Why
GitHub Code Quality now stores coverage itself: a
github-code-quality[bot]comment on the pull request with aggregate and per-file line coverage against the default branch, and aRestrict code coveragebranch ruleset that can block a merge below a minimum percentage or beyond a maximum drop. It accepts Cobertura XML and nothing else, and this package could only write LCOV.This is the first of five PRs wiring that up end to end (TestItemControllers → TestItemRuns → TestItemApp → julia-run-testitems → testitem-workflow). This one is self-contained and green on its own.
What
write_cobertura(io_or_path, result; root)in a newsrc/cobertura.jl, deliberately built as the twin ofwrite_lcov:rootrelativization through the shared_report_path, same/separators, same refusal to walk out of the root with..;falseand writes nothing when the run collected no coverage" contract, so a caller can drive both from oneif— and a run without coverage leaves no empty file behind for something to upload as a real 0%;file:URI.Cobertura describes branch and method coverage too. Julia's line-count instrumentation produces neither and Code Quality reads line coverage only, so those attributes are present — the format's consumers expect them — and always zero. A line Julia could not instrument is left out rather than reported as a line nobody ran: Cobertura has no "not applicable" hit count. Files are grouped into one
<package>per directory, dotted, as the format's Java ancestry expects.Verification
test/test_cobertura.jlcovering the no-coverage case, escaping, non-file:URIs, root relativization (absolute and relative roots) and the path-writing method.xml.etree.ElementTree), and itslines-covered/lines-validagree exactly with theLH:/LF:totalswrite_lcovproduces from the sameTestrunResult.Note
versiongoes to1.12.0-DEV— additive feature, and the downstream[compat]bounds in the other four PRs assume"1.12". Say the word if you want a different number.Unrelated, but noticed while editing:
CHANGELOG.md's unreleased section has been headed## [2.0.0] - Unreleasedsince the file was added, while releases have been shipping as 1.11.x. Left alone here.