Repository navigation
Actually fail the build on NuGet Pester failures (add missing exit 1) - #606
Conversation
The NuGet Pester gate wrote an error but never called exit 1, so under the default $ErrorActionPreference=Continue (GitHub Actions pwsh) the build printed "Stopping build…" and continued, exiting 0. Add exit 1 to match the npm and CLI unit-test gates in the same script. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes an incomplete build gate in scripts/build-cli.ps1. Following #605 (which made the NuGet Pester test gate reachable), a failure detected with $FailOnTestFailure set only called Write-Error without exit 1. Because Write-Error is non-terminating under the default $ErrorActionPreference = 'Continue' used by GitHub Actions' pwsh, the build printed a "Stopping build…" message but continued and exited 0, so NuGet Pester failures did not actually fail the build in CI. Adding exit 1 makes the gate terminate as intended and aligns it with the two sibling test gates in the same script.
Changes:
- Added
exit 1afterWrite-Errorin the NuGet Pester test-failure gate so the build actually fails when$FailOnTestFailureis set.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Build Metrics ReportBinary Sizes
Test Results✅ 1545 passed, 1 skipped out of 1546 tests in 433.0s (+17.5s vs. baseline) Test Coverage❌ 18% line coverage, 37.2% branch coverage · ✅ no change vs. baseline CLI Startup Time43ms median (x64, Updated 2026-07-07 22:00:55 UTC · commit |
Problem
#605 fixed the NuGet Pester test gate in
scripts/build-cli.ps1— it added$pesterConfig.Run.PassThru = $true(soInvoke-Pesterreturns a result object) and changed the failure condition to count failed tests + blocks + containers. That made the gate reachable for the first time.But the gate was still incomplete: when a failure is detected and
$FailOnTestFailureis set (default$true), it calledWrite-Errorbut never calledexit 1. Under PowerShell's default$ErrorActionPreference = 'Continue'— which is exactly what GitHub Actions' defaultpwshshell uses, and what.github/workflows/build-package.yml(.\scripts\build-cli.ps1 -SkipDocs) relies on —Write-Erroris non-terminating. So the script printed "Stopping build…" and then kept running and exited0. The build did not actually fail on NuGet Pester failures under GitHub Actions. (It only failed in Azure DevOps.pipelines/templates/build.yaml, wherePowerShell@2forceserrorActionPreference=stop.)Fix
Add
exit 1immediately after theWrite-Errorin the NuGet Pester gate, making it consistent with the two sibling gates in the same file that already do this:This is a single-line change.
Verification
scripts/build-cli.ps1parses cleanly ([System.Management.Automation.Language.Parser]::ParseFile).git diffconfirms the only change is the addedexit 1line.