CI #6
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| lint: | |
| name: PSScriptAnalyzer Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache PowerShell modules | |
| id: cache-lint-modules | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.local/share/powershell/Modules | |
| key: ${{ runner.os }}-psmodules-lint-${{ hashFiles('build.depend.psd1') }} | |
| restore-keys: | | |
| ${{ runner.os }}-psmodules-lint- | |
| - name: Install PSScriptAnalyzer | |
| if: steps.cache-lint-modules.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
| Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser | |
| - name: Run PSScriptAnalyzer | |
| shell: pwsh | |
| run: | | |
| $results = Invoke-ScriptAnalyzer -Path ./{{ModuleName}} -Recurse -Settings PSGallery -ReportSummary | |
| $errors = $results | Where-Object { $_.Severity -eq 'Error' } | |
| if ($results) { | |
| Write-Host "::group::PSScriptAnalyzer Results" | |
| $results | Format-Table -AutoSize | |
| Write-Host "::endgroup::" | |
| } | |
| if ($errors) { | |
| Write-Host "::error::PSScriptAnalyzer found $($errors.Count) error(s)" | |
| exit 1 | |
| } | |
| Write-Host "PSScriptAnalyzer passed with no errors" | |
| unit-tests: | |
| name: Unit Tests (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macOS-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache PowerShell modules | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/Documents/PowerShell/Modules | |
| ~/.local/share/powershell/Modules | |
| key: ${{ runner.os }}-psmodules-${{ hashFiles('build.depend.psd1') }} | |
| restore-keys: | | |
| ${{ runner.os }}-psmodules- | |
| - name: Build and Test | |
| shell: pwsh | |
| run: | | |
| New-Item -Path out -ItemType Directory -Force | Out-Null | |
| ./build.ps1 -Task Build,Test -Bootstrap | |
| - name: Upload Coverage to Codecov | |
| uses: codecov/codecov-action@v6 | |
| if: success() | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: out/codeCoverage.xml | |
| flags: ${{ matrix.os }} | |
| fail_ci_if_error: false | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: out/ | |
| retention-days: 30 |