Skip to content

v1.4.4

Choose a tag to compare

@github-actions github-actions released this 27 Mar 21:36
· 2 commits to main since this release
21c88f4

🩹 [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, added Test-Path checks for tests/BeforeAll.ps1 and tests/AfterAll.ps1 in the 'Calculate Job Run Conditions' LogGroup block, before the $run object construction.
  • BeforeAllModuleLocal flag updated from $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) to $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) -and $hasBeforeAllScript.
  • AfterAllModuleLocal flag updated from $true to $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 in workflow.yml, BeforeAll-ModuleLocal.yml, and AfterAll-ModuleLocal.yml already respect these flags, and the in-workflow Test-Path guards remain as a safety net.