Skip to content

Commit 65591bd

Browse files
📖 [Docs]: Module-local workflow phases documented as root-only (#100)
Module authors can now distinguish the two root-only workflow phase scripts from recursively discovered module-local test entries. ## Fixed: Setup and teardown discovery is unambiguous `tests/BeforeAll.ps1` and `tests/AfterAll.ps1` are documented as exact, non-recursive paths that run once around the module-local test matrix. Ordinary Advanced test entries remain separately eligible for recursive discovery under `tests/`. --- <details> <summary>Technical details</summary> - Corrects `src/docs/Frameworks/Process-PSModule/pipeline-stages.md` to match the exact `Test-Path` checks in Process-PSModule main. - Separates workflow phase detection from recursive configuration, container, and test-file discovery. - Implementation plan progress: all tasks in #99 are complete. - Validation passed: documentation indexes, links, Zensical build, Super-Linter, and diff checks. - Copilot review converged after the clarity feedback was addressed; the final round added no comments. </details> <details> <summary>Relevant issues (or links)</summary> - Fixes #99 - PSModule/docs#88 </details> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 6600eda commit 65591bd

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎src/docs/Frameworks/Process-PSModule/pipeline-stages.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ The [PSModule - SourceCode tests](https://github.com/PSModule/Process-PSModule/b
112112
- Imports and tests the module in parallel (matrix) using module-local Pester tests.
113113
- Discovers module-local tests recursively under `tests/`, applying the [per-directory precedence](#module-local-test-discovery) independently at every level.
114114
- Module test files declare a Pester **6.x** requirement via `#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }` — a convention module authors add to each `*.Tests.ps1`, not something this pipeline injects. The [Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action installs a matching `6.x`, so minor and patch updates flow in automatically while a new major stays a deliberate, reviewed change.
115-
- Supports setup and teardown scripts executed via separate dedicated jobs:
116-
- `BeforeAll`: Runs root `tests/BeforeAll.ps1` once before all test matrix jobs to set up the test environment (e.g., deploy infrastructure, download test data).
117-
- `AfterAll`: Runs root `tests/AfterAll.ps1` once after all test matrix jobs complete to clean up the test environment (e.g., remove test resources, clean up databases).
118-
- Setup and teardown detection is not recursive; nested files with those names are not workflow phases.
115+
- Supports two special workflow phase scripts executed via separate dedicated jobs:
116+
- `tests/BeforeAll.ps1`: Runs once before all module-local test matrix jobs to set up the test environment (e.g., deploy infrastructure, download test data).
117+
- `tests/AfterAll.ps1`: Runs once after all module-local test matrix jobs complete to clean up the test environment (e.g., remove test resources, clean up databases).
118+
- The workflow checks only those exact repository-root paths; phase detection is non-recursive. This is separate from the recursive discovery of ordinary module-local test entries described below; nested files named `BeforeAll.ps1` or `AfterAll.ps1` do not create workflow phases.
119+
- The two phase scripts run with the same environment variables as the tests.
119120
- This produces a JSON-based report that is used by [Get-PesterTestResults](#get-test-results) to evaluate the results of the tests.
120121

121122
### Module-local test discovery
@@ -136,13 +137,13 @@ Every discovered artifact needs a unique prefix before its first dot because tha
136137

137138
The workflow supports automatic execution of setup and teardown scripts for module tests:
138139

139-
- The exact root paths `tests/BeforeAll.ps1` and `tests/AfterAll.ps1` are detected and executed if present.
140-
- If no scripts are found, the workflow continues normally.
141-
- Detection is not recursive.
140+
- `tests/BeforeAll.ps1` and `tests/AfterAll.ps1` are special workflow phase files, not ordinary recursively discovered test entries.
141+
- Each phase is enabled only when its exact file exists at the root of `tests/`.
142+
- If either file is absent, the workflow skips that phase and continues normally.
142143

143144
#### Setup - `BeforeAll.ps1`
144145

145-
- Place at the root test path `tests/BeforeAll.ps1`.
146+
- Place at the exact repository-root path `tests/BeforeAll.ps1`.
146147
- Runs once before all test matrix jobs to prepare the test environment.
147148
- Deploy test infrastructure, download test data, initialize databases, or configure services.
148149
- Has access to the same environment variables as your tests (secrets, GitHub token, etc.).
@@ -159,7 +160,7 @@ Write-Host "Test environment ready!"
159160

160161
#### Teardown - `AfterAll.ps1`
161162

162-
- Place at the root test path `tests/AfterAll.ps1`.
163+
- Place at the exact repository-root path `tests/AfterAll.ps1`.
163164
- Runs once after all test matrix jobs complete to clean up the test environment.
164165
- Remove test resources, clean up databases, stop services, or upload artifacts.
165166
- Has access to the same environment variables as your tests.

0 commit comments

Comments
 (0)