Skip to content

Actually fail the build on NuGet Pester failures (add missing exit 1) - #606

Merged
Zach Teutsch (zateutsch) merged 1 commit into
mainfrom
nmetulev-fix-nuget-pester-gate-exit-code
Jul 8, 2026
Merged

Zach Teutsch (zateutsch) merged 1 commit into
mainfrom
nmetulev-fix-nuget-pester-gate-exit-code

Conversation

@nmetulev

Copy link
Copy Markdown
Member

Problem

#605 fixed the NuGet Pester test gate in scripts/build-cli.ps1 — it added $pesterConfig.Run.PassThru = $true (so Invoke-Pester returns 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 $FailOnTestFailure is set (default $true), it called Write-Error but never called exit 1. Under PowerShell's default $ErrorActionPreference = 'Continue' — which is exactly what GitHub Actions' default pwsh shell uses, and what .github/workflows/build-package.yml (.\scripts\build-cli.ps1 -SkipDocs) relies on — Write-Error is non-terminating. So the script printed "Stopping build…" and then kept running and exited 0. The build did not actually fail on NuGet Pester failures under GitHub Actions. (It only failed in Azure DevOps .pipelines/templates/build.yaml, where PowerShell@2 forces errorActionPreference=stop.)

Fix

Add exit 1 immediately after the Write-Error in the NuGet Pester gate, making it consistent with the two sibling gates in the same file that already do this:

  • the npm unit-tests gate (~line 246–247)
  • the CLI unit-tests gate (~line 298–299)

This is a single-line change.

Verification

  • scripts/build-cli.ps1 parses cleanly ([System.Management.Automation.Language.Parser]::ParseFile).
  • git diff confirms the only change is the added exit 1 line.

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>
Copilot AI review requested due to automatic review settings July 7, 2026 21:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 1 after Write-Error in the NuGet Pester test-failure gate so the build actually fails when $FailOnTestFailure is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 31.71 MB 31.71 MB ✅ 0.0 KB (0.00%)
CLI (x64) 32.04 MB 32.04 MB ✅ 0.0 KB (0.00%)
MSIX (ARM64) 13.30 MB 13.30 MB 📈 +0.0 KB (+0.00%)
MSIX (x64) 14.15 MB 14.15 MB 📉 -0.0 KB (-0.00%)
NPM Package 27.77 MB 27.77 MB 📈 +0.3 KB (+0.00%)
NuGet Package 27.79 MB 27.79 MB 📈 +0.4 KB (+0.00%)
VS Code Extension 20.60 MB 20.60 MB 📈 +0.7 KB (+0.00%)

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 Time

43ms median (x64, winapp --version) · ✅ no change vs. baseline


Updated 2026-07-07 22:00:55 UTC · commit 5362a8a · workflow run

@zateutsch
Zach Teutsch (zateutsch) merged commit a5724f6 into main Jul 8, 2026
25 of 26 checks passed
@zateutsch
Zach Teutsch (zateutsch) deleted the nmetulev-fix-nuget-pester-gate-exit-code branch July 8, 2026 01:24
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.

3 participants