Skip to content

Commit e485211

Browse files
tpcarmanclaude
andcommitted
Rewrite Pester workflow based on AsBuiltReport.Microsoft.Azure template
- Add matrix strategy across windows-latest, ubuntu-latest, macos-latest - Replace dorny/test-reporter with actions/upload-artifact (avoids XML format parsing issues; test results stored as downloadable artifacts) - Add Codecov code coverage upload (Windows only) - Add workflow_dispatch for manual runs - Revert output format to NUnitXml (JUnitXml change reverted) - Split module installs into separate named steps - Always use pwsh shell (PS5.1 not supported by this module) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 68eba38 commit e485211

File tree

1 file changed

+53
-18
lines changed

1 file changed

+53
-18
lines changed

.github/workflows/Pester.yml

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,71 @@ on:
99
branches:
1010
- master
1111
- dev
12+
workflow_dispatch:
1213

1314
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]
1822

19-
- name: Set PSRepository to Trusted for PowerShell Gallery
23+
defaults:
24+
run:
2025
shell: pwsh
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up PowerShell Gallery
2132
run: |
2233
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
2334
24-
- name: Install required modules
25-
shell: pwsh
35+
- name: Install Pester
2636
run: |
27-
Install-Module -Name AsBuiltReport.Core -Repository PSGallery -Force -AllowClobber -Scope CurrentUser
28-
Install-Module -Name PScribo -Repository PSGallery -Force -AllowClobber -Scope CurrentUser
2937
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
3138
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
3444
run: |
35-
.\Tests\Invoke-Tests.ps1 -OutputFormat JUnitXml
45+
Install-Module -Name PSScriptAnalyzer -MinimumVersion 1.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser
3646
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
3964
if: always()
65+
uses: actions/upload-artifact@v4
4066
with:
41-
name: Pester Tests
67+
name: test-results-${{ matrix.os }}
4268
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

Comments
 (0)