Skip to content

Commit ad06b68

Browse files
Clarify module-local workflow phase discovery
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent f156c36 commit ad06b68

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,24 @@ The [PSModule - SourceCode tests](https://github.com/PSModule/Process-PSModule/b
111111

112112
- Imports and tests the module in parallel (matrix) using Pester tests from the module repository.
113113
- 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.
114-
- Supports setup and teardown scripts executed via separate dedicated jobs:
115-
- `BeforeAll`: Runs once before all test matrix jobs to set up the test environment (e.g., deploy infrastructure, download test data).
116-
- `AfterAll`: Runs once after all test matrix jobs complete to clean up the test environment (e.g., remove test resources, clean up databases).
117-
- Setup/teardown scripts are automatically detected in test directories and executed with the same environment variables as the tests.
114+
- Supports two special workflow phase scripts executed via separate dedicated jobs:
115+
- `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).
116+
- `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).
117+
- The workflow checks only those exact repository-root paths; phase detection is non-recursive. Ordinary Advanced test entries may still be discovered recursively under `tests/`, but nested files named `BeforeAll.ps1` or `AfterAll.ps1` do not create workflow phases.
118+
- The two phase scripts run with the same environment variables as the tests.
118119
- This produces a JSON-based report that is used by [Get-PesterTestResults](#get-test-results) evaluate the results of the tests.
119120

120121
### Setup and Teardown Scripts
121122

122123
The workflow supports automatic execution of setup and teardown scripts for module tests:
123124

124-
- Scripts are automatically detected and executed if present.
125-
- If no scripts are found, the workflow continues normally.
125+
- `tests/BeforeAll.ps1` and `tests/AfterAll.ps1` are special workflow phase files, not ordinary recursively discovered test entries.
126+
- Each phase is enabled only when its exact file exists at the root of `tests/`.
127+
- If either file is absent, the workflow skips that phase and continues normally.
126128

127129
#### Setup - `BeforeAll.ps1`
128130

129-
- Place in your test directories (`tests/BeforeAll.ps1`).
131+
- Place at the exact repository-root path `tests/BeforeAll.ps1`.
130132
- Runs once before all test matrix jobs to prepare the test environment.
131133
- Deploy test infrastructure, download test data, initialize databases, or configure services.
132134
- Has access to the same environment variables as your tests (secrets, GitHub token, etc.).
@@ -143,7 +145,7 @@ Write-Host "Test environment ready!"
143145

144146
#### Teardown - `AfterAll.ps1`
145147

146-
- Place in your test directories (`tests/AfterAll.ps1`).
148+
- Place at the exact repository-root path `tests/AfterAll.ps1`.
147149
- Runs once after all test matrix jobs complete to clean up the test environment.
148150
- Remove test resources, clean up databases, stop services, or upload artifacts.
149151
- Has access to the same environment variables as your tests.

0 commit comments

Comments
 (0)