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
This commit is contained in:
yhc
2026-08-10 19:32:27 +08:00
parent 0f6e85cd72
commit 3730b3396f
+22
View File
@@ -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