Commit 21c88f4
authored
🩹 [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.
- Fixes PSModule/Process-PSModule#288
## 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.1 parent 8ec4c9e commit 21c88f4
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
534 | 541 | | |
535 | 542 | | |
536 | 543 | | |
537 | 544 | | |
538 | 545 | | |
539 | 546 | | |
540 | 547 | | |
541 | | - | |
| 548 | + | |
542 | 549 | | |
543 | | - | |
| 550 | + | |
544 | 551 | | |
545 | 552 | | |
546 | 553 | | |
| |||
0 commit comments