From 3730b3396fd3ab6eb9329b5d4b530cc05fd4628f Mon Sep 17 00:00:00 2001 From: yhc <1964366186@qq.com> Date: Mon, 10 Aug 2026 19:32:27 +0800 Subject: [PATCH] ci: add PowerShell syntax check via PSParser (P1-1) - New step in sh-syntax job runs [Parser]::ParseFile over all tracked .ps1 files (no execution, syntax-only); fails the build on any parse error with file/line/column annotations - Baselines clean locally: 24 tracked .ps1 files, 0 parse errors - Closes the gap where Windows was the primary platform but only .sh scripts had a CI syntax check --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41012c8..9012fca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,28 @@ jobs: exit 1 fi + - name: PowerShell syntax check (PSParser, all tracked .ps1) + shell: pwsh + run: | + $files = git ls-files '*.ps1' + if (-not $files) { Write-Host 'No .ps1 files tracked'; exit 0 } + $failed = 0 + foreach ($f in $files) { + $tokens = $null + $errors = $null + [System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f), [ref]$tokens, [ref]$errors) | Out-Null + if ($errors -and $errors.Count -gt 0) { + $failed++ + Write-Host "::error file=$f::$($errors.Count) parse error(s)" + foreach ($e in $errors) { + Write-Host (" L{0}:{1} {2}" -f $e.Extent.StartLineNumber, $e.Extent.StartColumnNumber, $e.Message) + } + } else { + Write-Host "syntax OK: $f" + } + } + if ($failed -gt 0) { exit 1 } + version-check: name: version consistency runs-on: ubuntu-latest