|
| 1 | +name: PowerShell Archive Module Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, servicing ] |
| 6 | + pull_request: |
| 7 | + branches: [ master, servicing ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 15 | + |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + |
| 18 | + name: Test on ${{ matrix.os }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 1000 |
| 25 | + |
| 26 | + - name: Install Pester |
| 27 | + shell: pwsh |
| 28 | + run: | |
| 29 | + if (!(Get-Module -ListAvailable -Name Pester | Where-Object {$_.Version -le "4.99" -and $_.Version -ge "4.0"})) { |
| 30 | + Install-Module -Name Pester -Force -SkipPublisherCheck -MaximumVersion 4.99 |
| 31 | + } |
| 32 | + |
| 33 | + - name: Run Tests |
| 34 | + shell: pwsh |
| 35 | + run: | |
| 36 | + Import-Module "Pester" -MaximumVersion "4.99" |
| 37 | + Get-Module "Pester" |
| 38 | + $testResultsFile = "./ArchiveTestResults.xml" |
| 39 | + Import-Module "./Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psd1" -Force |
| 40 | + $testResults = Invoke-Pester -Script "./Tests" -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
| 41 | + if ($testResults.FailedCount -gt 0) { |
| 42 | + throw "$($testResults.FailedCount) tests failed." |
| 43 | + } |
| 44 | + |
| 45 | + - name: Upload test results |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + if: always() |
| 48 | + with: |
| 49 | + name: test-results-${{ matrix.os }} |
| 50 | + path: ArchiveTestResults.xml |
| 51 | + |
| 52 | + winps-tests: |
| 53 | + runs-on: windows-latest |
| 54 | + |
| 55 | + name: Windows PowerShell Tests |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + fetch-depth: 1000 |
| 62 | + |
| 63 | + - name: Install Pester |
| 64 | + shell: pwsh |
| 65 | + run: | |
| 66 | + if (!(Get-Module -ListAvailable -Name Pester | Where-Object {$_.Version -le "4.99" -and $_.Version -ge "4.0"})) { |
| 67 | + Install-Module -Name Pester -Force -SkipPublisherCheck -MaximumVersion 4.99 |
| 68 | + } |
| 69 | +
|
| 70 | + - name: Run Tests |
| 71 | + shell: pwsh |
| 72 | + run: | |
| 73 | + Import-Module "Pester" -MaximumVersion "4.99" |
| 74 | + Get-Module "Pester" |
| 75 | + $testResultsFile = "./ArchiveTestResults.xml" |
| 76 | + Import-Module "./Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psd1" -Force |
| 77 | + $testResults = Invoke-Pester -Script "./Tests" -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru |
| 78 | + if ($testResults.FailedCount -gt 0) { |
| 79 | + throw "$($testResults.FailedCount) tests failed." |
| 80 | + } |
| 81 | +
|
| 82 | + - name: Upload test results |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + if: always() |
| 85 | + with: |
| 86 | + name: windows-powershell-test-results |
| 87 | + path: ArchiveTestResults.xml |
0 commit comments