diff --git a/packaging/windows/nightly-signing-tests.ps1 b/packaging/windows/nightly-signing-tests.ps1 index 535ad4e222..fc81696ece 100644 --- a/packaging/windows/nightly-signing-tests.ps1 +++ b/packaging/windows/nightly-signing-tests.ps1 @@ -107,7 +107,14 @@ try { $file = Join-Path $root 'owned-sentinel.exe' [IO.File]::WriteAllText($file, 'generated sentinel, not a real executable') $before = (Get-FileHash -LiteralPath $file -Algorithm SHA256).Hash - & $sign -Files $file + # With GITHUB_ACTIONS set, sign.ps1 prints its unsigned-files warning as a workflow annotation. + # The test clears it for this call, reads the warning from the warning stream and restores it. + $actions = $env:GITHUB_ACTIONS + $env:GITHUB_ACTIONS = $null + try { $signOutput = @(& $sign -Files $file 3>&1) } finally { $env:GITHUB_ACTIONS = $actions } + $warnings = @($signOutput | Where-Object { $_ -is [Management.Automation.WarningRecord] }) + Assert-Policy ($warnings.Count -eq 1 -and $warnings[0].Message.Contains('Windows signing secrets not set')) 'optional stable policy did not warn about unsigned files' + Assert-Policy (-not ($signOutput | Where-Object { "$_".StartsWith('::') })) 'optional stable policy printed a workflow command' Assert-Policy ((Get-FileHash -LiteralPath $file -Algorithm SHA256).Hash -ceq $before) 'optional stable policy changed unsigned bytes' Write-Output 'PASS: stable-optional-policy-preserves-owned-bytes' } finally {