Skip to content

Commit 827d022

Browse files
fix: Enhance documentation clarity and formatting across multiple files, including README, action contracts, workflow integration, and data model. Standardize code block syntax and improve readability in execution flow and error messages.
1 parent c219559 commit 827d022

File tree

7 files changed

+98
-76
lines changed

7 files changed

+98
-76
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ Write-Host "Cleanup completed!"
302302
- If no scripts are found, the workflow continues normally
303303

304304
**Execution Order:**
305+
305306
The workflow executes setup and teardown scripts using separate dedicated jobs with the following order:
306-
```
307+
308+
```plaintext
307309
BeforeAll-ModuleLocal → Test-ModuleLocal (matrix) → AfterAll-ModuleLocal → Get-TestResults/Get-CodeCoverage
308310
```
309311

specs/001-building-on-this/contracts/action.yml.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,20 @@ Scripts (BeforeAll.ps1, AfterAll.ps1) can assume:
307307
### Error Messages Contract
308308

309309
**Invalid Mode**:
310-
```
310+
311+
```plaintext
311312
Invalid mode '$mode'. Mode must be 'before' or 'after'.
312313
```
313314

314315
**Script Execution Error (before)**:
315-
```
316+
317+
```plaintext
316318
BeforeAll script failed: [absolute-path] - [error-message]
317319
```
318320

319321
**Script Execution Error (after)**:
320-
```
322+
323+
```plaintext
321324
WARNING: AfterAll script failed: [absolute-path] - [error-message]
322325
```
323326

