# PSScriptAnalyzer lint — runs on every push/PR that touches PowerShell files. # Requires PSScriptAnalyzer installed on the runner host: # Install-Module PSScriptAnalyzer -Scope AllUsers -Force # # Failures block the PR. Fix warnings with: # Invoke-ScriptAnalyzer -Path scripts\ -Recurse -Fix name: Lint (PSScriptAnalyzer) on: push: paths: - '**.ps1' - '**.psm1' pull_request: paths: - '**.ps1' - '**.psm1' jobs: lint: runs-on: windows-build timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 - name: Run PSScriptAnalyzer shell: powershell run: | $ErrorActionPreference = 'Stop' if (-not (Get-Module -ListAvailable PSScriptAnalyzer)) { Write-Host "Installing PSScriptAnalyzer..." Install-Module PSScriptAnalyzer -Scope CurrentUser -Force -AllowClobber } $paths = @('scripts', 'template', 'runner', 'Setup-Host.ps1') $results = $paths | ForEach-Object { if (Test-Path $_) { Invoke-ScriptAnalyzer -Path $_ -Recurse -Severity Error,Warning } } if ($results) { $results | Format-Table -AutoSize Write-Error "PSScriptAnalyzer found $($results.Count) issue(s). Fix before merging." exit 1 } else { Write-Host "PSScriptAnalyzer: no issues found." }