Repository navigation
ci: Surface code coverage results in module CI - #12
Merged
Merged
Conversation
The workflow already uploaded and published testResults.xml, but nothing collected the JaCoCo coverage report a module's Pester task can produce. Each test job now uploads the report as its own artifact and renders the JaCoCo totals into the run summary, both guarded on the file existing so a module that does not measure coverage is unaffected. The path is a workflow_call input because it differs per consumer: PowerShellBuild's $PSBPreference.Test.CodeCoverage.OutputFile defaults to codeCoverage.xml in the project root, while a repository following the tests/out/ convention the test results already use writes tests/out/coverage.xml. The summary reports and never gates. Pester instruments the current session only, so anything a test exercises in a child process goes uncounted and the figure understates real coverage; a build-failing threshold over it would be actively misleading. The caveat is stated in the summary itself and in the comments above the step. The unit test publisher now downloads only the test result artifacts, so the coverage reports are not fed to it as test results. Refs psake/PowerShellBuild#139 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01U1Jhu7fgTRJq7LK5MuKteE
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.
What
Surface code coverage in the shared module CI workflow. Until now
ModuleCI.ymluploaded and publishedtestResults.xmlbut nothing collected the JaCoCo report a module's Pester task can produce.Each test job (the pwsh matrix and the Windows PowerShell 5.1 job) gains two steps:
The unit test publisher now downloads only the
Unit Test Results*artifacts, so the new coverage artifacts are not handed topublish-unit-test-result-actionas if they were test results.Which option, and why
Refs psake/PowerShellBuild#139, which listed three options in ascending ambition. This is option 1 plus the cheapest honest form of option 2.
irongut/CodeCoverageSummaryreads Cobertura, not JaCoCo. The JaCoCo PR-comment actions are Java-oriented: they mapsourcefilenameonto source directories and report per-changed-file coverage, which does not line up with what Pester emits for a PowerShell module. A dozen lines of PowerShell in a PowerShell org's workflow is less machinery than an action that needs coaxing, and it keeps the caveat below attached to the number it describes. It also avoids a second bot comment on every pull request -publish-unit-test-result-actionalready comments, and a duplicate for an understated number is noise.Reports, never gates
Pester instruments the current session only. Tests that exercise code in child processes do not contribute - PowerShellBuild has a lot of those, its help tests and the
Test-PSBuildPestersubprocess matrix among them - so the measured number understates real coverage. It is a trend line, not an absolute.So there is no threshold and no failure path. A build-failing gate over an understated number would be actively harmful. The caveat is printed under the table in the run summary, and stated in the workflow comments above the step.
Guarding consumers that produce no coverage
Both new steps carry
if: always() && hashFiles(inputs.code_coverage_report_path) != '', the same shape as the existing changelog step. Coverage is off by default in PowerShellBuild ($PSBPreference.Test.CodeCoverage.Enabled = $false), so most consumers produce no file at all and simply skip both steps. Nobody is failed for lacking a file they never claimed to have.The path is a new
workflow_callinput,code_coverage_report_path, defaulting totests/out/coverage.xml- thetests/out/convention the test results already follow, and what psake/PowerShellBuild actually writes. A module that leaves$PSBPreference.Test.CodeCoverage.OutputFileat its default writescodeCoverage.xmlto the project root instead and can point the input at that. No existing caller needs to change.Verification
tests/out/coverage.xmlfrom a psake/PowerShellBuild build under bothpwshand Windows PowerShell 5.1. Byte-identical output on both, no BOM, LF endings. The JaCoCoDOCTYPEdoes not trip the[xml]cast on either engine.🤖 Generated with Claude Code
https://claude.ai/code/session_01U1Jhu7fgTRJq7LK5MuKteE