@@ -178,88 +178,11 @@ jobs:
178178 Version : ${{ inputs.Version }}
179179 WorkingDirectory : ${{ inputs.WorkingDirectory }}
180180
181- BeforeAll-ModuleLocal :
182- if : ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.ModuleTestSuites != '[]' }}
183- name : BeforeAll Setup
184- runs-on : ubuntu-latest
185- needs :
186- - Build-Module
187- - Get-Settings
188- outputs :
189- hasBeforeAll : ${{ steps.check-beforeall.outputs.hasBeforeAll }}
190- hasAfterAll : ${{ steps.check-afterall.outputs.hasAfterAll }}
191- steps :
192- - name : Checkout Code
193- uses : actions/checkout@v4
194-
195- - name : Check for BeforeAll/AfterAll scripts
196- id : check-beforeall
197- shell : bash
198- working-directory : ${{ inputs.WorkingDirectory }}
199- run : |
200- hasBeforeAll=false
201- hasAfterAll=false
202-
203- # Check each test path for BeforeAll/AfterAll scripts
204- testSuites='${{ needs.Get-Settings.outputs.ModuleTestSuites }}'
205- echo "Test suites: $testSuites"
206-
207- if echo "$testSuites" | jq -e '.[] | select(.TestPath)' > /dev/null 2>&1; then
208- for testPath in $(echo "$testSuites" | jq -r '.[].TestPath' | sort -u); do
209- echo "Checking test path: $testPath"
210- if [ -f "$testPath/BeforeAll.ps1" ]; then
211- echo "BeforeAll.ps1 found in $testPath"
212- hasBeforeAll=true
213- fi
214- if [ -f "$testPath/AfterAll.ps1" ]; then
215- echo "AfterAll.ps1 found in $testPath"
216- hasAfterAll=true
217- fi
218- done
219- fi
220-
221- echo "hasBeforeAll=$hasBeforeAll" >> $GITHUB_OUTPUT
222- echo "hasAfterAll=$hasAfterAll" >> $GITHUB_OUTPUT
223-
224- - name : Install-PSModuleHelpers
225- if : steps.check-beforeall.outputs.hasBeforeAll == 'true'
226- uses : PSModule/Install-PSModuleHelpers@v1
227-
228- - name : Run BeforeAll scripts
229- if : steps.check-beforeall.outputs.hasBeforeAll == 'true'
230- shell : pwsh
231- working-directory : ${{ inputs.WorkingDirectory }}
232- env :
233- TEST_APP_ENT_CLIENT_ID : ${{ secrets.TEST_APP_ENT_CLIENT_ID }}
234- TEST_APP_ENT_PRIVATE_KEY : ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }}
235- TEST_APP_ORG_CLIENT_ID : ${{ secrets.TEST_APP_ORG_CLIENT_ID }}
236- TEST_APP_ORG_PRIVATE_KEY : ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }}
237- TEST_USER_ORG_FG_PAT : ${{ secrets.TEST_USER_ORG_FG_PAT }}
238- TEST_USER_USER_FG_PAT : ${{ secrets.TEST_USER_USER_FG_PAT }}
239- TEST_USER_PAT : ${{ secrets.TEST_USER_PAT }}
240- GITHUB_TOKEN : ${{ github.token }}
241- run : |
242- $testSuites = '${{ needs.Get-Settings.outputs.ModuleTestSuites }}' | ConvertFrom-Json
243- $processedPaths = @()
244-
245- foreach ($suite in $testSuites) {
246- $testPath = $suite.TestPath
247- if ($testPath -and $testPath -notin $processedPaths) {
248- $beforeAllScript = Join-Path $testPath "BeforeAll.ps1"
249- if (Test-Path $beforeAllScript) {
250- Write-Host "Running BeforeAll setup script: $beforeAllScript"
251- & $beforeAllScript
252- $processedPaths += $testPath
253- }
254- }
255- }
256-
257181 Test-ModuleLocal :
258182 if : ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.ModuleTestSuites != '[]' }}
259183 needs :
260184 - Build-Module
261185 - Get-Settings
262- - BeforeAll-ModuleLocal
263186 strategy :
264187 fail-fast : false
265188 matrix :
@@ -278,48 +201,6 @@ jobs:
278201 Version : ${{ inputs.Version }}
279202 WorkingDirectory : ${{ inputs.WorkingDirectory }}
280203
281- AfterAll-ModuleLocal :
282- if : ${{ always() && needs.BeforeAll-ModuleLocal.outputs.hasAfterAll == 'true' }}
283- name : AfterAll Teardown
284- runs-on : ubuntu-latest
285- needs :
286- - BeforeAll-ModuleLocal
287- - Test-ModuleLocal
288- steps :
289- - name : Checkout Code
290- uses : actions/checkout@v4
291-
292- - name : Install-PSModuleHelpers
293- uses : PSModule/Install-PSModuleHelpers@v1
294-
295- - name : Run AfterAll scripts
296- shell : pwsh
297- working-directory : ${{ inputs.WorkingDirectory }}
298- env :
299- TEST_APP_ENT_CLIENT_ID : ${{ secrets.TEST_APP_ENT_CLIENT_ID }}
300- TEST_APP_ENT_PRIVATE_KEY : ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }}
301- TEST_APP_ORG_CLIENT_ID : ${{ secrets.TEST_APP_ORG_CLIENT_ID }}
302- TEST_APP_ORG_PRIVATE_KEY : ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }}
303- TEST_USER_ORG_FG_PAT : ${{ secrets.TEST_USER_ORG_FG_PAT }}
304- TEST_USER_USER_FG_PAT : ${{ secrets.TEST_USER_USER_FG_PAT }}
305- TEST_USER_PAT : ${{ secrets.TEST_USER_PAT }}
306- GITHUB_TOKEN : ${{ github.token }}
307- run : |
308- $testSuites = '${{ needs.Get-Settings.outputs.ModuleTestSuites }}' | ConvertFrom-Json
309- $processedPaths = @()
310-
311- foreach ($suite in $testSuites) {
312- $testPath = $suite.TestPath
313- if ($testPath -and $testPath -notin $processedPaths) {
314- $afterAllScript = Join-Path $testPath "AfterAll.ps1"
315- if (Test-Path $afterAllScript) {
316- Write-Host "Running AfterAll teardown script: $afterAllScript"
317- & $afterAllScript
318- $processedPaths += $testPath
319- }
320- }
321- }
322-
323204 Get-TestResults :
324205 if : needs.Get-Settings.result == 'success' && !fromJson(needs.Get-Settings.outputs.Settings).Test.TestResults.Skip && (needs.Get-Settings.outputs.SourceCodeTestSuites != '[]' || needs.Get-Settings.outputs.PSModuleTestSuites != '[]' || needs.Get-Settings.outputs.ModuleTestSuites != '[]') && (always() && !cancelled())
325206 needs :
@@ -328,7 +209,6 @@ jobs:
328209 - Lint-SourceCode
329210 - Test-Module
330211 - Test-ModuleLocal
331- - AfterAll-ModuleLocal
332212 uses : ./.github/workflows/Get-TestResults.yml
333213 secrets : inherit
334214 with :
@@ -346,7 +226,6 @@ jobs:
346226 - Get-Settings
347227 - Test-Module
348228 - Test-ModuleLocal
349- - AfterAll-ModuleLocal
350229 uses : ./.github/workflows/Get-CodeCoverage.yml
351230 secrets : inherit
352231 with :
0 commit comments