Skip to content

PSSA now works in pipeline. Howerver, there a 100+ PSSA hits on old c… #4

PSSA now works in pipeline. Howerver, there a 100+ PSSA hits on old c…

PSSA now works in pipeline. Howerver, there a 100+ PSSA hits on old c… #4

name: PSScriptAnalyzer
on:
pull_request:
paths:
- "**.ps1"
- "**.psm1"
- "**.psd1"
push:
branches:
- main
- development
- "feature/144-implement-dual-validation-psscriptanalyzer-with-standardized-settings"
paths:
- "**.ps1"
- "**.psm1"
- "**.psd1"
jobs:
analyze:
name: PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Debug Paths
shell: pwsh
run: |
Write-Host "Current location: $(Get-Location)"
Write-Host "GITHUB_WORKSPACE: $env:GITHUB_WORKSPACE"
$settingsPath = Join-Path $env:GITHUB_WORKSPACE 'Hawk' 'tests' 'psscriptanalyzer' 'PSScriptAnalyzerSettings.psd1'
Write-Host "Settings path: $settingsPath"
Write-Host "`nVerifying tests structure:"
Get-ChildItem -Path (Join-Path $env:GITHUB_WORKSPACE 'Hawk' 'tests') -Recurse |
Select-Object FullName
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Force
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$settingsPath = Join-Path $env:GITHUB_WORKSPACE 'Hawk' 'tests' 'psscriptanalyzer' 'PSScriptAnalyzerSettings.psd1'
Write-Host "Using settings file: $settingsPath"
if (-not (Test-Path $settingsPath)) {
Write-Error "PSScriptAnalyzer settings file not found at: $settingsPath"
exit 1
}
$results = @()
$files = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -Include *.ps1,*.psm1,*.psd1 |
Where-Object {
$_.FullName -notlike '*\node_modules\*' -and
$_.FullName -notlike '*/.git/*'
}
foreach ($file in $files) {
Write-Host "Analyzing $($file.FullName)"
$fileResults = Invoke-ScriptAnalyzer -Path $file.FullName -Settings $settingsPath
if ($fileResults) {
$results += $fileResults
}
}
if ($results) {
Write-Host "Found $($results.Count) issues"
$results | Format-Table -AutoSize | Out-String | Write-Host
$results | Format-Table -AutoSize | Out-File (Join-Path $env:GITHUB_WORKSPACE 'psscriptanalyzer-results.txt')
exit 1
} else {
Write-Host "No PSScriptAnalyzer issues found"
}
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: psscriptanalyzer-results
path: psscriptanalyzer-results.txt
if-no-files-found: warn