refactor(build): align coverage config with template pattern#11
Conversation
Switch the staged-output path computation from a hardcoded module name to the env-var-driven pattern from tablackburn/PowerShellModuleTemplate#19: - Use $Env:BHPSModuleManifest / $Env:BHProjectName (populated by Set-BuildEnvironment before psake runs) instead of a hardcoded $moduleName = 'ReScenePS' and a manual manifest-path computation. - Add an env-var guard so direct Invoke-psake invocations (bypassing build.ps1) fail fast with an actionable message instead of an obscure Import-PowerShellDataFile null-binding error. - Use [IO.Path]::Combine for the staged path to avoid mixed separators on Windows, matching the rest of the properties block. Preserves the existing third coverage path (Classes/) — this module has a Classes/ subdirectory. Functionally equivalent to the prior config (same staged Output path, same coverage targets); this is a cosmetic alignment to the template pattern across the rest of the user's PowerShell modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughbuild.psake.ps1 now computes code coverage target files from the staged build output (Output//) using environment-provided manifest values; related test scripts set the build environment when BHBuildOutput is unset to populate those env vars before invoking the build. ChangesBuild & Test Environment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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
Aligns the psake build’s Pester coverage-path configuration with the upstream template’s env-var-driven pattern, so coverage targets the staged Output/<Name>/<Version> paths consistently across modules.
Changes:
- Replace hardcoded module name + manifest path computation with
BHPSModuleManifest/BHProjectNameenvironment variables. - Add a guard that throws if those BuildHelpers env vars aren’t present.
- Use
[IO.Path]::Combine()to build the staged output path used for coverage globs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
build.psake.ps1 (1)
29-31: 💤 Low valueMixed separators in coverage paths contradict the stated
[IO.Path]::Combinegoal.
$_stagedOutputis built with[IO.Path]::Combine(backslashes on Windows), but the array entries append subdirectory segments with a hard-coded forward slash, producing paths likeC:\...\Output\ReScenePS\1.0.0/Public/*.ps1on Windows. PowerShell normalises these transparently, so coverage collection still works — but the change doesn't fully achieve the stated goal of using[IO.Path]::Combineto avoid mixed separators.♻️ Consistent use of
[IO.Path]::Combinefor subdirectory paths$PSBPreference.Test.CodeCoverage.Files = @( - "$_stagedOutput/Public/*.ps1" - "$_stagedOutput/Private/*.ps1" - "$_stagedOutput/Classes/*.ps1" + [IO.Path]::Combine($_stagedOutput, 'Public', '*.ps1') + [IO.Path]::Combine($_stagedOutput, 'Private', '*.ps1') + [IO.Path]::Combine($_stagedOutput, 'Classes', '*.ps1') )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@build.psake.ps1` around lines 29 - 31, The coverage path entries mix separators by concatenating "$_stagedOutput" with forward-slash subpaths; update the three array items to construct paths with [IO.Path]::Combine instead of string concatenation so they inherit the platform-native separators (use [IO.Path]::Combine($_stagedOutput, 'Public', '*.ps1'), [IO.Path]::Combine($_stagedOutput, 'Private', '*.ps1'), and [IO.Path]::Combine($_stagedOutput, 'Classes', '*.ps1') to replace the current "$_stagedOutput/.../*.ps1" entries referencing $_stagedOutput).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@build.psake.ps1`:
- Around line 29-31: The coverage path entries mix separators by concatenating
"$_stagedOutput" with forward-slash subpaths; update the three array items to
construct paths with [IO.Path]::Combine instead of string concatenation so they
inherit the platform-native separators (use [IO.Path]::Combine($_stagedOutput,
'Public', '*.ps1'), [IO.Path]::Combine($_stagedOutput, 'Private', '*.ps1'), and
[IO.Path]::Combine($_stagedOutput, 'Classes', '*.ps1') to replace the current
"$_stagedOutput/.../*.ps1" entries referencing $_stagedOutput).
Help.tests.ps1 and Manifest.tests.ps1 each have a "running outside ./build.ps1" escape hatch that calls Invoke-psake -TaskList Build directly. Until now the bootstrap only set BHBuildOutput later in the file; it relied on PowerShellBuild's Init task to populate the rest of the BHE env vars as a side effect. The new env-var guard in build.psake.ps1's properties block (added in the previous commit on this branch) runs *before* the Build task can do anything, so the isolated-test invocation path now fails fast with a guard error instead of bootstrapping. Add Set-BuildEnvironment to the bootstrap so BHPSModuleManifest and BHProjectName are populated before psake evaluates properties. Verified locally: with BH* env vars cleared, Invoke-Pester ./tests/Help.tests.ps1 now bootstraps cleanly (psake builds, 145 tests pass). Addresses Copilot review feedback on PR #11. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rename $_moduleVersion → $moduleVersion and $_stagedOutput → $stagedOutput per Copilot review feedback on PR #11. Pure rename, no behavior change. Same rename applied across PowerShellModuleTemplate, JsmOperations, and PlexAutomationToolkit so the user's modules stay in sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Cosmetic alignment to the env-var-driven coverage-path pattern from upstream tablackburn/PowerShellModuleTemplate#19, the template this module was scaffolded from.
This is not a bug fix — coverage already works on `main` (verified at 78.95% / 77.91% / 98.51% / 100% by computing percentages from the JaCoCo XML directly; the console summary reporting 0% is a known PowerShellBuild 0.7.3 integer-truncation display bug, unrelated to this PR). It's purely a style convergence so this repo's `build.psake.ps1` matches the rest of the user's PowerShell modules.
Changes
Verification
Local `./build.ps1 -Task Test` produces an identical coverage XML before and after this change.
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Tests