|
25 | 25 | description: The classic personal access token for running tests. |
26 | 26 | required: false |
27 | 27 | inputs: |
28 | | - ModuleTestSuites: |
| 28 | + RunsOn: |
29 | 29 | type: string |
30 | | - description: JSON array of module test suites to run (from Get-Settings output). |
| 30 | + description: The type of runner to use for the job. |
| 31 | + required: true |
| 32 | + OSName: |
| 33 | + type: string |
| 34 | + description: The operating system name. |
| 35 | + required: true |
| 36 | + TestName: |
| 37 | + type: string |
| 38 | + description: The name of the test suite. |
| 39 | + required: true |
| 40 | + TestPath: |
| 41 | + type: string |
| 42 | + description: The path to the test files. |
31 | 43 | required: true |
32 | 44 | Name: |
33 | 45 | type: string |
|
73 | 85 | GITHUB_TOKEN: ${{ github.token }} |
74 | 86 |
|
75 | 87 | jobs: |
76 | | - BeforeAll-ModuleLocal: |
77 | | - name: BeforeAll-ModuleLocal |
78 | | - runs-on: ubuntu-latest |
79 | | - steps: |
80 | | - - name: Checkout Code |
81 | | - uses: actions/checkout@v5 |
82 | | - |
83 | | - - name: Install-PSModuleHelpers |
84 | | - uses: PSModule/Install-PSModuleHelpers@v1 |
85 | | - |
86 | | - - name: Run BeforeAll Setup Scripts |
87 | | - uses: PSModule/GitHub-Script@v1 |
88 | | - with: |
89 | | - Name: BeforeAll-ModuleLocal |
90 | | - ShowInfo: false |
91 | | - ShowOutput: true |
92 | | - Debug: ${{ inputs.Debug }} |
93 | | - Prerelease: ${{ inputs.Prerelease }} |
94 | | - Verbose: ${{ inputs.Verbose }} |
95 | | - Version: ${{ inputs.Version }} |
96 | | - WorkingDirectory: ${{ inputs.WorkingDirectory }} |
97 | | - Script: | |
98 | | - LogGroup "Running BeforeAll Setup Scripts" { |
99 | | - $beforeAllScript = 'tests/BeforeAll.ps1' |
100 | | -
|
101 | | - if (-not (Test-Path $beforeAllScript)) { |
102 | | - Write-Host "No BeforeAll.ps1 script found at [$beforeAllScript] - exiting successfully" |
103 | | - exit 0 |
104 | | - } |
105 | | -
|
106 | | - Write-Host "Running BeforeAll setup script: $beforeAllScript" |
107 | | - try { |
108 | | - Push-Location 'tests' |
109 | | - & $beforeAllScript |
110 | | - Write-Host "BeforeAll script completed successfully: $beforeAllScript" |
111 | | - } |
112 | | - catch { |
113 | | - Write-Error "BeforeAll script failed: $beforeAllScript - $_" |
114 | | - throw |
115 | | - } |
116 | | - finally { |
117 | | - Pop-Location |
118 | | - } |
119 | | - } |
120 | | -
|
121 | 88 | Test-ModuleLocal: |
122 | | - name: Test-${{ matrix.TestName }} (${{ matrix.OSName }}) |
123 | | - runs-on: ${{ matrix.RunsOn }} |
124 | | - needs: |
125 | | - - BeforeAll-ModuleLocal |
126 | | - strategy: |
127 | | - fail-fast: false |
128 | | - matrix: |
129 | | - include: ${{ fromJson(inputs.ModuleTestSuites) }} |
| 89 | + name: Test-${{ inputs.TestName }} (${{ inputs.OSName }}) |
| 90 | + runs-on: ${{ inputs.RunsOn }} |
130 | 91 | steps: |
131 | 92 | - name: Checkout Code |
132 | 93 | uses: actions/checkout@v5 |
@@ -158,65 +119,16 @@ jobs: |
158 | 119 | Prerelease: ${{ inputs.Prerelease }} |
159 | 120 | Verbose: ${{ inputs.Verbose }} |
160 | 121 | Version: ${{ inputs.Version }} |
161 | | - TestResult_TestSuiteName: ${{ matrix.TestName }}-${{ matrix.OSName }} |
| 122 | + TestResult_TestSuiteName: ${{ inputs.TestName }}-${{ inputs.OSName }} |
162 | 123 | TestResult_Enabled: true |
163 | 124 | CodeCoverage_Enabled: true |
164 | 125 | Output_Verbosity: Detailed |
165 | 126 | CodeCoverage_OutputFormat: JaCoCo |
166 | 127 | CodeCoverage_CoveragePercentTarget: 0 |
167 | 128 | Filter_ExcludeTag: Flaky |
168 | | - Path: ${{ matrix.TestPath }} |
| 129 | + Path: ${{ inputs.TestPath }} |
169 | 130 | Run_Path: ${{ steps.import-module.outputs.path }} |
170 | 131 | WorkingDirectory: ${{ inputs.WorkingDirectory }} |
171 | 132 | Prescript: | # This is to speed up module loading in Pester. |
172 | 133 | Install-PSResource -Repository PSGallery -TrustRepository -Name PSCustomObject |
173 | 134 | Import-Module -Name '${{ steps.import-module.outputs.name }}' -RequiredVersion 999.0.0 |
174 | | -
|
175 | | - AfterAll-ModuleLocal: |
176 | | - name: AfterAll-ModuleLocal |
177 | | - runs-on: ubuntu-latest |
178 | | - needs: |
179 | | - - Test-ModuleLocal |
180 | | - if: always() |
181 | | - steps: |
182 | | - - name: Checkout Code |
183 | | - uses: actions/checkout@v5 |
184 | | - |
185 | | - - name: Install-PSModuleHelpers |
186 | | - uses: PSModule/Install-PSModuleHelpers@v1 |
187 | | - |
188 | | - - name: Run AfterAll Teardown Scripts |
189 | | - if: always() |
190 | | - uses: PSModule/GitHub-Script@v1 |
191 | | - with: |
192 | | - Name: AfterAll-ModuleLocal |
193 | | - ShowInfo: false |
194 | | - ShowOutput: true |
195 | | - Debug: ${{ inputs.Debug }} |
196 | | - Prerelease: ${{ inputs.Prerelease }} |
197 | | - Verbose: ${{ inputs.Verbose }} |
198 | | - Version: ${{ inputs.Version }} |
199 | | - WorkingDirectory: ${{ inputs.WorkingDirectory }} |
200 | | - Script: | |
201 | | - LogGroup "Running AfterAll Teardown Scripts" { |
202 | | - $afterAllScript = 'tests/AfterAll.ps1' |
203 | | -
|
204 | | - if (-not (Test-Path $afterAllScript)) { |
205 | | - Write-Host "No AfterAll.ps1 script found at [$afterAllScript] - exiting successfully" |
206 | | - exit 0 |
207 | | - } |
208 | | -
|
209 | | - Write-Host "Running AfterAll teardown script: $afterAllScript" |
210 | | - try { |
211 | | - Push-Location 'tests' |
212 | | - & $afterAllScript |
213 | | - Write-Host "AfterAll script completed successfully: $afterAllScript" |
214 | | - } |
215 | | - catch { |
216 | | - Write-Warning "AfterAll script failed: $afterAllScript - $_" |
217 | | - # Don't throw for teardown scripts to ensure other cleanup scripts can run |
218 | | - } |
219 | | - finally { |
220 | | - Pop-Location |
221 | | - } |
222 | | - } |
0 commit comments