Skip to content

Commit ec5c76c

Browse files
🚀 [Feature]: Add ability to skip OS and shell specific tests (#23)
## Description - Adds the ability to use a parameter to skip specific tests: - `SkipTests = 'All'` - Skips all tests - `SkipTests = 'MacOS'` - Skips tests on MacOS - `SkipTests = 'Core'` - Skips pwsh tests (Ubuntu + MacOS + Windows(pwsh)), but still runs Windows PowerShell tests. - Fixes #24 ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent c4982c8 commit ec5c76c

File tree

4 files changed

+159
-44
lines changed

4 files changed

+159
-44
lines changed

.github/workflows/Workflow-Test-Default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
ModulesOutputPath: tests/outputs/modules
2424
DocsOutputPath: tests/outputs/docs
2525
TestProcess: true
26+
SkipTests: Module

.github/workflows/Workflow-Test-WithManifest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
ModulesOutputPath: tests/outputs/modules
2424
DocsOutputPath: tests/outputs/docs
2525
TestProcess: true
26+
SkipTests: Desktop, Linux

.github/workflows/workflow.yml

Lines changed: 156 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ on:
2727
required: false
2828
default: outputs/docs
2929
SkipTests:
30-
type: boolean
31-
description: Whether to skip tests.
30+
type: string
31+
description: Defines what types of tests to skip. Allowed values are 'All', 'SourceCode', 'Module', 'None', 'macOS', 'Windows', 'Linux', 'Desktop', 'Core'.
3232
required: false
33-
default: false
33+
default: None
3434
TestProcess:
3535
type: boolean
3636
description: Whether to test the process.
@@ -55,17 +55,10 @@ permissions:
5555
statuses: write
5656

5757
jobs:
58-
TestSourceCode:
59-
name: Test code
60-
strategy:
61-
fail-fast: false
62-
matrix:
63-
shell: [pwsh]
64-
os: [ubuntu-latest, macos-latest, windows-latest]
65-
include:
66-
- shell: powershell
67-
os: windows-latest
68-
runs-on: ${{ matrix.os }}
58+
TestSourceCode-pwsh-ubuntu-latest:
59+
name: Test source code (pwsh, ubuntu-latest)
60+
if: ${{ !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'SourceCode') || contains(inputs.SkipTests, 'Linux') || contains(inputs.SkipTests, 'Core')) }}
61+
runs-on: ubuntu-latest
6962
steps:
7063
- name: Checkout Code
7164
uses: actions/checkout@v4
@@ -75,20 +68,103 @@ jobs:
7568
with:
7669
Version: ${{ inputs.Version }}
7770
Prerelease: ${{ inputs.Prerelease }}
78-
Shell: ${{ matrix.shell }}
71+
Shell: pwsh
7972

