v1.4.4
🩹 [Patch]: BeforeAll/AfterAll-ModuleLocal jobs skipped when setup/teardown scripts do not exist (#18)
The BeforeAll-ModuleLocal and AfterAll-ModuleLocal workflow jobs no longer allocate runners when the corresponding tests/BeforeAll.ps1 or tests/AfterAll.ps1 scripts do not exist in the repository. Repositories without setup/teardown scripts now skip these jobs entirely, saving runner time on every workflow run.
Changed: Runner allocation for setup/teardown jobs
Previously, BeforeAll-ModuleLocal and AfterAll-ModuleLocal jobs always spun up a runner — even when the repository had no tests/BeforeAll.ps1 or tests/AfterAll.ps1 script. The runner would check out the repo, invoke the GitHub-Script action, find no script, and exit gracefully. This wasted runner time on every workflow run for the majority of repositories that have no setup/teardown requirements.
Now, the Get-PSModuleSettings action detects whether these scripts exist before setting the run flags. If a script is missing, the corresponding job flag is set to false and the workflow job is skipped before a runner is allocated.
Additionally, AfterAllModuleLocal was previously set to $true unconditionally, relying solely on the workflow-level if: condition to gate it. It now uses the same base conditions as BeforeAllModuleLocal ($shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module)) combined with the script existence check. The workflow-level always() condition remains as an additional safeguard for cleanup-after-failure scenarios.
Repositories that include these scripts are unaffected — both jobs continue to run as before.
Technical Details
- In
src/main.ps1, addedTest-Pathchecks fortests/BeforeAll.ps1andtests/AfterAll.ps1in the'Calculate Job Run Conditions'LogGroup block, before the$runobject construction. BeforeAllModuleLocalflag updated from$shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module)to$shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) -and $hasBeforeAllScript.AfterAllModuleLocalflag updated from$trueto$shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) -and $hasAfterAllScript.- Added log output for script existence detection, consistent with how other conditions are logged.
- No workflow YAML changes needed — the existing
if:conditions inworkflow.yml,BeforeAll-ModuleLocal.yml, andAfterAll-ModuleLocal.ymlalready respect these flags, and the in-workflowTest-Pathguards remain as a safety net.