-
-
Notifications
You must be signed in to change notification settings - Fork 6
220 lines (189 loc) Β· 7.56 KB
/
workflow-tests.yml
File metadata and controls
220 lines (189 loc) Β· 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# This isn't a reusable workflow but an actual CI action for this repo itself - to test the workflows.
name: Workflow Tests
on:
push:
permissions:
contents: write
pull-requests: write
actions: write
jobs:
# Test PR creation scenario - should create a PR with specific version pattern
updater-pr-creation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ./gh-workflow-tests-checkout
- name: Run updater action
id: updater
uses: ./gh-workflow-tests-checkout/updater
with:
path: updater/tests/sentry-cli.properties
name: WORKFLOW-TEST-DEPENDENCY-DO-NOT-MERGE
pattern: '^2\.0\.'
pr-strategy: update
api-token: ${{ github.token }}
- name: Validate PR creation outputs
env:
BASE_BRANCH: ${{ steps.updater.outputs.baseBranch }}
ORIGINAL_TAG: ${{ steps.updater.outputs.originalTag }}
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
PR_URL: ${{ steps.updater.outputs.prUrl }}
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
run: |
echo "π Validating PR creation scenario outputs..."
echo "Base Branch: '$BASE_BRANCH'"
echo "Original Tag: '$ORIGINAL_TAG'"
echo "Latest Tag: '$LATEST_TAG'"
echo "PR URL: '$PR_URL'"
echo "PR Branch: '$PR_BRANCH'"
# Validate base branch is main
if [[ "$BASE_BRANCH" != "main" ]]; then
echo "β Expected base branch 'main', got '$BASE_BRANCH'"
exit 1
fi
# Validate original tag is expected test value
if [[ "$ORIGINAL_TAG" != "2.0.0" ]]; then
echo "β Expected original tag '2.0.0', got '$ORIGINAL_TAG'"
exit 1
fi
# Validate latest tag is a valid version
if [[ ! "$LATEST_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "β Latest tag '$LATEST_TAG' is not a valid version format"
exit 1
fi
# Validate PR URL format
if [[ ! "$PR_URL" =~ ^https://github\.com/getsentry/github-workflows/pull/[0-9]+$ ]]; then
echo "β PR URL '$PR_URL' is not a valid GitHub PR URL"
exit 1
fi
# Validate PR branch format
if [[ "$PR_BRANCH" != "deps/updater/tests/sentry-cli.properties" ]]; then
echo "β Expected PR branch 'deps/updater/tests/sentry-cli.properties', got '$PR_BRANCH'"
exit 1
fi
echo "β
PR creation scenario validation passed!"
# Test target-branch functionality - should use specified branch as base
updater-target-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ./gh-workflow-tests-checkout
- name: Run updater action with target-branch
id: updater
uses: ./gh-workflow-tests-checkout/updater
with:
path: updater/tests/sentry-cli.properties
name: TARGET-BRANCH-TEST-DO-NOT-MERGE
pattern: '^2\.0\.'
target-branch: test/nonbot-commits
pr-strategy: update
api-token: ${{ github.token }}
- name: Validate target-branch outputs
env:
BASE_BRANCH: ${{ steps.updater.outputs.baseBranch }}
ORIGINAL_TAG: ${{ steps.updater.outputs.originalTag }}
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
PR_URL: ${{ steps.updater.outputs.prUrl }}
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
run: |
echo "π Validating target-branch scenario outputs..."
echo "Base Branch: '$BASE_BRANCH'"
echo "Original Tag: '$ORIGINAL_TAG'"
echo "Latest Tag: '$LATEST_TAG'"
echo "PR URL: '$PR_URL'"
echo "PR Branch: '$PR_BRANCH'"
# Validate base branch is the specified target-branch
if [[ "$BASE_BRANCH" != "test/nonbot-commits" ]]; then
echo "β Expected base branch 'test/nonbot-commits', got '$BASE_BRANCH'"
exit 1
fi
# Validate original tag is expected test value
if [[ "$ORIGINAL_TAG" != "2.0.0" ]]; then
echo "β Expected original tag '2.0.0', got '$ORIGINAL_TAG'"
exit 1
fi
# Validate latest tag is a valid version
if [[ ! "$LATEST_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "β Latest tag '$LATEST_TAG' is not a valid version format"
exit 1
fi
# Validate PR URL format
if [[ ! "$PR_URL" =~ ^https://github\.com/getsentry/github-workflows/pull/[0-9]+$ ]]; then
echo "β PR URL '$PR_URL' is not a valid GitHub PR URL"
exit 1
fi
# Validate PR branch format
if [[ "$PR_BRANCH" != "deps/updater/tests/sentry-cli.properties" ]]; then
echo "β Expected PR branch 'deps/updater/tests/sentry-cli.properties', got '$PR_BRANCH'"
exit 1
fi
echo "β
Target-branch scenario validation passed!"
# Test no-change scenario - should detect no updates needed
updater-no-changes:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
path: ./gh-workflow-tests-checkout
- name: Run updater action
id: updater
uses: ./gh-workflow-tests-checkout/updater
with:
path: updater/tests/workflow-args.sh
name: Workflow args test script
pattern: '.*'
api-token: ${{ github.token }}
- name: Validate no-changes outputs
env:
BASE_BRANCH: ${{ steps.updater.outputs.baseBranch }}
ORIGINAL_TAG: ${{ steps.updater.outputs.originalTag }}
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
PR_URL: ${{ steps.updater.outputs.prUrl }}
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
run: |
echo "π Validating no-changes scenario outputs..."
echo "Base Branch: '$BASE_BRANCH'"
echo "Original Tag: '$ORIGINAL_TAG'"
echo "Latest Tag: '$LATEST_TAG'"
echo "PR URL: '$PR_URL'"
echo "PR Branch: '$PR_BRANCH'"
# Validate no PR was created (empty values)
if [[ -n "$BASE_BRANCH" ]]; then
echo "β Expected empty base branch for no-changes, got '$BASE_BRANCH'"
exit 1
fi
if [[ -n "$PR_URL" ]]; then
echo "β Expected no PR URL for no-changes, got '$PR_URL'"
exit 1
fi
if [[ -n "$PR_BRANCH" ]]; then
echo "β Expected no PR branch for no-changes, got '$PR_BRANCH'"
exit 1
fi
# Validate original equals latest (no update)
if [[ "$ORIGINAL_TAG" != "$LATEST_TAG" ]]; then
echo "β Expected original tag to equal latest tag, got '$ORIGINAL_TAG' != '$LATEST_TAG'"
exit 1
fi
# Validate tag format (should be 'latest' or valid version)
if [[ "$ORIGINAL_TAG" != "latest" && ! "$ORIGINAL_TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "β Original tag '$ORIGINAL_TAG' is not 'latest' or valid version format"
exit 1
fi
echo "β
No-changes scenario validation passed!"
cli-integration:
runs-on: ${{ matrix.host }}-latest
strategy:
fail-fast: false
matrix:
host:
- ubuntu
- macos
- windows
steps:
- uses: actions/checkout@v4
- uses: ./sentry-cli/integration-test/
with:
path: sentry-cli/integration-test/tests/