@@ -531,16 +531,23 @@ LogGroup 'Calculate Job Run Conditions:' {
531531 # Note: $shouldPrerelease already requires $hasImportantChanges, so no separate check needed.
532532 $shouldRunBuildTest = $isNotAbandonedPR -and $hasImportantChanges
533533
534+ # Check if setup/teardown scripts exist in the repository
535+ $hasBeforeAllScript = Test-Path - Path ' tests/BeforeAll.ps1'
536+ $hasAfterAllScript = Test-Path - Path ' tests/AfterAll.ps1'
537+ Write-Host " Setup/teardown script detection:"
538+ Write-Host " tests/BeforeAll.ps1 exists: $hasBeforeAllScript "
539+ Write-Host " tests/AfterAll.ps1 exists: $hasAfterAllScript "
540+
534541 # Create Run object with all job-specific conditions
535542 $run = [pscustomobject ]@ {
536543 LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip )
537544 BuildModule = $shouldRunBuildTest -and (-not $settings.Build.Module.Skip )
538545 TestSourceCode = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.SourceCode )
539546 LintSourceCode = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.SourceCode )
540547 TestModule = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.PSModule )
541- BeforeAllModuleLocal = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module )
548+ BeforeAllModuleLocal = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module ) -and $hasBeforeAllScript
542549 TestModuleLocal = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module )
543- AfterAllModuleLocal = $true # Always runs if Test-ModuleLocal was not skipped
550+ AfterAllModuleLocal = $shouldRunBuildTest -and ( $null -ne $settings .TestSuites.Module ) -and $hasAfterAllScript
544551 GetTestResults = $shouldRunBuildTest -and (-not $settings.Test.TestResults.Skip ) -and (
545552 ($null -ne $settings.TestSuites.SourceCode ) -or ($null -ne $settings.TestSuites.PSModule ) -or ($null -ne $settings.TestSuites.Module )
546553 )
0 commit comments