-
Notifications
You must be signed in to change notification settings - Fork 0
567 lines (480 loc) · 20.5 KB
/
test.yml
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
name: 'Test'
on:
push:
workflow_dispatch:
env:
DATABASE_URL: ${{ secrets.CHINOOK_DATABASE_URL }}
jobs:
code-test:
name: 'Code Test'
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
- name: Setup Dependencies
run: |
corepack enable
npm install
- name: Jest Tests
env:
CHINOOK_DATABASE_URL: ${{ secrets.CHINOOK_DATABASE_URL }}
CHINOOK_API_KEY: ${{ secrets.CHINOOK_API_KEY }}
GATEWAY_URL: ${{ secrets.GATEWAY_URL }}
run: npm test
- name: Upload Code Coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
examples-test:
needs: code-test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
shell: bash
name: 'Node, Bun, Deno, Browsers, Express, Knex, NextJS, Vite Test'
timeout-minutes: 20
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
#setup node, bun and deno
- uses: actions/setup-node@v4
with:
node-version: latest
- uses: oven-sh/setup-bun@v2
- uses: denoland/setup-deno@v2
with:
deno-version: vx.x.x
- name: setup playwright for browser related test
run: npx playwright install --with-deps && npx playwright install msedge && npx playwright install chrome
- name: build driver
run: npm i && npm run build
#testing driver, removing examples after testing to save up space
- name: node with-javascript-express
working-directory: examples/with-javascript-express
run: |
npm i
npm start &
sleep 3
node_test=$(curl localhost:3000)
if [[ $node_test == *"{\"tracks\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ node with-javascript-express test passed"
npx kill-port 3000
exit 0
fi
echo "❌ node with-javascript-express test failed"
exit 1
- name: bun with-javascript-express
working-directory: examples/with-javascript-express
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
bun i #re-installing dependencies in windows with bash causes a panic
fi
bun start &
sleep 3
bun_test=$(curl localhost:3000)
if [[ $bun_test == *"{\"tracks\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ bun with-javascript-express test passed"
npx kill-port 3000
exit 0
fi
echo "❌ bun with-javascript-express test failed"
exit 1
- name: deno with-javascript-express
working-directory: examples/with-javascript-express
run: |
deno run start &
sleep 3
deno_test=$(curl localhost:3000)
if [[ $deno_test == *"{\"tracks\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ deno with-javascript-express test passed"
npx kill-port 3000
exit 0
fi
echo "❌ deno with-javascript-express test failed"
exit 1
- name: remove with-javascript-express
run: rm -rf examples/with-javascript-express
- name: node with-plain-javascript
working-directory: examples/with-plain-javascript
run: |
npm i
app_log=$(mktemp)
npm start > "$app_log" 2>&1 &
app_pid=$!
sleep 3
kill "$app_pid" 2>/dev/null
node_test=$(<"$app_log")
rm "$app_log"
if [[ "$node_test" == *"Composer: 'Angus Young, Malcolm Young, Brian Johnson',"* ]]; then
echo "✅ node with-plain-javascript test passed"
exit 0
fi
echo "❌ node with-plain-javascript test failed"
exit 1
- name: bun with-plain-javascript
working-directory: examples/with-plain-javascript
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
bun i #re-installing dependencies in windows with bash causes a panic
fi
app_log=$(mktemp)
bun start > "$app_log" 2>&1 &
app_pid=$!
sleep 3
kill "$app_pid" 2>/dev/null
bun_test=$(<"$app_log")
rm "$app_log"
if [[ "$bun_test" == *"Composer: 'Angus Young, Malcolm Young, Brian Johnson',"* ]]; then
echo "✅ bun with-plain-javascript test passed"
exit 0
fi
echo "❌ bun with-plain-javascript test failed"
exit 1
- name: deno with-plain-javascript
working-directory: examples/with-plain-javascript
run: |
app_log=$(mktemp)
deno run start > "$app_log" 2>&1 &
app_pid=$!
sleep 3
kill "$app_pid" 2>/dev/null
deno_test=$(<"$app_log")
rm "$app_log"
if [[ "$deno_test" == *"Composer: 'Angus Young, Malcolm Young, Brian Johnson',"* ]]; then
echo "✅ deno with-plain-javascript test passed"
exit 0
fi
echo "❌ deno with-plain-javascript test failed"
exit 1
- name: remove with-plain-javascript
if: matrix.os != 'windows-latest' #kill command doesn not work on windows with bash, we can skip this step
run: rm -rf examples/with-plain-javascript
- name: node with-typescript-knex
working-directory: examples/with-typescript-knex
run: |
npm i
node_test=$(npx tsx example.ts)
if [[ "$node_test" == *"\"Company\": \"Embraer - Empresa Brasileira de Aeronáutica S.A.\","* ]]; then
echo "✅ node with-typescript-knex test passed"
exit 0
fi
echo "❌ node with-typescript-knex test failed"
exit 1
- name: bun with-typescript-knex
working-directory: examples/with-typescript-knex
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
bun i #re-installing dependencies in windows with bash causes a panic
fi
bun_test=$(bun example.ts)
if [[ "$bun_test" == *"\"Company\": \"Embraer - Empresa Brasileira de Aeronáutica S.A.\","* ]]; then
echo "✅ bun with-typescript-knex test passed"
exit 0
fi
echo "❌ bun with-typescript-knex test failed"
exit 1
- name: remove with-typescript-knex
run: rm -rf examples/with-typescript-knex
- name: node with-typescript-nextjs
working-directory: examples/with-typescript-nextjs
run: |
npm i
npm run dev &
sleep 3
node_test=$(curl localhost:3003)
node_test2=$(curl localhost:3003/api/hello)
if [[ $node_test == *"next.js json route"* && $node_test2 == *"{\"data\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ node with-typescript-nextjs test passed"
npx kill-port 3003
exit 0
fi
echo "❌ node with-typescript-nextjs test failed"
exit 1
- name: bun with-typescript-nextjs
working-directory: examples/with-typescript-nextjs
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
bun i #re-installing dependencies in windows with bash causes a panic
fi
bun run dev &
sleep 3
bun_test=$(curl localhost:3003)
bun_test2=$(curl localhost:3003/api/hello)
if [[ $bun_test == *"next.js json route"* && $bun_test2 == *"{\"data\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ bun with-typescript-nextjs test passed"
npx kill-port 3003
exit 0
fi
echo "❌ bun with-typescript-nextjs test failed"
exit 1
- name: deno with-typescript-nextjs
working-directory: examples/with-typescript-nextjs
run: |
deno run dev &
sleep 3
#not testing index page because it throws an error with deno
deno_test=$(curl localhost:3003/api/hello)
if [[ $deno_test == *"{\"data\":[{\"TrackId\":1,\"Name\":\"For Those About To Rock (We Salute You)\",\"AlbumId\":1,\"MediaTypeId\":1,\"GenreId\":1,\"Composer\":\"Angus Young, Malcolm Young, Brian Johnson\",\"Milliseconds\":343719,\"Bytes\":11170334,\"UnitPrice\":0.99},{"* ]]; then
echo "✅ deno with-typescript-nextjs test passed"
npx kill-port 3003
exit 0
fi
echo "❌ deno with-typescript-nextjs test failed"
exit 1
- name: remove with-typescript-nextjs
run: rm -rf examples/with-typescript-nextjs
- name: node with-javascript-vite
working-directory: examples/with-javascript-vite
run: npm i && npx playwright test
env:
VITE_DATABASE_URL: ${{ secrets.CHINOOK_DATABASE_URL }}
- name: bun with-javascript-vite
working-directory: examples/with-javascript-vite
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
bun i #re-installing dependencies in windows with bash causes a panic
fi
bun playwright test
env:
VITE_DATABASE_URL: ${{ secrets.CHINOOK_DATABASE_URL }}
- name: deno with-javascript-vite
if: matrix.os != 'windows-latest' #https://github.com/denoland/deno/issues/23524#issuecomment-2292075726
working-directory: examples/with-javascript-vite
run: deno add npm:@playwright/test && deno run --allow-all npm:playwright test
env:
VITE_DATABASE_URL: ${{ secrets.CHINOOK_DATABASE_URL }}
PW_DISABLE_TS_ESM: true
- name: remove with-javascript-vite
run: rm -rf examples/with-javascript-vite
- name: node with-javascript-browser
working-directory: examples/with-javascript-browser
run: npm i && node test.cjs
- name: bun with-javascript-browser
if: matrix.os != 'windows-latest' #cannot launch browsers on windows with bash in commonjs?
working-directory: examples/with-javascript-browser
run: bun i && bun test.cjs
- name: deno with-javascript-browser
if: matrix.os != 'windows-latest' #https://github.com/denoland/deno/issues/23524#issuecomment-2292075726
uses: nick-fields/retry@v3 #doing this step with the retry action because sometimes in macos it gets stuck without failing
with:
timeout_seconds: 45
max_attempts: 5
command: cd examples/with-javascript-browser && deno --allow-all test.cjs
- name: remove with-javascript-browser
run: rm -rf examples/with-javascript-browser
rn-ios-test:
needs: code-test
strategy:
matrix:
os: [macos-13, macos-14, macos-15] # macos-12 for ios 15 it's going to be deprecated, it's also using an old version of xcode that is not compatible with react native
include:
- os: macos-13
version: '16.4'
- os: macos-14
version: '17'
- os: macos-15
version: '18'
name: 'React Native iOS ${{ matrix.version }} Test'
timeout-minutes: 40
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: setup utils
run: brew tap wix/brew && brew install applesimutils
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
#switch to old xcode version that has ios 16.4
- uses: maxim-lobanov/[email protected]
if: matrix.version == '16.4'
with:
xcode-version: 14.3
- name: build driver
run: npm i && npm run build && echo "DRIVER=$(npm pack --json | jq '.[0].filename')" >> $GITHUB_ENV
- name: install driver
working-directory: examples/with-typescript-react-native
run: npm i ../../${{ env.DRIVER }} #installing a tar packaged version of the driver since react native doesn't work well with local dependencies
- name: install cocoapods
working-directory: examples/with-typescript-react-native
run: cd ios ; pod install ; cd -
- name: build app
working-directory: examples/with-typescript-react-native
run: npx detox build --configuration ios.sim.release
- name: test app
working-directory: examples/with-typescript-react-native
run: npx detox test --configuration ios.sim.${{ matrix.version }} --headless --record-videos all --take-screenshots all
- name: upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: rn-ios-${{matrix.version}}-test-artifacts
path: examples/with-typescript-react-native/artifacts
rn-android-test:
needs: code-test
strategy:
matrix:
api-level: [25, 26, 29, 31, 35] #app fail: android 5; driver fail: android 6 and android 7
include:
- api-level: 25
version: '7.1'
- api-level: 26
version: '8.0'
- api-level: 29
version: '10'
- api-level: 31
version: '12'
- api-level: 35
version: '15'
name: 'React Native Android ${{matrix.version}} Test'
timeout-minutes: 30
runs-on: ubuntu-latest #android emulator on github actions works only on linux and old macos x86 builds, we can skip other os since the build and test process is going to be the same
steps:
- uses: jlumbroso/[email protected]
with:
android: false
- uses: actions/checkout@v4
- name: enable kvm group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: build driver
run: npm i && npm run build && echo "DRIVER=$(npm pack --json | jq '.[0].filename')" >> $GITHUB_ENV
- name: install driver
working-directory: examples/with-typescript-react-native
run: npm i ../../${{ env.DRIVER }} #installing a tar packaged version of the driver since react native doesn't work well with local dependencies
- name: build app
working-directory: examples/with-typescript-react-native
run: npx detox build --configuration android.emu.release
- name: test app
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
profile: Nexus 6
avd-name: Medium_Phone_API_35
emulator-boot-timeout: 20000
working-directory: examples/with-typescript-react-native
script: npx detox test --configuration android.emu.release --headless --record-videos all --take-screenshots all
- name: upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: rn-android-${{matrix.version}}-test-artifacts
path: examples/with-typescript-react-native/artifacts
expo-ios-test:
needs: code-test
strategy:
matrix:
os: [macos-13, macos-14, macos-15] # macos-12 for ios 15 it's going to be deprecated, it's also using an old version of xcode that is not compatible with react native
include:
- os: macos-13
version: '16.4'
- os: macos-14
version: '17'
- os: macos-15
version: '18'
name: 'Expo iOS ${{ matrix.version }} Test'
timeout-minutes: 40
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: setup utils
run: brew tap wix/brew && brew install applesimutils
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
#switch to old xcode version that has ios 16.4
- uses: maxim-lobanov/[email protected]
if: matrix.version == '16.4'
with:
xcode-version: 14.3
- name: build driver
run: npm i && npm run build && echo "DRIVER=$(npm pack --json | jq '.[0].filename')" >> $GITHUB_ENV
- name: install driver
working-directory: examples/with-javascript-expo
run: npm i ../../${{ env.DRIVER }} #installing a tar packaged version of the driver since react native doesn't work well with local dependencies
- name: expo prebuild
working-directory: examples/with-javascript-expo
run: npx expo prebuild
- name: build app
working-directory: examples/with-javascript-expo
run: npx detox build --configuration ios.sim.release
- name: test app
working-directory: examples/with-javascript-expo
run: npx detox test --configuration ios.sim.${{ matrix.version }} --headless --record-videos all --take-screenshots all
- name: upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: expo-ios-${{matrix.version}}-test-artifacts
path: examples/with-javascript-expo/artifacts
expo-android-test:
needs: code-test
strategy:
matrix:
api-level: [25, 26, 29, 31, 35] #app fail: android 5; driver fail: android 6 and android 7
include:
- api-level: 25
version: '7.1'
- api-level: 26
version: '8.0'
- api-level: 29
version: '10'
- api-level: 31
version: '12'
- api-level: 35
version: '15'
name: 'Expo Android ${{matrix.version}} Test'
timeout-minutes: 30
runs-on: ubuntu-latest #android emulator on github actions works only on linux and old macos x86 builds, we can skip other os since the build and test process is going to be the same
steps:
- uses: jlumbroso/[email protected]
with:
android: false
- uses: actions/checkout@v4
- name: enable kvm group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: build driver
run: npm i && npm run build && echo "DRIVER=$(npm pack --json | jq '.[0].filename')" >> $GITHUB_ENV
- name: install driver
working-directory: examples/with-javascript-expo
run: npm i ../../${{ env.DRIVER }} #installing a tar packaged version of the driver since react native doesn't work well with local dependencies
- name: expo prebuild
working-directory: examples/with-javascript-expo
run: npx expo prebuild
- name: build app
working-directory: examples/with-javascript-expo
run: npx detox build --configuration android.emu.release
- name: test app
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
profile: Nexus 6
avd-name: Medium_Phone_API_35
emulator-boot-timeout: 20000
working-directory: examples/with-javascript-expo
script: npx detox test --configuration android.emu.release --headless --record-videos all --take-screenshots all
- name: upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: expo-android-${{matrix.version}}-test-artifacts
path: examples/with-javascript-expo/artifacts