|
9 | 9 | branches: |
10 | 10 | - master |
11 | 11 | - dev |
| 12 | + workflow_dispatch: |
12 | 13 |
|
13 | 14 | jobs: |
14 | | - pester-tests: |
15 | | - runs-on: ubuntu-latest |
16 | | - steps: |
17 | | - - uses: actions/checkout@v4 |
| 15 | + test: |
| 16 | + name: Pester Tests - ${{ matrix.os }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [windows-latest, ubuntu-latest, macos-latest] |
18 | 22 |
|
19 | | - - name: Set PSRepository to Trusted for PowerShell Gallery |
| 23 | + defaults: |
| 24 | + run: |
20 | 25 | shell: pwsh |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up PowerShell Gallery |
21 | 32 | run: | |
22 | 33 | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted |
23 | 34 |
|
24 | | - - name: Install required modules |
25 | | - shell: pwsh |
| 35 | + - name: Install Pester |
26 | 36 | run: | |
27 | | - Install-Module -Name AsBuiltReport.Core -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
28 | | - Install-Module -Name PScribo -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
29 | 37 | Install-Module -Name Pester -MinimumVersion 5.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
30 | | - Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
31 | 38 |
|
32 | | - - name: Run Pester tests |
33 | | - shell: pwsh |
| 39 | + - name: Install PScribo |
| 40 | + run: | |
| 41 | + Install-Module -Name PScribo -MinimumVersion 0.11.1 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
| 42 | +
|
| 43 | + - name: Install PSScriptAnalyzer |
34 | 44 | run: | |
35 | | - .\Tests\Invoke-Tests.ps1 -OutputFormat JUnitXml |
| 45 | + Install-Module -Name PSScriptAnalyzer -MinimumVersion 1.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
36 | 46 |
|
37 | | - - name: Publish test results |
38 | | - uses: dorny/test-reporter@v1 |
| 47 | + - name: Install AsBuiltReport.Core |
| 48 | + run: | |
| 49 | + Install-Module -Name AsBuiltReport.Core -MinimumVersion 1.6.2 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser |
| 50 | +
|
| 51 | + - name: Run Pester Tests |
| 52 | + run: | |
| 53 | + $CodeCoverageParam = @{} |
| 54 | + $OutputFormatParam = @{ OutputFormat = 'NUnitXml' } |
| 55 | +
|
| 56 | + # Only enable code coverage for Windows |
| 57 | + if ('${{ matrix.os }}' -eq 'windows-latest') { |
| 58 | + $CodeCoverageParam = @{ CodeCoverage = $true } |
| 59 | + } |
| 60 | +
|
| 61 | + .\Tests\Invoke-Tests.ps1 @CodeCoverageParam @OutputFormatParam |
| 62 | +
|
| 63 | + - name: Upload test results |
39 | 64 | if: always() |
| 65 | + uses: actions/upload-artifact@v4 |
40 | 66 | with: |
41 | | - name: Pester Tests |
| 67 | + name: test-results-${{ matrix.os }} |
42 | 68 | path: Tests/testResults.xml |
43 | | - reporter: java-junit |
44 | | - fail-on-error: true |
| 69 | + retention-days: 30 |
| 70 | + |
| 71 | + - name: Upload code coverage to Codecov |
| 72 | + if: matrix.os == 'windows-latest' |
| 73 | + uses: codecov/codecov-action@v5 |
| 74 | + with: |
| 75 | + files: ./Tests/coverage.xml |
| 76 | + flags: unit |
| 77 | + name: codecov-${{ matrix.os }} |
| 78 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 79 | + fail_ci_if_error: false |
0 commit comments