Skip to content

Commit 4e9bf57

Browse files
✨ [Refactor]: Add environment variable checks for GITHUB_RUN_ID and Settings in BeforeAll and AfterAll scripts
1 parent ca70b97 commit 4e9bf57

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/AfterAll.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ LogGroup 'AfterAll - Global Test Teardown' {
55
$authCases = . "$PSScriptRoot/Data/AuthCases.ps1"
66

77
$id = $env:GITHUB_RUN_ID
8+
if (-not $id) {
9+
throw 'GITHUB_RUN_ID environment variable is not set. Refusing to clean up test repositories with an unscoped wildcard (would impact concurrent runs).'
10+
}
11+
if (-not $env:Settings) {
12+
throw 'Settings environment variable is not set. Process-PSModule must populate it with the test suite configuration.'
13+
}
814
$prefix = 'Test'
915

1016
# Derive the list of OS names from the Settings JSON provided by Process-PSModule.

tests/BeforeAll.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ param()
44
LogGroup 'BeforeAll - Global Test Setup' {
55
$authCases = . "$PSScriptRoot/Data/AuthCases.ps1"
66
$id = $env:GITHUB_RUN_ID
7+
if (-not $id) {
8+
throw 'GITHUB_RUN_ID environment variable is not set. Refusing to create or clean up test repositories with a non-deterministic name.'
9+
}
10+
if (-not $env:Settings) {
11+
throw 'Settings environment variable is not set. Process-PSModule must populate it with the test suite configuration.'
12+
}
713

814
# Derive the list of OS names from the Settings JSON provided by Process-PSModule.
915
$settings = $env:Settings | ConvertFrom-Json

0 commit comments

Comments
 (0)