Collect and report coverage for UnitsNet.Modular - #1726
Open
Rafael-SOWNet wants to merge 1 commit into
Open
Conversation
The Modular test projects are absent from Build/test-projects.psm1, and this workflow ran plain dotnet test, so nothing in the repository measured Modular coverage. codecov.yml targets the 80-100 range, but that target only ever saw the legacy projects. Wraps the existing test run in the dotCover tool the repository already depends on, and uploads the report the same way pr.yml does. The filter is narrower than the legacy '+:module=UnitsNet*;-:module=*Tests'. The compatibility suite compiles the current UnitsNet project and generates a large fixture assembly, so the broad filter reports legacy UnitsNet at 24% and a 19k-statement generated test fixture at 37%, dragging the headline to 31% and measuring things this workflow does not own. Restricting it to the two product assemblies reports what Modular is actually responsible for. id-token is granted because this workflow, unlike pr.yml, declares its permissions explicitly, so Codecov's use_oidc would otherwise have no token.
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.
Motivation
Nothing in the repository measures UnitsNet.Modular's coverage.
Build/test-projects.psm1lists seven test projects and none of the three Modular ones are among them, and this workflow
ran plain
dotnet test.codecov.ymlsets the target range to 80–100, but that target has onlyever seen the legacy projects.
The Modular projects cannot simply be added to
test-projects.psm1:Start-Testsrunsdotnet test --no-buildagainst projects thatbuild.ps1has already built fromUnitsNet.slnx, whereas Modular is a separate solution that needs-p:Platform=ProjectReferences. Collecting it here, where the solution is already builtcorrectly, avoids teaching the legacy pipeline about the Modular platform.
Changes
dotCoverthe repository already depends on is availabledotCover cover-dotnet, writing DetailedXML toArtifacts/Coveragecodecov/codecov-action@v6step and optionspr.ymlusesid-token: writeTwo of those deserve a reason.
id-token.pr.ymldeclares nopermissionsblock and inherits the repository default.This workflow declares
contents: readexplicitly, which sets everything else tonone, soCodecov's
use_oidc: truewould have no token to request.The filter is narrower than the legacy one.
Start-Testsuses+:module=UnitsNet*;-:module=*Tests. Applied here that reports assemblies this workflow doesnot own, because the compatibility suite compiles the current UnitsNet project and generates a
large fixture:
+:module=UnitsNet*;-:module=*TestsUnitsNetat 24% (35 557 statements) andUnitsNet.Modular.Compatibility.GeneratedFixture, a generated test fixture, at 37% (19 435 statements)UnitsNet.Modular81%,UnitsNet.Modular.Generator93%Legacy
UnitsNetis already measured bypr.yml, so including it here would double-count itagainst a number this workflow cannot move.
Result
Modular's coverage turns out to be healthy — 2 498 / 2 764 statements, inside the repository's
80–100 target. This PR does not improve coverage; it makes an existing good number visible and
guards it against regressing unnoticed. The thinnest areas, for anyone interested later, are
UnitDescriptorat 21%,BaseDimensionsat 31% andLogarithmicQuantityMathat 55%.What this does not do
No test is added or changed, and no product code is touched. The AOT smoke test, the NuGet
consumer checks and packing are untouched and still run in the same order.
Validation
I cannot run this workflow against upstream, so I ran it on my fork, from this branch, with the
workflow file as it stands in this PR:
https://github.com/Rafael-SOWNet/UnitsNet/actions/runs/31126042733 — all steps green,
including the two new ones.
So the upload path works, not just the collection. It landed in my fork's Codecov project
rather than yours, which is the one part of this that can only be confirmed once it runs here.