80-
- name: Test built module
73+
- name: Test source code
74+
id: test
75+
uses: PSModule/Test-PSModule@v1
76+
with:
77+
Name: ${{ inputs.Name }}
78+
Path: ${{ inputs.Path }}
79+
Shell: pwsh
80+
TestType: SourceCode
81+
82+
TestSourceCode-pwsh-macos-latest:
83+
name: Test source code (pwsh, macos-latest)
84+
if: ${{ !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'SourceCode' ) || contains(inputs.SkipTests, 'macOS') || contains(inputs.SkipTests, 'Core')) }}
85+
runs-on: macos-latest
86+
outputs:
87+
passed: ${{ steps.test.outputs.passed }}
88+
steps:
89+
- name: Checkout Code
90+
uses: actions/checkout@v4
91+
92+
- name: Initialize environment
93+
uses: PSModule/Initialize-PSModule@v1
94+
with:
95+
Version: ${{ inputs.Version }}
96+
Prerelease: ${{ inputs.Prerelease }}
97+
Shell: pwsh
98+
99+
- name: Test source code
100+
id: test
101+
uses: PSModule/Test-PSModule@v1
102+
with:
103+
Name: ${{ inputs.Name }}
104+
Path: ${{ inputs.Path }}
105+
Shell: pwsh
106+
TestType: SourceCode
107+
108+
TestSourceCode-pwsh-windows-latest:
109+
name: Test source code (pwsh, windows-latest)
110+
if: ${{ !(contains(inputs.SkipTests, 'All' ) || contains(inputs.SkipTests, 'SourceCode' ) || contains(inputs.SkipTests, 'Windows') || contains(inputs.SkipTests, 'Core')) }}
111+
runs-on: windows-latest
112+
outputs:
113+
passed: ${{ steps.test.outputs.passed }}
114+
steps:
115+
- name: Checkout Code
116+
uses: actions/checkout@v4
117+
118+
- name: Initialize environment
119+
uses: PSModule/Initialize-PSModule@v1
120+
with:
121+
Version: ${{ inputs.Version }}
122+
Prerelease: ${{ inputs.Prerelease }}
123+
Shell: pwsh
124+
125+
- name: Test source code
126+
id: test
127+
uses: PSModule/Test-PSModule@v1
128+
with:
129+
Name: ${{ inputs.Name }}
130+
Path: ${{ inputs.Path }}
131+
Shell: pwsh
132+
TestType: SourceCode
133+
134+
TestSourceCode-powershell-windows-latest:
135+
name: Test source code (powershell, windows-latest)
136+
if: ${{ !(contains(inputs.SkipTests, 'All' ) || contains(inputs.SkipTests, 'SourceCode' ) || contains(inputs.SkipTests, 'Windows') || contains(inputs.SkipTests, 'Desktop')) }}
137+
runs-on: windows-latest
138+
outputs:
139+
passed: ${{ steps.test.outputs.passed }}
140+
steps:
141+
- name: Checkout Code
142+
uses: actions/checkout@v4
143+
144+
- name: Initialize environment
145+
uses: PSModule/Initialize-PSModule@v1
146+
with:
147+
Version: ${{ inputs.Version }}
148+
Prerelease: ${{ inputs.Prerelease }}
149+
Shell: powershell
150+
151+
- name: Test source code
152+
id: test
81153
uses: PSModule/Test-PSModule@v1
82-
if: ${{ inputs.SkipTests != true }}
83154
with:
84155
Name: ${{ inputs.Name }}
85156
Path: ${{ inputs.Path }}
86-
Shell: ${{ matrix.shell }}
157+
Shell: powershell
87158
TestType: SourceCode
88159

89160
BuildModule:
90161
name: Build module
91-
needs: TestSourceCode
162+
if: ${{ contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-ubuntu-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-macos-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-windows-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-powershell-windows-latest.result) && !cancelled() }}
163+
needs:
164+
- TestSourceCode-pwsh-ubuntu-latest
165+
- TestSourceCode-pwsh-macos-latest
166+
- TestSourceCode-pwsh-windows-latest
167+
- TestSourceCode-powershell-windows-latest
92168
runs-on: ubuntu-latest
93169
steps:
94170
- name: Checkout Code
@@ -127,6 +203,7 @@ jobs:
127203
#This is necessary as there is no way to get output from a matrix job
128204
TestModule-pwsh-ubuntu-latest:
129205
name: Test module (pwsh, ubuntu-latest)
206+
if: ${{ needs.BuildModule.result == 'success' && !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'Module') || contains(inputs.SkipTests, 'Linux') || contains(inputs.SkipTests, 'Core')) && !cancelled() }}
130207
needs: BuildModule
131208
runs-on: ubuntu-latest
132209
outputs:
@@ -151,7 +228,6 @@ jobs:
151228
- name: Test built module
152229
id: test
153230
uses: PSModule/Test-PSModule@v1
154-
if: ${{ inputs.SkipTests != true }}
155231
continue-on-error: true
156232
with:
157233
Name: ${{ inputs.Name }}
@@ -166,6 +242,7 @@ jobs:
166242

167243
TestModule-pwsh-macos-latest:
168244
name: Test module (pwsh, macos-latest)
245+
if: ${{ needs.BuildModule.result == 'success' && !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'Module') || contains(inputs.SkipTests, 'macOS') || contains(inputs.SkipTests, 'Core')) && !cancelled() }}
169246
needs: BuildModule
170247
runs-on: macos-latest
171248
outputs:
@@ -190,7 +267,6 @@ jobs:
190267
- name: Test built module
191268
id: test
192269
uses: PSModule/Test-PSModule@v1
193-
if: ${{ inputs.SkipTests != true }}
194270
continue-on-error: true
195271
with:
196272
Name: ${{ inputs.Name }}
@@ -205,6 +281,7 @@ jobs:
205281

