fix: Update workflow to use correct action names and v4 upload-artifact #4
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: Pester Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - testing | |
| - test/** | |
| paths: | |
| - 'Scripts/**' | |
| - 'Tests/**' | |
| - 'Modules/**' | |
| - '.github/workflows/pester-tests.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| - testing | |
| paths: | |
| - 'Scripts/**' | |
| - 'Tests/**' | |
| - 'Modules/**' | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| name: Run Pester Tests | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| pwsh-version: ['7.2', '7.3', '7.4'] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup PowerShell ${{ matrix.pwsh-version }} | |
| uses: powershell/setup-powershell@v2 | |
| with: | |
| pwsh-version: ${{ matrix.pwsh-version }} | |
| - name: Install Pester | |
| shell: pwsh | |
| run: | | |
| $ProgressPreference = 'SilentlyContinue' | |
| Install-Module -Name Pester -RequiredVersion 5.7.1 -Force -SkipPublisherCheck | |
| Get-Module -Name Pester -ListAvailable | |
| - name: Run All Tests | |
| shell: pwsh | |
| run: | | |
| $testPath = 'Tests/' | |
| $resultsFile = 'test-results.xml' | |
| $pesterConfig = @{ | |
| Path = $testPath | |
| OutputFile = $resultsFile | |
| OutputFormat = 'NUnitXml' | |
| ExcludeTag = @('IntegrationNotImplemented') | |
| PassThru = $true | |
| WarningAction = 'SilentlyContinue' | |
| } | |
| $results = Invoke-Pester @pesterConfig | |
| Write-Host "`n========== Test Summary ==========" -ForegroundColor Cyan | |
| Write-Host "Total Tests: $($results.FailedCount + $results.PassedCount)" | |
| Write-Host "Passed: $($results.PassedCount)" -ForegroundColor Green | |
| Write-Host "Failed: $($results.FailedCount)" -ForegroundColor $(if ($results.FailedCount -gt 0) { 'Red' } else { 'Green' }) | |
| Write-Host "=================================" -ForegroundColor Cyan | |
| if ($results.FailedCount -gt 0) { | |
| exit 1 | |
| } | |
| - name: Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pester-test-results-${{ matrix.pwsh-version }} | |
| path: test-results.xml | |
| retention-days: 30 | |
| - name: Publish Test Report | |
| if: always() | |
| uses: EnricoMi/publish-unit-test-result-action/windows@v2 | |
| with: | |
| files: test-results.xml | |
| check_name: Test Results (PowerShell ${{ matrix.pwsh-version }}) | |
| comment_mode: always | |
| test-summary: | |
| name: Complete Test Suite Summary | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: always() | |
| steps: | |
| - name: Check Test Results | |
| run: | | |
| if [ "${{ needs.test.result }}" == "failure" ]; then | |
| echo "❌ Tests failed - Build cannot proceed" | |
| exit 1 | |
| else | |
| echo "✅ All tests passed successfully" | |
| fi |