Merge pull request #10156 from dotCooCoo/fix/windows-signing-test-annotation

Packaging: the Windows signing test does not turn its expected warning into an annotation
This commit is contained in:
.CooCoo
2026-12-02 11:10:19 -08:00
committed by GitHub
+8 -1
View File
@@ -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 {