Skip to content

[ENHANCEMENT] Add linting of PowerShell Scripts #25

[ENHANCEMENT] Add linting of PowerShell Scripts

[ENHANCEMENT] Add linting of PowerShell Scripts #25

Workflow file for this run

name: Run salt tests
on:
pull_request:
concurrency:
group: test-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
windows:
uses: plus3it/actions-workflows/.github/workflows/test-salt-windows.yml@00ff10246f901f01818db412fa99124dbed4a00c
strategy:
matrix:
os_version:
- windows-2019
- windows-2022
- windows-2025
salt_state:
- notepad-plusplus
salt_pillar_root:
- ./tests/pillar/test-main
with:
salt-os-version: ${{ matrix.os_version }}
salt-state: ${{ matrix.salt_state }}
salt-pillar-root: ${{ matrix.salt_pillar_root }}
lint_powershell:
name: PowerShell Linting
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$files = Get-ChildItem -Path ./ -Include *.ps1 -Recurse
Write-Host "--- Starting PowerShell Static Analysis ---"
$anyErrors = $false
foreach ($file in $files) {
$relativePath = $file.FullName.Replace($PWD.ProviderPath, ".")
$results = Invoke-ScriptAnalyzer -Path $file.FullName -Severity Warning
if ($results) {
Write-Host "FAIL: $relativePath" -ForegroundColor Red
$results | Format-Table -AutoSize
$anyErrors = $true
} else {
Write-Host "PASS: $relativePath" -ForegroundColor Green
}
}
if ($anyErrors) {
Write-Error "Static analysis failed. Please fix the errors above."
exit 1
} else {
Write-Host "--- All files passed analysis! ---"
}