Skip to content

Make Windows build-and-upload steps fail fast on native command errors - #334

Merged
SeanTAllen merged 1 commit into
mainfrom
windows-build-fail-fast
Jun 12, 2026
Merged

Make Windows build-and-upload steps fail fast on native command errors#334
SeanTAllen merged 1 commit into
mainfrom
windows-build-fail-fast

Conversation

@SeanTAllen

Copy link
Copy Markdown
Member

The Windows Build and upload steps in nightlies.yml and release.yml run a chain of native commands in a single pwsh block — pip install, the ponyc download, the make.ps1 build/test/install/package commands, then the Cloudsmith push — with a $LASTEXITCODE guard only after the push. In pwsh a non-zero exit from a native command is not fatal by default, so a failure in an earlier command did not stop the step; it ran on and the real error got buried until the guard fired much later.

Two complementary changes make Windows CI fail at the point of failure:

  • The four Build and upload blocks set $ErrorActionPreference = 'Stop' and $PSNativeCommandUseErrorActionPreference = $true at the top, turning native non-zero exits into terminating errors. This catches the pip install (the original failure) and the Cloudsmith push directly, so the manual $LASTEXITCODE guard is removed.

  • make.ps1 now guards every native call (ponyc and the test binary) with an explicit $LastExitCode check, mirroring ponyup's make.ps1. This is what fails the build and test steps — and crucially it also covers pr.yml and the Windows breakage workflow, which call make.ps1 without the block-level preferences, plus local .\make.ps1 runs. (The explicit check is robust to those workflows' 2>&1 redirect, since $LastExitCode is unaffected by stream merging.) The block-level preference and the in-script guards are independent mechanisms — correctness does not depend on preference inheritance into the called script.

While making the build fail fast, make.ps1's version line used git rev-parse --short --verify HEAD^, whose parent ref does not resolve in the shallow actions/checkout clone (verified against a CI log: fatal: Needed a single revision, Version: 0.9.2-). The failure was silently swallowed before, but would become a hard build break once make.ps1 fails fast. Switched to HEAD, which always resolves and matches the canonical Makefile.

Note: the fix relies on the runners executing run: steps under pwsh >= 7.4, where $PSNativeCommandUseErrorActionPreference is a settable preference. Modern Windows runner images ship this; worth eyeballing the first post-merge windows-11-arm run.

Follow-up filed as #333: the Windows build embeds a -<sha>-suffixed version string the Makefile doesn't (pre-existing; surfaced more clearly by the HEAD fix).

Closes #331

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Jun 12, 2026
@SeanTAllen
SeanTAllen force-pushed the windows-build-fail-fast branch from 96fac0e to 79fff3f Compare June 12, 2026 03:28
In a pwsh step a non-zero exit from a native command is not fatal by
default, so a failure in an early command (the pip install, the build,
the tests) did not stop the step. It ran on and the real error got
buried, only surfacing at the late $LASTEXITCODE guard after the
Cloudsmith push.

Two complementary changes make Windows CI fail at the point of failure:

- The four Build and upload blocks set $ErrorActionPreference = 'Stop'
  and $PSNativeCommandUseErrorActionPreference = $true, turning native
  non-zero exits into terminating errors. This catches the pip install
  and the Cloudsmith push directly, so the manual $LASTEXITCODE guard
  is removed.

- make.ps1 guards every native call (ponyc, the test binary) with an
  explicit $LastExitCode check, mirroring ponyup's make.ps1. This fails
  the build and test steps, including in pr.yml and the Windows breakage
  workflow, which call make.ps1 without the block-level preferences, and
  when run locally.

Failing fast exposed two latent failures make.ps1 had been masking:

- The version line used 'git rev-parse --short --verify HEAD^', whose
  parent ref does not resolve in the shallow CI checkout. Switch to
  HEAD, matching the Makefile.

- It passed $configFlag as a positional argument to ponyc. In Release
  builds $configFlag is empty, and pwsh 7 passes the variable through
  to native commands as a literal empty string whether or not it is
  quoted. ponyc treated it as a second package path, built the real
  package, then exited non-zero ('no source files in package'). Build
  the ponyc argument list as an array and only append $configFlag when
  non-empty, so the empty argument is genuinely absent.

Closes #331
@SeanTAllen
SeanTAllen force-pushed the windows-build-fail-fast branch from 79fff3f to 2361856 Compare June 12, 2026 03:35
@SeanTAllen
SeanTAllen merged commit d9ff3d9 into main Jun 12, 2026
12 checks passed
@SeanTAllen
SeanTAllen deleted the windows-build-fail-fast branch June 12, 2026 03:37
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Jun 12, 2026
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.

Windows build-and-upload steps don't fail fast on native command errors

2 participants