Skip to content

Collect and report coverage for UnitsNet.Modular - #1726

Open
Rafael-SOWNet wants to merge 1 commit into
angularsen:masterfrom
Rafael-SOWNet:ci/modular-coverage
Open

Collect and report coverage for UnitsNet.Modular#1726
Rafael-SOWNet wants to merge 1 commit into
angularsen:masterfrom
Rafael-SOWNet:ci/modular-coverage

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown

Motivation

Nothing in the repository measures UnitsNet.Modular's coverage. Build/test-projects.psm1
lists seven test projects and none of the three Modular ones are among them, and this workflow
ran plain dotnet test. codecov.yml sets the target range to 80–100, but that target has only
ever seen the legacy projects.

The Modular projects cannot simply be added to test-projects.psm1: Start-Tests runs
dotnet test --no-build against projects that build.ps1 has already built from
UnitsNet.slnx, whereas Modular is a separate solution that needs
-p:Platform=ProjectReferences. Collecting it here, where the solution is already built
correctly, avoids teaching the legacy pipeline about the Modular platform.

Changes

  • restore the local tools, so the dotCover the repository already depends on is available
  • wrap the existing test run in dotCover cover-dotnet, writing DetailedXML to Artifacts/Coverage
  • upload with the same codecov/codecov-action@v6 step and options pr.yml uses
  • grant id-token: write

Two of those deserve a reason.

id-token. pr.yml declares no permissions block and inherits the repository default.
This workflow declares contents: read explicitly, which sets everything else to none, so
Codecov's use_oidc: true would have no token to request.

The filter is narrower than the legacy one. Start-Tests uses
+:module=UnitsNet*;-:module=*Tests. Applied here that reports assemblies this workflow does
not own, because the compatibility suite compiles the current UnitsNet project and generates a
large fixture:

filter reported
+:module=UnitsNet*;-:module=*Tests 31% — legacy UnitsNet at 24% (35 557 statements) and UnitsNet.Modular.Compatibility.GeneratedFixture, a generated test fixture, at 37% (19 435 statements)
this PR's filter 90%UnitsNet.Modular 81%, UnitsNet.Modular.Generator 93%

Legacy UnitsNet is already measured by pr.yml, so including it here would double-count it
against 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
UnitDescriptor at 21%, BaseDimensions at 31% and LogarithmicQuantityMath at 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/31126042733all steps green,
including the two new ones.

Passed! - Failed: 0, Passed: 40, Skipped: 0, Total: 40   UnitsNet.Modular.Tests
Passed! - Failed: 0, Passed: 43, Skipped: 0, Total: 43   UnitsNet.Modular.Compatibility.Tests
Passed! - Failed: 0, Passed: 33, Skipped: 0, Total: 33   UnitsNet.Modular.Generator.Tests

Found 1 coverage files to report
 > Artifacts/Coverage/UnitsNet.Modular.coverage.xml
Sending upload (186600 bytes) to storage
Upload queued for processing complete

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants