@@ -56,7 +56,7 @@ permissions:
56
56
57
57
jobs :
58
58
TestSourceCode :
59
- name : Test source code
59
+ name : Test code
60
60
strategy :
61
61
fail-fast : false
62
62
matrix :
84
84
Name : ${{ inputs.Name }}
85
85
Path : ${{ inputs.Path }}
86
86
Shell : ${{ matrix.shell }}
87
- TestType : ' SourceCode'
87
+ TestType : SourceCode
88
88
89
89
BuildModule :
90
90
name : Build module
@@ -124,18 +124,13 @@ jobs:
124
124
if-no-files-found : error
125
125
retention-days : 1
126
126
127
- TestModule :
128
- name : Test module
127
+ # This is necessary as there is no way to get output from a matrix job
128
+ TestModule-pwsh-ubuntu-latest :
129
+ name : Test module (pwsh, ubuntu-latest)
129
130
needs : BuildModule
130
- strategy :
131
- fail-fast : false
132
- matrix :
133
- shell : [pwsh]
134
- os : [ubuntu-latest, macos-latest, windows-latest]
135
- include :
136
- - shell : powershell
137
- os : windows-latest
138
- runs-on : ${{ matrix.os }}
131
+ runs-on : ubuntu-latest
132
+ outputs :
133
+ passed : ${{ steps.test.outputs.passed }}
139
134
steps :
140
135
- name : Checkout Code
141
136
uses : actions/checkout@v4
@@ -145,7 +140,7 @@ jobs:
145
140
with :
146
141
Version : ${{ inputs.Version }}
147
142
Prerelease : ${{ inputs.Prerelease }}
148
- Shell : ${{ matrix.shell }}
143
+ Shell : pwsh
149
144
150
145
- name : Download module artifact
151
146
uses : actions/download-artifact@v4
@@ -154,13 +149,239 @@ jobs:
154
149
path : ${{ inputs.ModulesOutputPath }}
155
150
156
151
- name : Test built module
152
+ id : test
157
153
uses : PSModule/Test-PSModule@v1
158
154
if : ${{ inputs.SkipTests != true }}
155
+ continue-on-error : true
159
156
with :
160
157
Name : ${{ inputs.Name }}
161
158
Path : ${{ inputs.ModulesOutputPath }}
162
- Shell : ${{ matrix.shell }}
163
- TestType : ' Module'
159
+ Shell : pwsh
160
+ TestType : Module
161
+
162
+ - name : Set status
163
+ if : steps.test.outcome != 'success'
164
+ shell : pwsh
165
+ run : Write-Host "Complete successfully"
166
+
167
+ TestModule-pwsh-macos-latest :
168
+ name : Test module (pwsh, macos-latest)
169
+ needs : BuildModule
170
+ runs-on : macos-latest
171
+ outputs :
172
+ passed : ${{ steps.test.outputs.passed }}
173
+ steps :
174
+ - name : Checkout Code
175
+ uses : actions/checkout@v4
176
+
177
+ - name : Initialize environment
178
+ uses : PSModule/Initialize-PSModule@v1
179
+ with :
180
+ Version : ${{ inputs.Version }}
181
+ Prerelease : ${{ inputs.Prerelease }}
182
+ Shell : pwsh
183
+
184
+ - name : Download module artifact
185
+ uses : actions/download-artifact@v4
186
+ with :
187
+ name : module
188
+ path : ${{ inputs.ModulesOutputPath }}
189
+
190
+ - name : Test built module
191
+ id : test
192
+ uses : PSModule/Test-PSModule@v1
193
+ if : ${{ inputs.SkipTests != true }}
194
+ continue-on-error : true
195
+ with :
196
+ Name : ${{ inputs.Name }}
197
+ Path : ${{ inputs.ModulesOutputPath }}
198
+ Shell : pwsh
199
+ TestType : Module
200
+
201
+ - name : Set status
202
+ if : steps.test.outcome != 'success'
203
+ shell : pwsh
204
+ run : Write-Host "Complete successfully"
205
+
206
+ TestModule-pwsh-windows-latest :
207
+ name : Test module (pwsh, windows-latest)
208
+ needs : BuildModule
209
+ runs-on : windows-latest
210
+ outputs :
211
+ passed : ${{ steps.test.outputs.passed }}
212
+ steps :
213
+ - name : Checkout Code
214
+ uses : actions/checkout@v4
215
+
216
+ - name : Initialize environment
217
+ uses : PSModule/Initialize-PSModule@v1
218
+ with :
219
+ Version : ${{ inputs.Version }}
220
+ Prerelease : ${{ inputs.Prerelease }}
221
+ Shell : pwsh
222
+
223
+ - name : Download module artifact
224
+ uses : actions/download-artifact@v4
225
+ with :
226
+ name : module
227
+ path : ${{ inputs.ModulesOutputPath }}
228
+
229
+ - name : Test built module
230
+ id : test
231
+ uses : PSModule/Test-PSModule@v1
232
+ if : ${{ inputs.SkipTests != true }}
233
+ continue-on-error : true
234
+ with :
235
+ Name : ${{ inputs.Name }}
236
+ Path : ${{ inputs.ModulesOutputPath }}
237
+ Shell : pwsh
238
+ TestType : Module
239
+
240
+ - name : Set status
241
+ if : steps.test.outcome != 'success'
242
+ shell : pwsh
243
+ run : Write-Host "Complete successfully"
244
+
245
+ TestModule-powershell-windows-latest :
246
+ name : Test module (powershell, windows-latest)
247
+ needs : BuildModule
248
+ runs-on : windows-latest
249
+ outputs :
250
+ passed : ${{ steps.test.outputs.passed }}
251
+ steps :
252
+ - name : Checkout Code
253
+ uses : actions/checkout@v4
254
+
255
+ - name : Initialize environment
256
+ uses : PSModule/Initialize-PSModule@v1
257
+ with :
258
+ Version : ${{ inputs.Version }}
259
+ Prerelease : ${{ inputs.Prerelease }}
260
+ Shell : powershell
261
+
262
+ - name : Download module artifact
263
+ uses : actions/download-artifact@v4
264
+ with :
265
+ name : module
266
+ path : ${{ inputs.ModulesOutputPath }}
267
+
268
+ - name : Test built module
269
+ id : test
270
+ uses : PSModule/Test-PSModule@v1
271
+ if : ${{ inputs.SkipTests != true }}
272
+ continue-on-error : true
273
+ with :
274
+ Name : ${{ inputs.Name }}
275
+ Path : ${{ inputs.ModulesOutputPath }}
276
+ Shell : powershell
277
+ TestType : Module
278
+
279
+ - name : Set status
280
+ if : steps.test.outcome != 'success'
281
+ shell : pwsh
282
+ run : Write-Host "Complete successfully"
283
+
284
+ TestModuleStatus :
285
+ name : Test module status
286
+ needs :
287
+ - TestModule-pwsh-ubuntu-latest
288
+ - TestModule-pwsh-macos-latest
289
+ - TestModule-pwsh-windows-latest
290
+ - TestModule-powershell-windows-latest
291
+ runs-on : ubuntu-latest
292
+ if : success() || failure()
293
+ steps :
294
+ - name : Checkout Code
295
+ uses : actions/checkout@v4
296
+
297
+ - name : Initialize environment
298
+ uses : PSModule/Initialize-PSModule@v1
299
+ with :
300
+ Version : ${{ inputs.Version }}
301
+ Prerelease : ${{ inputs.Prerelease }}
302
+
303
+ - name : Download module artifact
304
+ uses : actions/download-artifact@v4
305
+ with :
306
+ name : module
307
+ path : ${{ inputs.ModulesOutputPath }}
308
+
309
+ - name : Summerize tests
310
+ shell : pwsh
311
+ run : |
312
+ Start-LogGroup -Name 'Status'
313
+ $Linux = '${{ needs.TestModule-pwsh-ubuntu-latest.outputs.passed }}' -eq 'true'
314
+ $MacOS = '${{ needs.TestModule-pwsh-macos-latest.outputs.passed }}' -eq 'true'
315
+ $Windows = '${{ needs.TestModule-pwsh-windows-latest.outputs.passed }}' -eq 'true'
316
+ $Desktop = '${{ needs.TestModule-powershell-windows-latest.outputs.passed }}' -eq 'true'
317
+ $Core = $Linux -or $MacOS -or $Windows
318
+
319
+ $Status = [pscustomobject]@{
320
+ Linux = $Linux
321
+ MacOS = $MacOS
322
+ Windows = $Windows
323
+ Desktop = $Desktop
324
+ Core = $Core
325
+ }
326
+
327
+ Write-Host ($Status | Format-Table | Out-String)
328
+
329
+ if (-not ($Core -or $Desktop)) {
330
+ Write-Host "::[error]::No tests passed"
331
+ exit 1
332
+ }
333
+ Stop-LogGroup
334
+
335
+ Start-LogGroup -Name 'Data'
336
+ $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
337
+ $path = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "${{ inputs.ModulesOutputPath }}\$moduleName"
338
+ $moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
339
+
340
+ $data = [pscustomobject]@{
341
+ ModuleName = $moduleName
342
+ Path = $path
343
+ ModuleManifestPath = $moduleManifestPath
344
+ }
345
+ Write-Host ($data | Format-Table | Out-String)
346
+
347
+ if ($Desktop) {
348
+ Add-ModuleManifestData -Path $moduleManifestPath -CompatiblePSEditions 'Desktop'
349
+ Add-ModuleManifestData -Path $moduleManifestPath -Tags 'PSEdition_Desktop'
350
+ }
351
+
352
+ if ($Core) {
353
+ Add-ModuleManifestData -Path $moduleManifestPath -CompatiblePSEditions 'Core'
354
+ Add-ModuleManifestData -Path $moduleManifestPath -Tags 'PSEdition_Core'
355
+ Set-ModuleManifest -Path $moduleManifestPath -PowerShellVersion '7.0'
356
+ } else {
357
+ Set-ModuleManifest -Path $moduleManifestPath -PowerShellVersion '5.1'
358
+ }
359
+
360
+ if ($Linux) {
361
+ Add-ModuleManifestData -Path $moduleManifestPath -Tags 'Linux'
362
+ }
363
+
364
+ if ($MacOS) {
365
+ Add-ModuleManifestData -Path $moduleManifestPath -Tags 'MacOS'
366
+ }
367
+
368
+ if ($Windows) {
369
+ Add-ModuleManifestData -Path $moduleManifestPath -Tags 'Windows'
370
+ }
371
+ Stop-LogGroup
372
+
373
+ Start-LogGroup -Name 'Module Manifest'
374
+ Show-FileContent -Path $moduleManifestPath
375
+ Stop-LogGroup
376
+
377
+ - name : Upload module artifact
378
+ uses : actions/upload-artifact@v4
379
+ with :
380
+ name : module
381
+ path : ${{ inputs.ModulesOutputPath }}
382
+ if-no-files-found : error
383
+ retention-days : 1
384
+ overwrite : true
164
385
165
386
LintDocs :
166
387
name : Lint documentation
@@ -197,8 +418,9 @@ jobs:
197
418
198
419
PublishModule :
199
420
name : Publish module
421
+ if : ${{ needs.TestModuleStatus.result == 'success' && needs.LintDocs.result == 'success' && (success() || failure()) }}
200
422
needs :
201
- - TestModule
423
+ - TestModuleStatus
202
424
- LintDocs
203
425
runs-on : ubuntu-latest
204
426
steps :
0 commit comments