|
| 1 | +name: Run Pester Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release/** |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - release/** |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Run Pester Tests |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v6 |
| 25 | + |
| 26 | + - name: Setup .NET |
| 27 | + uses: actions/setup-dotnet@v4 |
| 28 | + with: |
| 29 | + dotnet-version: '6.0.x' |
| 30 | + |
| 31 | + - name: Install Pester |
| 32 | + shell: pwsh |
| 33 | + run: | |
| 34 | + if (-not (Get-Module -ListAvailable -Name Pester | Where-Object Version -ge '5.0.0')) { |
| 35 | + Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -Scope CurrentUser -SkipPublisherCheck |
| 36 | + } |
| 37 | + Import-Module Pester -MinimumVersion 5.0.0 -Force |
| 38 | + |
| 39 | + - name: Build Module |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + ./build.ps1 -Build -Clean -BuildConfiguration Release |
| 43 | + |
| 44 | + - name: Run Pester Tests |
| 45 | + shell: pwsh |
| 46 | + run: | |
| 47 | + $config = New-PesterConfiguration |
| 48 | + $config.Run.Path = './test' |
| 49 | + $config.Run.Exit = $true |
| 50 | + $config.Output.Verbosity = 'Detailed' |
| 51 | + $config.CodeCoverage.Enabled = $false |
| 52 | + $config.TestResult.Enabled = $true |
| 53 | + $config.TestResult.OutputPath = 'testResults.xml' |
| 54 | + $config.TestResult.OutputFormat = 'NUnitXml' |
| 55 | + |
| 56 | + Invoke-Pester -Configuration $config |
| 57 | + |
| 58 | + - name: Upload Test Results |
| 59 | + if: always() |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: test-results-${{ matrix.os }} |
| 63 | + path: testResults.xml |
| 64 | + |
| 65 | + - name: Publish Test Results |
| 66 | + if: always() |
| 67 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 68 | + with: |
| 69 | + files: testResults.xml |
0 commit comments