fix(build): target staged output for code coverage#47
Conversation
Pester reports 0% coverage because the coverage globs in build.psake.ps1
point at the source tree (PlexAutomationToolkit/{Public,Private}/*.ps1)
while the test files Import-Module from the staged build output
(Output/<Name>/<Version>/). Pester treats the two paths as different
files, so every executed line counts as "missed."
Compute the staged path explicitly from the manifest version (read via
$Env:BHPSModuleManifest, which BuildHelpers populates before psake
runs), and guard against missing env vars so direct Invoke-psake
invocations fail fast with an actionable message.
Same fix as upstream tablackburn/PowerShellModuleTemplate#19, the
template this module was scaffolded from.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe build script's code coverage configuration was updated to reference staged build output instead of source files. The script now requires ChangesBuild Coverage Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR updates the build/test configuration so Pester code coverage is collected against the staged module output under Output/<Name>/<Version> instead of the source tree, aligning coverage paths with how this repository’s tests import the module.
Changes:
- Repoints Pester coverage globs from
PlexAutomationToolkit/{Public,Private}to the stagedOutput/<Project>/<Version>directory. - Derives the staged coverage path from BuildHelpers environment variables and the module manifest version.
- Adds an early guard/error when required BuildHelpers variables are not available during psake property evaluation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rename $_moduleVersion → $moduleVersion and $_stagedOutput → $stagedOutput to match the upstream template change in tablackburn/PowerShellModuleTemplate. Pure rename, no behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Pester reports 0% coverage on this module because the coverage globs in
build.psake.ps1point at the source tree (PlexAutomationToolkit/{Public,Private}/*.ps1) while the test filesImport-Modulefrom the staged build output (Output/<Name>/<Version>/). Pester treats the two paths as different files, so every executed line counts as "missed."This fix points coverage at the staged output, derived from the manifest version and BuildHelpers env vars.
Why this matters
Same root cause and same fix as upstream tablackburn/PowerShellModuleTemplate#19 — the template this module was scaffolded from. Verified there at 0% → 100% coverage on identical test infrastructure.
This module's tests use
Import-Module -Name (Join-Path -Path $Env:BHBuildOutput -ChildPath "$Env:BHProjectName.psd1")(template default), so the bug applies and the fix lands cleanly.Why not just use
$Env:BHBuildOutput?That was the first attempt — it doesn't work. PowerShellBuild only rewrites
BHBuildOutputto the staged version path later, inside its own tasks. At psakeproperties-evaluation time, it's still BuildHelpers' default<root>/BuildOutput, which doesn't exist and causes Pester to bail withCould not resolve coverage path.So the path has to be computed explicitly from the manifest (
$Env:BHPSModuleManifestis populated bySet-BuildEnvironmentbefore psake runs).Test plan
./build.ps1 -Task Build,Teston three OSes (plus Windows PowerShell 5.1) — all jobs greenunittestsflag continues to report non-zero coverage;codecov/patchpasses🤖 Generated with Claude Code