From 1e2179aa561823e1aecb688b4cd9452b88d0abe7 Mon Sep 17 00:00:00 2001 From: James Maes Date: Mon, 12 Oct 2026 11:00:24 -0500 Subject: [PATCH] fix(ci): isolate racing signing analyzer rules Retain every configured rule while preventing concurrent command-metadata access by casing and exported-cmdlet analysis. Require a negative fixture for each pass; preserve all signing files, tests, versions and deadlines. Co-Authored-By: Codex (GPT-6) Signed-off-by: James Maes --- .github/workflows/ci.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86b976f..96a284d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,9 +131,31 @@ jobs: Install-Module Pester -RequiredVersion 5.7.1 -Scope CurrentUser -Force Import-Module PSScriptAnalyzer -RequiredVersion 1.25.0 Import-Module Pester -RequiredVersion 5.7.1 + # Keep every configured rule; isolate concurrent command-metadata consumers. + # https://github.com/PowerShell/PSScriptAnalyzer/issues/1708 + $settings = 'configs/shell/PSScriptAnalyzerSettings.psd1' + $casingFixture = @(Invoke-ScriptAnalyzer -ScriptDefinition "get-content -literalpath 'fixture.txt'" -Settings $settings -IncludeRule PSUseCorrectCasing) + if ('PSUseCorrectCasing' -notin $casingFixture.RuleName) { throw 'The casing pass did not detect incorrect casing.' } + $reservedFixture = @(Invoke-ScriptAnalyzer -ScriptDefinition 'function Get-Fixture? { [CmdletBinding()] param() }; Export-ModuleMember -Function Get-Fixture?' -Settings $settings -IncludeRule PSReservedCmdletChar) + if ('PSReservedCmdletChar' -notin $reservedFixture.RuleName) { throw 'The reserved-character pass did not detect the exported function.' } + $remainingFixture = @(Invoke-ScriptAnalyzer -ScriptDefinition "Write-Host 'fixture'" -Settings $settings -ExcludeRule PSUseCorrectCasing, PSReservedCmdletChar) + if ('PSAvoidUsingWriteHost' -notin $remainingFixture.RuleName) { throw 'The remaining-rule pass did not detect Write-Host.' } foreach ($path in @('tools/WindowsSigning.psm1', 'tools/WindowsSigning.Tests.ps1', 'tools/VelopackSigning.Tests.ps1')) { - $findings = @(Invoke-ScriptAnalyzer -Path $path -Settings configs/shell/PSScriptAnalyzerSettings.psd1) + Write-Output "Analyzing $path" + try + { + $findings = @( + Invoke-ScriptAnalyzer -Path $path -Settings $settings -IncludeRule PSUseCorrectCasing + Invoke-ScriptAnalyzer -Path $path -Settings $settings -IncludeRule PSReservedCmdletChar + Invoke-ScriptAnalyzer -Path $path -Settings $settings -ExcludeRule PSUseCorrectCasing, PSReservedCmdletChar + ) + } + catch + { + Write-Output $_.Exception.ToString() + throw + } if ($findings.Count -gt 0) { $findings | Format-Table; throw "Script analysis failed: $path" } } $configuration = New-PesterConfiguration -- 2.54.0