hermes-agent/tests/install/e2e-assets/source-build-env.ps1
ethernet f7561667c7 fix: round-8 CI backlog (Windows-only lane)
- tests/conftest.py: `real_bash` fixture — the Windows runners resolve `bash` to System32's
  WSL launcher (UTF-16 "no installed distributions", exit 1); prefer Git for Windows'. Used
  by the setup-pin, install stage-frame and source-launcher shell tests.
- source-build-env.ps1: Test-Path before Remove-Item — under $ErrorActionPreference='Stop'
  a missing identity variable aborted the try block before the child ran (Windows PS 5.1
  raised where pwsh on Unix did not).
- desktop-update/windows.ps1: `--force` precedes the target arguments (the hand-off contract
  test reads argv in that order).
- test_install_ps1_desktop_stage: assert the current contract — the shared completion tail
  (source_completion.py --desktop) builds the products and -IncludeDesktop selects the desktop
  product inside `products` rather than adding a stage. The test predated the completion-tail
  refactor and had been red on the Windows lane since.
- test_windows_native_support: the restart watcher argv is `runtime_command` shaped
  ([python, -I, -c, bootstrap, pid, delay, ...]).
- test_mint_launchers: create the fixture repo's pm/ dir before copying pm/environments.py.
- test_browser_use_pm: console-script launchers report sys.argv[0] without `.exe`.
- test_update_stale_gateway_yield (from main): `_verify_fleet_after_update` has no
  `node_failures` here (PM owns node).
2026-09-21 06:03:05 -04:00

24 lines
1.1 KiB
PowerShell

# Child installers/builds stamp their checkout; restore the workflow identity even on failure.
function Invoke-SourceBuild([scriptblock]$Action) {
$saved = @{}
$names = @('GITHUB_SHA', 'GITHUB_REF', 'GITHUB_REF_NAME', 'GITHUB_HEAD_REF', 'GITHUB_BASE_REF',
'HERMES_BUILD_COMMIT', 'HERMES_PAYLOAD_TAG', 'HERMES_PAYLOAD_VERSION', 'HERMES_DESKTOP_VARIANT')
# The env: drive, not [Environment]::SetEnvironmentVariable: on .NET/Unix the latter only
# updates the managed copy, so a child spawned afterwards still inherits the old value.
# Test-Path first: under $ErrorActionPreference = 'Stop' a missing item would otherwise
# terminate the try block before $Action runs.
try {
foreach ($name in $names) {
$item = "env:$name"
if (Test-Path -LiteralPath $item) {
$saved[$name] = (Get-Item -LiteralPath $item).Value
Remove-Item -LiteralPath $item
}
}
& $Action
} finally {
foreach ($name in $saved.Keys) {
Set-Item -LiteralPath "env:$name" -Value $saved[$name]
}
}
}