206282
TestModule-pwsh-windows-latest:
207283
name: Test module (pwsh, windows-latest)
284+
if: ${{ needs.BuildModule.result == 'success' && !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'Module') || contains(inputs.SkipTests, 'Windows') || contains(inputs.SkipTests, 'Core')) && !cancelled() }}
208285
needs: BuildModule
209286
runs-on: windows-latest
210287
outputs:
@@ -229,7 +306,6 @@ jobs:
229306
- name: Test built module
230307
id: test
231308
uses: PSModule/Test-PSModule@v1
232-
if: ${{ inputs.SkipTests != true }}
233309
continue-on-error: true
234310
with:
235311
Name: ${{ inputs.Name }}
@@ -244,6 +320,7 @@ jobs:
244320

245321
TestModule-powershell-windows-latest:
246322
name: Test module (powershell, windows-latest)
323+
if: ${{ needs.BuildModule.result == 'success' && !(contains(inputs.SkipTests, 'All') || contains(inputs.SkipTests, 'Module') || contains(inputs.SkipTests, 'Windows') || contains(inputs.SkipTests, 'Desktop')) && !cancelled() }}
247324
needs: BuildModule
248325
runs-on: windows-latest
249326
outputs:
@@ -268,7 +345,6 @@ jobs:
268345
- name: Test built module
269346
id: test
270347
uses: PSModule/Test-PSModule@v1
271-
if: ${{ inputs.SkipTests != true }}
272348
continue-on-error: true
273349
with:
274350
Name: ${{ inputs.Name }}
@@ -283,13 +359,13 @@ jobs:
283359

