Skip to content

Commit 39743b6

Browse files
🩹 [Refactor]: Clean up Gather-Tests workflow by removing commented-out code and enhancing output handling
1 parent 154cbd0 commit 39743b6

File tree

2 files changed

+63
-26
lines changed

2 files changed

+63
-26
lines changed

‎.github/workflows/Gather-Tests.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ jobs:
7979
Path = $testSuites
8080
}
8181
82-
83-
# $OSsToTest | ForEach-Object {
84-
# $os = $_
85-
# $testSuites | ForEach-Object {
86-
# $testSuite = $_
87-
# $shellsToTest | ForEach-Object {
88-
# $shell = $_
89-
# $testPath = Resolve-Path -Path $testSuite | Select-Object -ExpandProperty Path
90-
# $tests.Add(
91-
# [pscustomobject]@{
92-
# OS = $os
93-
# Path = $testPath
94-
# Shell = $shell
95-
# }
96-
# )
97-
# }
98-
# }
99-
# }
100-
10182
$testsJson = $tests | ConvertTo-Json -Depth 10 -Compress
10283
10384
Write-Output $testsJson

‎.github/workflows/workflow.yml

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,75 @@ jobs:
148148
# Verbose: ${{ inputs.Verbose }}
149149
# Version: ${{ inputs.Version }}
150150

151+
# Gather-Tests:
152+
# # if: ${{ needs.Build-Module.result == 'success' && !cancelled() }}
153+
# # needs:
154+
# # - Build-Module
155+
# uses: ./.github/workflows/Gather-Tests.yml
156+
# with:
157+
# Path: ${{ inputs.Path }}
158+
151159
Gather-Tests:
152-
# if: ${{ needs.Build-Module.result == 'success' && !cancelled() }}
153-
# needs:
154-
# - Build-Module
155-
uses: ./.github/workflows/Gather-Tests.yml
156-
with:
157-
Path: ${{ inputs.Path }}
160+
name: Gather-Tests
161+
runs-on: ubuntu-latest
162+
outputs:
163+
TestSuites: ${{ fromJson(steps.Gather-Tests.outputs.result).TestSuites }}
164+
steps:
165+
- name: Checkout Code
166+
uses: actions/checkout@v4
167+
168+
- name: Gather-Tests
169+
uses: PSModule/GitHub-Script@v1
170+
id: Gather-Tests
171+
with:
172+
ShowOutput: true
173+
WorkingDirectory: ${{ inputs.Path }}
174+
Script: |
175+
$shellsToTest = @('pwsh')
176+
$OSsToTest = @('ubuntu-latest', 'macos-latest', 'windows-latest')
177+
178+
$testsPath = Resolve-Path 'tests' | Select-Object -ExpandProperty Path
179+
if (-not (Test-Path -Path $testsPath)) {
180+
Write-Host "No tests found"
181+
exit 0
182+
}
183+
184+
Write-Host "Tests found at [$testsPath]"
185+
186+
$testSuites = @()
187+
Get-ChildItem -Path $testsPath -Directory | ForEach-Object {
188+
$testSuites += $_.FullName
189+
}
190+
if (-not $testSuites) {
191+
$testSuites += @($testsPath)
192+
}
193+
194+
$testSuites | Format-List
195+
196+
$tests = @{
197+
OS = $OSsToTest
198+
Path = $testSuites
199+
}
200+
201+
$testsJson = $tests | ConvertTo-Json -Depth 10 -Compress
202+
203+
Write-Output $testsJson
204+
205+
Set-GitHubOutput -Name Tests -Value $tests -Verbose -Debug -Confirm:$false
206+
$output = Get-Content $env:GITHUB_OUTPUT -Raw
207+
Write-Output $output
208+
Set-GitHubStepSummary -Summary $output
209+
210+
211+
212+
213+
158214
159215
TestModuleLocal:
160216
needs:
161217
- Gather-Tests
162218
strategy:
163-
matrix: ${{ toJson(needs.Gather-Tests.outputs.TestSuites) }}
219+
matrix: ${{ fromJson(needs.Gather-Tests.outputs.TestSuites) }}
164220
runs-on: ${{ matrix.OS }}
165221
steps:
166222
- name: Test

0 commit comments

Comments
 (0)