Skip to content

Commit 551b598

Browse files
vaindclaude
andcommitted
feat: Convert workflow test scripts to use PowerShell and Pester
- Replace bash conditionals with Pester Should assertions - Change shell from bash to pwsh for all validation steps - Update environment variable syntax from $VAR to $env:VAR - Replace echo with Write-Host for PowerShell compatibility - Simplify test logic using Pester's built-in assertion methods 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 747517a commit 551b598

File tree

2 files changed

+48
-93
lines changed

2 files changed

+48
-93
lines changed

.github/workflows/danger-workflow-tests.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,14 @@ jobs:
2424
- name: Validate danger outputs
2525
env:
2626
DANGER_OUTCOME: ${{ steps.danger.outputs.outcome }}
27+
shell: pwsh
2728
run: |
28-
echo "🔍 Validating Danger action outputs..."
29-
echo "Danger Outcome: '$DANGER_OUTCOME'"
29+
Write-Host "🔍 Validating Danger action outputs..."
30+
Write-Host "Danger Outcome: '$env:DANGER_OUTCOME'"
3031
3132
# Validate that Danger ran successfully
32-
if [[ "$DANGER_OUTCOME" != "success" ]]; then
33-
echo "❌ Expected Danger outcome 'success', got '$DANGER_OUTCOME'"
34-
echo "This could indicate:"
35-
echo " - Danger found issues that caused it to fail"
36-
echo " - The action itself encountered an error"
37-
echo " - Docker container issues"
38-
exit 1
39-
fi
33+
# T
34+
$env:DANGER_OUTCOME | Should -Be "success"
4035
41-
echo "✅ Danger PR analysis completed successfully!"
42-
echo "ℹ️ Check the PR comments for any Danger findings"
36+
Write-Host "✅ Danger PR analysis completed successfully!"
37+
Write-Host "ℹ️ Check the PR comments for any Danger findings"

.github/workflows/workflow-tests.yml

