1c39701534
- All 3 workflows: pwsh -> powershell (host requires PS 5.1, not Core 7+) - workflow-example.yml: replace GITHUB_WORKSPACE-relative ciScriptsDir with hardcoded host path; use SSH alias URL (host-clone mode) instead of HTTP - docs: add WORKFLOW-AUTHORING.md reference for AI and developers
56 lines
1.5 KiB
YAML
56 lines
1.5 KiB
YAML
# 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."
|
|
}
|