Skip to content

Commit

Permalink
Add annotations for pwsh lint
Browse files Browse the repository at this point in the history
Add annotations for PSScriptAnalyzer issues.
  • Loading branch information
martincostello committed Feb 8, 2025
1 parent fa88f19 commit ab5c13b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ jobs:

- name: Lint PowerShell scripts
shell: pwsh
run: Invoke-ScriptAnalyzer -Path . -Recurse -IncludeDefaultRules -ReportSummary -Severity @('Error','Warning') -EnableExit
run: |
$settings = @{
IncludeDefaultRules = $true
Severity = @("Error", "Warning")
}
$issues = Invoke-ScriptAnalyzer -Path ${env:GITHUB_WORKSPACE} -Recurse -ReportSummary -Settings $settings
foreach ($issue in $issues) {
$severity = $issue.Severity.ToString()
$level = $severity.Contains("Error") ? "error" : $severity.Contains("Warning") ? "warning" : "notice"
Write-Output "::${level} file=$($issue.ScriptName),line=$($issue.Line),title=PSScriptAnalyzer::$($issue.Message)"
}
if ($issues.Count -gt 0) {
exit 1
}

0 comments on commit ab5c13b

Please sign in to comment.