specs/001-building-on-this/contracts/workflow-integration.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ BeforeAll-ModuleLocal:
6464
- ~92 lines of code
6565
6666
**New Implementation**:
67+
6768
```yaml
6869
AfterAll-ModuleLocal:
6970
name: AfterAll-ModuleLocal
@@ -97,6 +98,7 @@ AfterAll-ModuleLocal:
9798
```
9899
99100
**Key Changes**:
101+
100102
- Remove Install-PSModuleHelpers step (moved to composite action)
101103
- Remove GitHub-Script step with inline script
102104
- Add setup-test composite action call with mode: after
@@ -116,7 +118,8 @@ AfterAll-ModuleLocal:
116118
## Workflow Structure Contract
117119
118120
### File Organization
119-
```
121+
122+
```plaintext
120123
Test-ModuleLocal.yml (314 lines → ~176 lines)
121124
├── on: workflow_call
122125
│ ├── secrets: [8 test secrets]
@@ -172,7 +175,7 @@ Test-ModuleLocal.yml (314 lines → ~176 lines)
172175
173176
## Job Dependency Contract
174177
175-
```
178+
```plaintext
176179
BeforeAll-ModuleLocal (no dependencies)
177180
178181
Test-ModuleLocal (needs: BeforeAll-ModuleLocal)
@@ -325,6 +328,7 @@ AfterAll-ModuleLocal (needs: Test-ModuleLocal, if: always())
325328
| Maintenance burden | High (duplicated code) | Low (single action) | Significant improvement |
326329
327330
**Execution Time Breakdown**:
331+
328332
- Current: Checkout + Install-PSModuleHelpers + GitHub-Script + Script execution
329333
- New: Checkout + setup-test (Install-PSModuleHelpers + GitHub-Script) + Script execution
330334
- Difference: Composite action invocation overhead (~1-2 seconds)
@@ -340,6 +344,7 @@ If issues are discovered post-integration:
340344
5. **Re-deploy**: Apply fix and re-test in production
341345
342346
**Rollback steps**:
347+
343348
```bash
344349
git revert <commit-hash> # Revert workflow changes
345350
git push origin main # Deploy rollback

specs/001-building-on-this/data-model.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ This document defines the data structures, contracts, and entities for the setup
6767
- All environment variables accessible to scripts
6868

6969
**Dependencies**:
70+
7071
- PSModule/Install-PSModuleHelpers@v1 (installs PSModule helper functions)
7172
- PSModule/GitHub-Script@v1 (provides PowerShell execution environment with LogGroup)
7273

@@ -82,6 +83,7 @@ This document defines the data structures, contracts, and entities for the setup
8283
### 2. Test Script Files
8384

8485
**BeforeAll.ps1**:
86+
8587
- **Location**: `tests/BeforeAll.ps1` (root tests folder only)
8688
- **Purpose**: Setup external test resources before all test matrix jobs - resources that are independent of test platform/OS
8789
- **Intended Use**: Deploy cloud infrastructure via APIs, create external database instances, initialize test data in third-party services
@@ -91,6 +93,7 @@ This document defines the data structures, contracts, and entities for the setup
9193
- **Example Use Cases**: Deploy Azure/AWS resources via APIs, create external PostgreSQL databases, initialize SaaS test accounts
9294

9395
**AfterAll.ps1**:
96+
9497
- **Location**: `tests/AfterAll.ps1` (root tests folder only)
9598
- **Purpose**: Cleanup external test resources after all test matrix jobs - resources that are independent of test platform/OS
9699
- **Intended Use**: Remove cloud infrastructure via APIs, delete external database instances, cleanup test data in third-party services
@@ -100,6 +103,7 @@ This document defines the data structures, contracts, and entities for the setup
100103
- **Example Use Cases**: Delete Azure/AWS resources via APIs, remove external databases, cleanup SaaS test accounts
101104

102105
**Script Contract**:
106+
103107
- Scripts can access all environment variables (secrets)
104108
- Scripts execute in tests directory (via Push-Location)
105109
- Scripts should use Write-Host for output (not Write-Verbose)
@@ -110,6 +114,7 @@ This document defines the data structures, contracts, and entities for the setup
110114
### 3. Workflow Integration Contract
111115

112116
**BeforeAll-ModuleLocal Job**:
117+
113118
```yaml
114119
BeforeAll-ModuleLocal:
115120
name: BeforeAll-ModuleLocal
@@ -139,6 +144,7 @@ BeforeAll-ModuleLocal:
139144
```
140145
141146
**AfterAll-ModuleLocal Job**:
147+
142148
```yaml
143149
AfterAll-ModuleLocal:
144150
name: AfterAll-ModuleLocal
@@ -172,6 +178,7 @@ AfterAll-ModuleLocal:
172178
```
173179
174180
**Job Dependencies**:
181+
175182
- BeforeAll-ModuleLocal: No dependencies (runs first)
176183
- Test-ModuleLocal: Depends on BeforeAll-ModuleLocal
177184
- AfterAll-ModuleLocal: Depends on Test-ModuleLocal, always runs (if: always())
@@ -180,7 +187,7 @@ AfterAll-ModuleLocal:
180187
181188
Since this is a stateless action, state transitions describe the execution flow:
182189
183-
```
190+
```plaintext
184191
[Start]
185192
→ Check inputs.mode validation
186193
→ mode = "before" or "after"
@@ -258,17 +265,20 @@ Since this is a stateless action, state transitions describe the execution flow:
258265
### Output Contract
259266

260267
The action provides output via:
268+
261269
1. **Exit Code**: 0 for success, non-zero for failure (mode="before" only)
262270
2. **Console Output**: Formatted messages via LogGroup
263271
3. **GitHub Actions Status**: Job success/failure reflected in workflow UI
264272

265273
### Log Output Format
266274

267275
All output wrapped in LogGroup with title based on mode:
276+
268277
- mode="before": "Running BeforeAll Setup Scripts"
269278
- mode="after": "Running AfterAll Teardown Scripts"
270279

271280
Standard messages:
281+
272282
- No tests directory: "No tests directory found - exiting successfully"
273283
- No script found: "No [BeforeAll|AfterAll].ps1 script found - exiting successfully"
274284
- Script execution start: "Running [BeforeAll|AfterAll] setup/teardown script: [path]"
@@ -279,23 +289,27 @@ Standard messages:
279289
## Non-Functional Requirements
280290

281291
### Performance
292+
282293
- Action invocation overhead: <2 seconds (Install-PSModuleHelpers + GitHub-Script startup)
283294
- Script discovery: <100ms (single file check)
284295
- Total execution time: Script runtime + overhead
285296

286297
### Reliability
298+
287299
- Action must handle missing directories/files gracefully
288300
- Action must always restore working directory (via finally block)
289301
- Action must propagate errors correctly based on mode
290302
- AfterAll mode must ensure cleanup always runs (if: always())
291303

292304
### Maintainability
305+
293306
- Single source of truth for setup/teardown logic
294307
- Clear separation of concerns (action vs scripts)
295308
- Reusable across workflows
296309
- Documented inputs and behavior
297310

298311
### Security
312+
299313
- Secrets passed as environment variables (not in action inputs)
300314
- Scripts run in isolated job context
301315
- No secret values logged (use Write-Host for non-sensitive output)

0 commit comments

Comments
 (0)