284360
TestModuleStatus:
285361
name: Test module status
362+
if: ${{ contains(fromJson('["success", "skipped"]'), needs.TestModule-pwsh-ubuntu-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestModule-pwsh-macos-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestModule-pwsh-windows-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestModule-powershell-windows-latest.result) && !cancelled() }}
286363
needs:
287364
- TestModule-pwsh-ubuntu-latest
288365
- TestModule-pwsh-macos-latest
289366
- TestModule-pwsh-windows-latest
290367
- TestModule-powershell-windows-latest
291368
runs-on: ubuntu-latest
292-
if: success() || failure()
293369
steps:
294370
- name: Checkout Code
295371
uses: actions/checkout@v4
@@ -309,28 +385,62 @@ jobs:
309385
- name: Summerize tests
310386
shell: pwsh
311387
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)
388+
Start-LogGroup -Name 'Passed tests'
389+
390+
$linuxPassed = '${{ needs.TestModule-pwsh-ubuntu-latest.outputs.passed }}' -eq 'true'
391+
$linuxSkipped = '${{ needs.TestModule-pwsh-ubuntu-latest.result }}' -eq 'skipped'
392+
$macOSPassed = '${{ needs.TestModule-pwsh-macos-latest.outputs.passed }}' -eq 'true'
393+
$macOSSkipped = '${{ needs.TestModule-pwsh-macos-latest.result }}' -eq 'skipped'
394+
$windowsPassed = '${{ needs.TestModule-pwsh-windows-latest.outputs.passed }}' -eq 'true'
395+
$windowsSkipped = '${{ needs.TestModule-pwsh-windows-latest.result }}' -eq 'skipped'
396+
$desktopPassed = '${{ needs.TestModule-powershell-windows-latest.outputs.passed }}' -eq 'true'
397+
$desktopSkipped = '${{ needs.TestModule-powershell-windows-latest.result }}' -eq 'skipped'
398+
$corePassed = $linuxPassed -or $macOSPassed -or $windowsPassed
399+
$coreSkipped = $linuxSkipped -and $macOSSkipped -and $windowsSkipped
400+
$anyPassed = $corePassed -or $desktopPassed
401+
$allSkipped = $coreSkipped -and $desktopSkipped
402+
403+
$Status = @(
404+
[pscustomobject]@{
405+
Name = 'Linux'
406+
Icon = $linuxSkipped ? '⚠️' : $linuxPassed ? '✅' : '❌'
407+
Status = $linuxSkipped ? 'Skipped' : $linuxPassed ? 'Passed' : 'Failed'
408+
}
409+
[pscustomobject]@{
410+
Name = 'MacOS'
411+
Icon = $macOSSkipped ? '⚠️' : $macOSPassed ? '✅' : '❌'
412+
Status = $macOSSkipped ? 'Skipped' : $macOSPassed ? 'Passed' : 'Failed'
413+
}
414+
[pscustomobject]@{
415+
Name = 'Windows'
416+
Icon = $windowsSkipped ? '⚠️' : $windowsPassed ? '✅' : '❌'
417+
Status = $windowsSkipped ? 'Skipped' : $windowsPassed ? 'Passed' : 'Failed'
418+
}
419+
[pscustomobject]@{
420+
Name = 'Desktop'
421+
Icon = $desktopSkipped ? '⚠️' : $desktopPassed ? '✅' : '❌'
422+
Status = $desktopSkipped ? 'Skipped' : $desktopPassed ? 'Passed' : 'Failed'
423+
}
424+
[pscustomobject]@{
425+
Name = 'Core'
426+
Icon = $coreSkipped ? '⚠️' : $corePassed ? '✅' : '❌'
427+
Status = $coreSkipped ? 'Skipped' : $corePassed ? 'Passed' : 'Failed'
428+
}
429+
[pscustomobject]@{
430+
Name = 'Result'
431+
Icon = $allSkipped ? '⚠️' : $anyPassed ? '✅' : '❌'
432+
Status = $allSkipped ? 'Skipped' : $anyPassed ? 'Passed' : 'Failed'
433+
}
434+
)
435+
436+
Write-Host ($Status | Format-Table | Out-String)
437+
($Status | New-MDTable) | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
438+
Stop-LogGroup
328439
329-
if (-not ($Core -or $Desktop)) {
440+
if (-not $anyPassed -and -not $allSkipped) {
330441
Write-Host "::[error]::No tests passed"
331442
exit 1
332443
}
333-
Stop-LogGroup
334444
335445
Start-LogGroup -Name 'Data'
336446
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
@@ -346,6 +456,8 @@ jobs:
346456
347457
Set-ModuleManifest -Path $moduleManifestPath -PowerShellVersion '5.1'
348458
459+
#TODO: DONT OVERRIDE MANIFEST
460+
349461
if ($Desktop) {
350462
Add-ModuleManifestData -Path $moduleManifestPath -CompatiblePSEditions 'Desktop'
351463
Add-ModuleManifestData -Path $moduleManifestPath -Tags 'PSEdition_Desktop'
@@ -386,6 +498,7 @@ jobs:
386498

387499
LintDocs:
388500
name: Lint documentation
501+
if: ${{ needs.BuildModule.result == 'success' && !cancelled() }}
389502
needs: BuildModule
390503
runs-on: ubuntu-latest
391504
steps:
@@ -419,7 +532,7 @@ jobs:
419532

420533
PublishModule:
421534
name: Publish module
422-
if: ${{ needs.TestModuleStatus.result == 'success' && needs.LintDocs.result == 'success' && (success() || failure()) }}
535+
if: ${{ needs.TestModuleStatus.result == 'success' && needs.LintDocs.result == 'success' && !cancelled() }}
423536
needs:
424537
- TestModuleStatus
425538
- LintDocs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
| `Path` | `string` | The path to the source code of the module. | `false` | `src` |
7272
| `ModulesOutputPath` | `string` | The path to the output directory for the modules. | `false` | `outputs/modules` |
7373
| `DocsOutputPath` | `string` | The path to the output directory for the documentation. | `false` | `outputs/docs` |
74-
| `SkipTests` | `boolean` | Whether to skip the tests. | false | `false` |
74+
| `SkipTests` | `string` | Defines what types of tests to skip. Allowed values are 'All', 'SourceCode', 'Module', 'None', 'macOS', 'Windows', 'Linux', 'Desktop', 'Core'. | false | `None` |
7575
| `TestProcess` | `boolean` | Whether to test the process. | false | `false` |
7676

7777
### Secrets

0 commit comments

Comments
 (0)