Lines changed: 41 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,31 @@ jobs:
3333
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
3434
PR_URL: ${{ steps.updater.outputs.prUrl }}
3535
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
36+
shell: pwsh
3637
run: |
37-
echo "🔍 Validating PR creation scenario outputs..."
38-
echo "Base Branch: '$BASE_BRANCH'"
39-
echo "Original Tag: '$ORIGINAL_TAG'"
40-
echo "Latest Tag: '$LATEST_TAG'"
41-
echo "PR URL: '$PR_URL'"
42-
echo "PR Branch: '$PR_BRANCH'"
38+
Write-Host "🔍 Validating PR creation scenario outputs..."
39+
Write-Host "Base Branch: '$env:BASE_BRANCH'"
40+
Write-Host "Original Tag: '$env:ORIGINAL_TAG'"
41+
Write-Host "Latest Tag: '$env:LATEST_TAG'"
42+
Write-Host "PR URL: '$env:PR_URL'"
43+
Write-Host "PR Branch: '$env:PR_BRANCH'"
4344
4445
# Validate base branch is main
45-
if [[ "$BASE_BRANCH" != "main" ]]; then
46-
echo "❌ Expected base branch 'main', got '$BASE_BRANCH'"
47-
exit 1
48-
fi
46+
$env:BASE_BRANCH | Should -Be "main"
4947
5048
# Validate original tag is expected test value
51-
if [[ "$ORIGINAL_TAG" != "2.0.0" ]]; then
52-
echo "❌ Expected original tag '2.0.0', got '$ORIGINAL_TAG'"
53-
exit 1
54-
fi
49+
$env:ORIGINAL_TAG | Should -Be "2.0.0"
5550
5651
# Validate latest tag is a valid version
57-
if [[ ! "$LATEST_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
58-
echo "❌ Latest tag '$LATEST_TAG' is not a valid version format"
59-
exit 1
60-
fi
52+
$env:LATEST_TAG | Should -Match "^[0-9]+\.[0-9]+\.[0-9]+$"
6153
6254
# Validate PR URL format
63-
if [[ ! "$PR_URL" =~ ^https://github\.com/getsentry/github-workflows/pull/[0-9]+$ ]]; then
64-
echo "❌ PR URL '$PR_URL' is not a valid GitHub PR URL"
65-
exit 1
66-
fi
55+
$env:PR_URL | Should -Match "^https://github\.com/getsentry/github-workflows/pull/[0-9]+$"
6756
6857
# Validate PR branch format
69-
if [[ "$PR_BRANCH" != "deps/updater/tests/sentry-cli.properties" ]]; then
70-
echo "❌ Expected PR branch 'deps/updater/tests/sentry-cli.properties', got '$PR_BRANCH'"
71-
exit 1
72-
fi
58+
$env:PR_BRANCH | Should -Be "deps/updater/tests/sentry-cli.properties"
7359
74-
echo "✅ PR creation scenario validation passed!"
60+
Write-Host "✅ PR creation scenario validation passed!"
7561
7662
# Test target-branch functionality - should use specified branch as base
7763
updater-target-branch:
@@ -97,45 +83,31 @@ jobs:
9783
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
9884
PR_URL: ${{ steps.updater.outputs.prUrl }}
9985
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
86+
shell: pwsh
10087
run: |
101-
echo "🔍 Validating target-branch scenario outputs..."
102-
echo "Base Branch: '$BASE_BRANCH'"
103-
echo "Original Tag: '$ORIGINAL_TAG'"
104-
echo "Latest Tag: '$LATEST_TAG'"
105-
echo "PR URL: '$PR_URL'"
106-
echo "PR Branch: '$PR_BRANCH'"
88+
Write-Host "🔍 Validating target-branch scenario outputs..."
89+
Write-Host "Base Branch: '$env:BASE_BRANCH'"
90+
Write-Host "Original Tag: '$env:ORIGINAL_TAG'"
91+
Write-Host "Latest Tag: '$env:LATEST_TAG'"
92+
Write-Host "PR URL: '$env:PR_URL'"
93+
Write-Host "PR Branch: '$env:PR_BRANCH'"
10794
10895
# Validate base branch is the specified target-branch
109-
if [[ "$BASE_BRANCH" != "test/nonbot-commits" ]]; then
110-
echo "❌ Expected base branch 'test/nonbot-commits', got '$BASE_BRANCH'"
111-
exit 1
112-
fi
96+
$env:BASE_BRANCH | Should -Be "test/nonbot-commits"
11397
11498
# Validate original tag is expected test value
115-
if [[ "$ORIGINAL_TAG" != "2.0.0" ]]; then
116-
echo "❌ Expected original tag '2.0.0', got '$ORIGINAL_TAG'"
117-
exit 1
118-
fi
99+
$env:ORIGINAL_TAG | Should -Be "2.0.0"
119100
120101
# Validate latest tag is a valid version
121-
if [[ ! "$LATEST_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
122-
echo "❌ Latest tag '$LATEST_TAG' is not a valid version format"
123-
exit 1
124-
fi
102+
$env:LATEST_TAG | Should -Match "^[0-9]+\.[0-9]+\.[0-9]+$"
125103
126104
# Validate PR URL format
127-
if [[ ! "$PR_URL" =~ ^https://github\.com/getsentry/github-workflows/pull/[0-9]+$ ]]; then
128-
echo "❌ PR URL '$PR_URL' is not a valid GitHub PR URL"
129-
exit 1
130-
fi
105+
$env:PR_URL | Should -Match "^https://github\.com/getsentry/github-workflows/pull/[0-9]+$"
131106
132107
# Validate PR branch format
133-
if [[ "$PR_BRANCH" != "test/nonbot-commits-deps/updater/tests/sentry-cli.properties" ]]; then
134-
echo "❌ Expected PR branch 'test/nonbot-commits-deps/updater/tests/sentry-cli.properties', got '$PR_BRANCH'"
135-
exit 1
136-
fi
108+
$env:PR_BRANCH | Should -Be "test/nonbot-commits-deps/updater/tests/sentry-cli.properties"
137109
138-
echo "✅ Target-branch scenario validation passed!"
110+
Write-Host "✅ Target-branch scenario validation passed!"
139111
140112
# Test no-change scenario - should detect no updates needed
141113
updater-no-changes:
@@ -159,43 +131,31 @@ jobs:
159131
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
160132
PR_URL: ${{ steps.updater.outputs.prUrl }}
161133
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
134+
shell: pwsh
162135
run: |
163-
echo "🔍 Validating no-changes scenario outputs..."
164-
echo "Base Branch: '$BASE_BRANCH'"
165-
echo "Original Tag: '$ORIGINAL_TAG'"
166-
echo "Latest Tag: '$LATEST_TAG'"
167-
echo "PR URL: '$PR_URL'"
168-
echo "PR Branch: '$PR_BRANCH'"
136+
Write-Host "🔍 Validating no-changes scenario outputs..."
137+
Write-Host "Base Branch: '$env:BASE_BRANCH'"
138+
Write-Host "Original Tag: '$env:ORIGINAL_TAG'"
139+
Write-Host "Latest Tag: '$env:LATEST_TAG'"
140+
Write-Host "PR URL: '$env:PR_URL'"
141+
Write-Host "PR Branch: '$env:PR_BRANCH'"
169142
170143
# Validate no PR was created (empty values)
171-
if [[ -n "$BASE_BRANCH" ]]; then
172-
echo "❌ Expected empty base branch for no-changes, got '$BASE_BRANCH'"
173-
exit 1
174-
fi
144+
$env:BASE_BRANCH | Should -BeNullOrEmpty
175145
176-
if [[ -n "$PR_URL" ]]; then
177-
echo "❌ Expected no PR URL for no-changes, got '$PR_URL'"
178-
exit 1
179-
fi
146+
$env:PR_URL | Should -BeNullOrEmpty
180147
181-
if [[ -n "$PR_BRANCH" ]]; then
182-
echo "❌ Expected no PR branch for no-changes, got '$PR_BRANCH'"
183-
exit 1
184-
fi
148+
$env:PR_BRANCH | Should -BeNullOrEmpty
185149
186150
# Validate original equals latest (no update)
187-
if [[ "$ORIGINAL_TAG" != "$LATEST_TAG" ]]; then
188-
echo "❌ Expected original tag to equal latest tag, got '$ORIGINAL_TAG' != '$LATEST_TAG'"
189-
exit 1
190-
fi
151+
$env:ORIGINAL_TAG | Should -Be $env:LATEST_TAG
191152
192153
# Validate tag format (should be 'latest' or valid version)
193-
if [[ "$ORIGINAL_TAG" != "latest" && ! "$ORIGINAL_TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
194-
echo "❌ Original tag '$ORIGINAL_TAG' is not 'latest' or valid version format"
195-
exit 1
196-
fi
154+
if ($env:ORIGINAL_TAG -ne "latest") {
155+
$env:ORIGINAL_TAG | Should -Match "^v?[0-9]+\.[0-9]+\.[0-9]+$"
156+
}
197157
198-
echo "✅ No-changes scenario validation passed!"
158+
Write-Host "✅ No-changes scenario validation passed!"
199159
200160
cli-integration:
201161
runs-on: ${{ matrix.host }}-latest

0 commit comments

Comments
 (0)