-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add psscriptanalyzer.yml to separate pester tests (validate.yml) from…
… psscriptanalyzer tests.
- Loading branch information
1 parent
e8cd220
commit a231fea
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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@v3 | ||
|
||
- name: Install PSScriptAnalyzer | ||
shell: pwsh | ||
run: | | ||
Set-PSRepository PSGallery -InstallationPolicy Trusted | ||
Install-Module PSScriptAnalyzer -Force | ||
- name: Run PSScriptAnalyzer | ||
shell: pwsh | ||
run: | | ||
$settings = Join-Path $env:GITHUB_WORKSPACE '.github/psscriptanalyzer/PSScriptAnalyzerSettings.psd1' | ||
$results = @() | ||
# Analyze all PowerShell files | ||
Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -Include *.ps1,*.psm1,*.psd1 | | ||
ForEach-Object { | ||
$analysis = Invoke-ScriptAnalyzer -Path $_.FullName -Settings $settings | ||
if ($analysis) { | ||
$results += $analysis | ||
} | ||
} | ||
# Output results | ||
if ($results) { | ||
$results | Format-Table -AutoSize | ||
Write-Output "::error::PSScriptAnalyzer found $($results.Count) issues" | ||
exit 1 | ||
} else { | ||
Write-Output "No PSScriptAnalyzer issues found" | ||
} | ||
- name: Upload PSScriptAnalyzer Results | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: psscriptanalyzer-results | ||
path: psscriptanalyzer-results.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters