-
Notifications
You must be signed in to change notification settings - Fork 752
286 lines (255 loc) · 9.78 KB
/
Copy pathrelease-tests.yml
File metadata and controls
286 lines (255 loc) · 9.78 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Release Branch Tests
on:
push:
branches:
- '[0-9]+.[0-9]+'
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
dependency-branches:
name: Resolve dependencies
# Run for: pushes to release branches, PRs targeting release branches, or PRs with 'run-tests' label
if: >-
github.event_name == 'push'
|| contains(github.event.pull_request.labels.*.name, 'run-tests')
|| contains(github.base_ref, '.')
runs-on: ubuntu-22.04
outputs:
branches: ${{ steps.result.outputs.branches }}
steps:
- uses: actions/checkout@v4
- uses: supertokens/get-core-dependencies-action@main
id: result
with:
run-for: PR
core-branch: ${{ github.head_ref || github.ref_name }}
# ── Update dependency manifests if needed ────────────────────────
update-deps:
name: Update dependency manifests
needs: dependency-branches
runs-on: ubuntu-22.04
outputs:
deps_changed: ${{ steps.check.outputs.changed }}
steps:
- name: Set up JDK 21.0.7
uses: actions/setup-java@v4
with:
java-version: 21.0.7
distribution: zulu
- name: Checkout supertokens-root
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-root
path: supertokens-root
ref: master
- name: Checkout supertokens-core
uses: actions/checkout@v4
with:
path: supertokens-root/supertokens-core
token: ${{ secrets.GH_TOKEN }}
ref: ${{ github.head_ref }}
- name: Checkout supertokens-plugin-interface
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-plugin-interface
path: supertokens-root/supertokens-plugin-interface
ref: ${{ fromJson(needs.dependency-branches.outputs.branches)['plugin-interface'] }}
token: ${{ secrets.GH_TOKEN }}
- name: Checkout supertokens-postgresql-plugin
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-postgresql-plugin
path: supertokens-root/supertokens-postgresql-plugin
ref: ${{ fromJson(needs.dependency-branches.outputs.branches)['postgresql'] }}
token: ${{ secrets.GH_TOKEN }}
- name: Load modules
run: |
cd supertokens-root
cat > modules.txt <<'EOF'
core,master
plugin-interface,master
postgresql-plugin,master
EOF
./loadModules
- name: Generate dependency manifests
run: |
cd supertokens-root
./gradlew generateDependenciesJson
- name: Check for changes and push
id: check
run: |
changed=false
for repo_dir in supertokens-root/supertokens-core supertokens-root/supertokens-plugin-interface supertokens-root/supertokens-postgresql-plugin; do
if [ ! -d "$repo_dir/.git" ]; then
continue
fi
pushd "$repo_dir" > /dev/null
# Stage any changed implementationDependencies.json files
find . -name 'implementationDependencies.json' -not -path './.git/*' -exec git add {} +
if ! git diff --cached --quiet; then
changed=true
echo "::group::implementationDependencies.json diff in $repo_dir"
git diff --cached
echo "::endgroup::"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "chore: update implementationDependencies.json"
git push
echo "Pushed updated implementationDependencies.json in $repo_dir"
fi
popd > /dev/null
done
echo "changed=$changed" >> "$GITHUB_OUTPUT"
# ── Unit tests (sqlite + postgresql) ──────────────────────────────
test:
name: Tests (${{ matrix.plugin }})
needs: [dependency-branches, update-deps]
if: needs.update-deps.outputs.deps_changed == 'false'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
plugin:
- sqlite
- postgresql
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: root
ports:
- 5432:5432
options: >-
--name postgres
--health-cmd "pg_isready -U root"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- name: Set up JDK 21.0.7
uses: actions/setup-java@v4
with:
java-version: 21.0.7
distribution: zulu
- name: Checkout supertokens-root
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-root
path: supertokens-root
ref: master
- name: Checkout supertokens-core
uses: actions/checkout@v4
with:
path: supertokens-root/supertokens-core
- name: Checkout supertokens-plugin-interface
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-plugin-interface
path: supertokens-root/supertokens-plugin-interface
ref: ${{ fromJson(needs.dependency-branches.outputs.branches)['plugin-interface'] }}
- name: Checkout supertokens-postgresql-plugin
if: matrix.plugin == 'postgresql'
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-postgresql-plugin
path: supertokens-root/supertokens-postgresql-plugin
ref: ${{ fromJson(needs.dependency-branches.outputs.branches)['postgresql'] }}
- name: Load modules
run: |
cd supertokens-root
cat > modules.txt <<'EOF'
core,master
plugin-interface,master
${{ matrix.plugin }}-plugin,master
EOF
./loadModules
- name: Configure PostgreSQL
if: matrix.plugin == 'postgresql'
env:
PGHOST: localhost
PGPORT: "5432"
PGUSER: root
PGPASSWORD: root
run: |
# GHA service containers don't support passing server args in YAML, so we
# apply max_connections via ALTER SYSTEM and restart the container.
psql -d root -c "ALTER SYSTEM SET max_connections = 1000;"
docker restart postgres
until pg_isready -h localhost -U root; do sleep 1; done
- name: Create PostgreSQL test databases
if: matrix.plugin == 'postgresql'
env:
PGHOST: localhost
PGPORT: "5432"
PGUSER: root
PGPASSWORD: root
run: |
for db in supertokens $(seq -f 'st%.0f' 0 50); do
psql -d root -c "CREATE DATABASE \"$db\";" 2>/dev/null || true
done
# Also pre-create worker-specific databases for parallel test workers.
# maxParallelForks = availableProcessors(); create for up to 8 workers to be safe.
for w in $(seq 1 8); do
for n in $(seq 0 50); do
psql -d root -c "CREATE DATABASE \"st${n}_w${w}\";" 2>/dev/null || true
done
done
- name: Setup test environment
run: cd supertokens-root && ./utils/setupTestEnv --local
- name: Run tests
env:
ST_PLUGIN_NAME: ${{ matrix.plugin }}
TEST_PG_ADMIN_DB: root
TEST_PG_HOST: localhost
run: |
cd supertokens-root
./gradlew test
- name: Publish test report
uses: mikepenz/action-junit-report@v5
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
detailed_summary: true
include_passed: false
annotate_notice: true
# ── Wait for the dev Docker image to be published ─────────────────
wait-for-docker:
name: Wait for Docker image
needs: [dependency-branches, update-deps]
if: needs.update-deps.outputs.deps_changed == 'false'
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.set_tag.outputs.TAG }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Wait for Docker build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# For PR events GITHUB_SHA is the synthetic merge commit, not the branch
# HEAD that triggered the Docker publish workflow. Use the PR head SHA when
# available, falling back to GITHUB_SHA for direct push events.
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: python .github/helpers/wait-for-docker.py
- name: Set image tag
id: set_tag
env:
# publish-dev-docker.yml builds on branch push and tags the image with the branch name.
# On pull_request events GITHUB_REF is the merge ref (refs/pull/N/merge), which would
# produce a tag like "refs_pull_N_merge" that was never pushed. Derive the tag from the
# PR's source branch (head_ref) instead — falling back to ref_name for push events —
# and sanitise it the same way (slashes -> underscores) so it matches the pushed image.
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
echo "TAG=$(echo "$BRANCH_NAME" | sed 's/\//_/g')" >> "$GITHUB_OUTPUT"
# ── Stress tests (uses the published Docker image) ────────────────
stress-tests:
name: Stress tests
needs: [test, wait-for-docker]
uses: ./.github/workflows/stress-tests.yml
with:
tag: ${{ needs.wait-for-docker.outputs.tag }}