Fix PSScriptAnalyzer warnings following PowerShell best practices (#7) #46
This file contains hidden or 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
| name: PowerShell CI | |
| on: | |
| push: | |
| branches: | |
| - 'v1_specsdev' | |
| - '001-create-a-powershell' | |
| - 'feature/**' | |
| pull_request: | |
| branches: | |
| - 'v1_specsdev' | |
| - 'main' | |
| jobs: | |
| lint-and-test: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: List tests directory contents | |
| run: | | |
| ls -l tests | |
| - name: Install PSScriptAnalyzer and Pester | |
| run: | | |
| Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser -AcceptLicense | |
| Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -Scope CurrentUser -AcceptLicense | |
| - name: Enforce no absolute paths in scripts | |
| run: | | |
| pwsh -NoProfile -Command "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; ./scripts/check-absolute-paths.ps1 -Path ." | |
| - name: Run PSScriptAnalyzer on module | |
| run: | | |
| pwsh -NoProfile -Command "Invoke-ScriptAnalyzer -Path ./PSSpecKit -Recurse -Settings .psscriptanalyzer.psd1" | |
| - name: Verify module can be imported | |
| run: | | |
| pwsh -NoProfile -Command "Import-Module ./PSSpecKit/PSSpecKit.psd1 -Force; Write-Host 'Module imported successfully'; Get-Command -Module PSSpecKit | Format-Table -AutoSize" | |
| - name: Run Pester tests | |
| run: | | |
| pwsh -NoProfile -Command 'Import-Module Pester -MinimumVersion 5.0.0 -Force; $r = Pester\Invoke-Pester -Path .\tests -PassThru; if ($r.FailedCount -gt 0) { exit 1 }' | |
| integration-tests: | |
| runs-on: windows-latest | |
| needs: lint-and-test | |
| # Only run on pull_request events with the 'run-integration' label. This reduces CI minutes for branch pushes. | |
| if: ${{ github.event_name == 'pull_request' && contains(join(',', github.event.pull_request.labels.*.name), 'run-integration') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Pester | |
| run: | | |
| pwsh -Command "Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -Scope CurrentUser -AcceptLicense" | |
| - name: Run integration tests only | |
| run: | | |
| pwsh -NoProfile -Command "Import-Module Pester -MinimumVersion 5.0.0 -Force; $r = Pester\Invoke-Pester -Path .\tests\integration -PassThru; if ($r.FailedCount -gt 0) { exit 1 }" |