🩹 [Patch]: BeforeAll/AfterAll-ModuleLocal jobs skipped when setup/teardown scripts do not exist#18
Merged
Marius Storhaug (MariusStorhaug) merged 1 commit intomainfrom Mar 27, 2026
Conversation
21c88f4
into
main
17 of 18 checks passed
Copilot started reviewing on behalf of
Marius Storhaug (MariusStorhaug)
March 27, 2026 21:36
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Get-PSModuleSettings action logic so workflow jobs for module-local setup/teardown (BeforeAll-ModuleLocal, AfterAll-ModuleLocal) can be skipped when the corresponding scripts aren’t present, avoiding unnecessary runner allocation.
Changes:
- Detects existence of
tests/BeforeAll.ps1andtests/AfterAll.ps1viaTest-Pathand logs the results. - Gates
BeforeAllModuleLocalontests/BeforeAll.ps1existence. - Gates
AfterAllModuleLocalon the same base module-local conditions as other build/test stages plustests/AfterAll.ps1existence (instead of$true).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Marius Storhaug (MariusStorhaug)
added a commit
to PSModule/Process-PSModule
that referenced
this pull request
Mar 27, 2026
…ts are absent (#300) 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. - Fixes #288 ## Changed: Runner allocation for setup/teardown jobs With the `Get-PSModuleSettings` v1.4.4 update, repositories without `tests/BeforeAll.ps1` or `tests/AfterAll.ps1` no longer allocate runners for the `BeforeAll-ModuleLocal` and `AfterAll-ModuleLocal` jobs. These jobs are now skipped entirely at the settings evaluation stage, before any runner is provisioned. Previously, both jobs always spun up a runner — even when there was nothing to execute. 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. Additionally, `AfterAllModuleLocal` was previously set to `$true` unconditionally. It now uses the same base conditions as `BeforeAllModuleLocal` combined with the script existence check. The workflow-level `always()` condition remains as an additional safeguard for cleanup-after-failure scenarios. ## Technical Details - Bumps `PSModule/Get-PSModuleSettings` from `v1.4.3` (`3d53e12`) to `v1.4.4` (`21c88f4`) in `Get-Settings.yml`. - The action change ([PSModule/Get-PSModuleSettings#18](PSModule/Get-PSModuleSettings#18)) adds `Test-Path` checks for the setup/teardown scripts and sets the `Run.BeforeAllModuleLocal` / `Run.AfterAllModuleLocal` flags accordingly, which the existing workflow `if:` conditions already respect. - No structural changes to any reusable workflow files — only a SHA pin update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
BeforeAll-ModuleLocalandAfterAll-ModuleLocalworkflow jobs no longer allocate runners when the correspondingtests/BeforeAll.ps1ortests/AfterAll.ps1scripts 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-ModuleLocalandAfterAll-ModuleLocaljobs always spun up a runner — even when the repository had notests/BeforeAll.ps1ortests/AfterAll.ps1script. 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-PSModuleSettingsaction detects whether these scripts exist before setting the run flags. If a script is missing, the corresponding job flag is set tofalseand the workflow job is skipped before a runner is allocated.Additionally,
AfterAllModuleLocalwas previously set to$trueunconditionally, relying solely on the workflow-levelif:condition to gate it. It now uses the same base conditions asBeforeAllModuleLocal($shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module)) combined with the script existence check. The workflow-levelalways()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
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.if:conditions inworkflow.yml,BeforeAll-ModuleLocal.yml, andAfterAll-ModuleLocal.ymlalready respect these flags, and the in-workflowTest-Pathguards remain as a safety net.