-
Notifications
You must be signed in to change notification settings - Fork 585
428 lines (377 loc) · 17.6 KB
/
pr-realm-js.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
name: Pull request build and test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
bundle:
name: Bundle TypeScript
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup node version
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install dependencies
# Ignoring scripts to prevent a prebuilt from getting fetched / built
run: npm ci --ignore-scripts
- name: Bundle all packages
run: npm run bundle
# Due to a limitation in upload-artifact a redundant file is needed to force
# preserving paths (https://github.com/actions/upload-artifact/issues/174)
- name: Upload dist artifacts
uses: actions/upload-artifact@v3
with:
name: realm-js-bundles
path: |
README.md
packages/*/dist
build:
name: Build for ${{ matrix.variant.os }} ${{ matrix.variant.arch }}
runs-on: ${{ matrix.variant.runner }}
env:
REALM_DISABLE_ANALYTICS: 1
NDK_VERSION: 23.1.7779620
strategy:
fail-fast: false
matrix:
variant:
- { os: linux, runner: ubuntu-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: linux, runner: ubuntu-latest, arch: arm, artifact-path: packages/realm/prebuilds }
- { os: linux, runner: ubuntu-latest, arch: arm64, artifact-path: packages/realm/prebuilds }
- { os: windows, runner: windows-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: windows, runner: windows-2019, arch: ia32, artifact-path: packages/realm/prebuilds }
- { os: android, runner: ubuntu-latest, arch: x86_64, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: armeabi-v7a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: arm64-v8a, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: android, runner: ubuntu-latest, arch: x86, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: darwin, runner: macos-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: darwin, runner: macos-latest, arch: arm64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: ios, runner: macos-latest-xlarge, arch: simulator, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest-xlarge, arch: catalyst, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest-xlarge, arch: ios, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup node version
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore NPM cache
id: npm-cache
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Wireit cache
uses: google/wireit@setup-github-actions-caching/v1
- name: MSVC Setup
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
# ninja-build is used by default if available and results in faster build times
# On linux, electron requires a connected display. We fake this by giving it a headless environment using xvfb
# Relevant issue: https://github.com/juliangruber/browser-run/issues/147
- name: Linux Environment setup
if: ${{ (matrix.variant.runner == 'ubuntu-latest') }}
run: sudo apt-get install ccache ninja-build
- name: Setup Java
if: ${{ matrix.variant.os == 'android' }}
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11'
- name: Setup Android SDK
if: ${{ matrix.variant.os == 'android' }}
uses: android-actions/setup-android@v2
- name: Install NDK
if: ${{ matrix.variant.os == 'android' }}
run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
# The ccache installed by github doesn't want to be moved around. Let the ccache action download a new one.
- name: Remove pre-installed ccache
if: ${{ runner.os == 'Windows' }}
shell: bash
# There are two; remove both
run: |
rm -fv $(which ccache)
rm -fv $(which ccache)
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ runner.os }}-${{ matrix.variant.os }}-${{ matrix.variant.arch }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
if: ${{ runner.os != 'Windows' }}
run: |
echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# in CI file timestamps change with every run so instead rely on file content hashing
# https://reactnative.dev/docs/build-speed#using-this-approach-on-a-ci
- name: Configure ccache
run: ccache --set-config="compiler_check=content"
- name: Install dependencies
# Ignoring scripts to prevent a prebuilt from getting fetched / built
run: npm ci --ignore-scripts
- name: Insert ccache executables
if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
cl_exe=$(which cl.exe)
cl_dir=$(dirname "$cl_exe")
# For 32-bit it uses a different compiler than the one in the path
if [ ${{ matrix.variant.arch }} = ia32 ]; then
cl_dir=$(dirname "$cl_dir")/x86
cl_exe="$cl_dir/cl.exe"
fi
cl_dir_windows="C:${cl_dir#/c}"
mv -v "$cl_exe" "$cl_dir"/cl-real.exe
cp -v "$cl_dir"/cl.exe.config "$cl_dir"/cl-real.exe.config
ccache_exe=$(which ccache.exe)
cp -v "$ccache_exe" "$cl_dir"/cl.exe
ls -l "$cl_dir"
echo "CCACHE_COMPILER=$cl_dir_windows/cl-real.exe" >> $GITHUB_ENV
echo 'CCACHE_COMPILERTYPE=msvc' >> $GITHUB_ENV
echo 'CCACHE_STATSLOG=C:\Users\runneradmin\ccache\statslog.txt' >> $GITHUB_ENV
#echo 'CCACHE_LOGFILE=C:\Users\runneradmin\ccache\logfile.txt' >> $GITHUB_ENV
# This tells msbuild to compile only one file at a time; ccache needs that.
echo 'UseMultiToolTask=true' >> $GITHUB_ENV
echo 'VCPKG_KEEP_ENV_VARS=CCACHE_COMPILER;CCACHE_STATSLOG;CCACHE_LOGFILE;CCACHE_COMPILERTYPE;UseMultiToolTask' >> $GITHUB_ENV
# build the c++ library for standard targets
- name: Build node
if: ${{ (matrix.variant.os != 'ios') && (matrix.variant.os != 'android') }}
run: npm run build:node:prebuild:${{matrix.variant.arch}} --workspace realm
# build the c++ library for IOS
# the Info.plist needs to be regenerated with all libraries in place
- name: Build iOS
if: ${{ (matrix.variant.os == 'ios') }}
run: |
npm run build:ios --workspace realm
rm -vf ${{ matrix.variant.artifact-path }}/Info.plist
env:
PLATFORMS: ${{ matrix.variant.arch }}
# build the c++ library for Android
- name: Build Android
if: ${{ (matrix.variant.os == 'android') }}
run: npm run build:android --workspace realm -- --arch=${{matrix.variant.arch}}
# Due to a limitation in upload-artifact a redundant file is needed to force
# preserving paths (https://github.com/actions/upload-artifact/issues/174)
- name: Upload prebuild artifact
uses: actions/upload-artifact@v3
with:
name: realm-js-prebuilds
path: |
README.md
${{ matrix.variant.artifact-path }}
ios-xcframework:
name: Generate Info.plist with all frameworks in place
needs: [build]
if: ${{ success() || failure() }}
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Download prebuilds
uses: actions/download-artifact@v3
with:
name: realm-js-prebuilds
- name: Regenerate Info.plist
run: scripts/regen-info-plist.sh packages/realm/react-native/ios/realm-js-ios.xcframework
# Due to a limitation in upload-artifact a redundant file is needed to force
# preserving paths (https://github.com/actions/upload-artifact/issues/174)
- name: Upload prebuild artifact
uses: actions/upload-artifact@v3
with:
name: realm-js-prebuilds
path: |
README.md
packages/realm/react-native/ios/realm-js-ios.xcframework/Info.plist
integration-tests:
name: Test ${{ matrix.variant.environment }} on ${{ matrix.variant.os }} (${{matrix.variant.target}})
needs: [bundle, build, ios-xcframework]
if: ${{ success() || failure() }}
env:
REALM_DISABLE_ANALYTICS: 1
MOCHA_REMOTE_TIMEOUT: 60000
LONG_TIMEOUT: 300000 # 5 minutes
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
MOCHA_REMOTE_EXIT_ON_ERROR: true
SPAWN_LOGCAT: true
BAAS_TAG: latest
# Pin the Xcode version
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app
runs-on: ${{ matrix.variant.runner }}
strategy:
fail-fast: false
matrix:
variant:
- { os: linux, target: "test:ci", runner: ubuntu-latest, environment: node }
- { os: linux, target: "test:ci:main", runner: ubuntu-latest, environment: electron }
- { os: linux, target: "test:ci:renderer", runner: ubuntu-latest, environment: electron }
#- { os: windows, target: "test:ci", runner: windows-latest, environment: node}
#- { os: windows, target: "test:ci:main", runner: windows-latest, environment: electron }
#- { os: windows, target: "test:ci:renderer", runner: windows-latest, environment: electron }
- { os: darwin, target: "test:ci:main", runner: macos-latest, environment: electron }
- { os: darwin, target: "test:ci:renderer", runner: macos-latest, environment: electron }
- { os: darwin, target: "test:ci", runner: macos-latest, environment: node }
- { os: android, target: "test:ci:android", runner: macos-latest-large, environment: react-native, arch: "armeabi-v7a" }
- { os: ios, target: "test:ci:ios", runner: macos-latest-xlarge, environment: react-native, arch: "ios" }
#- { os: ios, target: "test:ci:catalyst", runner: macos-latest, environment: react-native, arch: "catalyst" }
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup node version
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Generate server configuration
id: baas-config
run:
suffix=$(node -p 'Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)');
subdomain="realm-js-test-server-${{ github.run_id }}-${{ github.run_attempt }}-${suffix}";
echo "subdomain=${subdomain}" >> $GITHUB_OUTPUT;
echo "url=https://${subdomain}.ngrok.io" >> $GITHUB_OUTPUT;
- name: Trigger the test server workflow to start the server
run: gh workflow run test-server.yml -f ngrok_subdomain=${{ steps.baas-config.outputs.subdomain }} -f run_id=${{ github.run_id }} -f server_tag=${{ env.BAAS_TAG }}
env:
GH_TOKEN: ${{ github.token }}
- name: Get NPM cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore NPM cache
id: npm-cache
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Restore Wireit cache
uses: google/wireit@setup-github-actions-caching/v1
- name: Restore React Native cache
if: ${{ matrix.variant.environment == 'react-native' }}
uses: actions/cache@v3
with:
path: '**/Pods'
key: ${{ runner.os }}-${{matrix.variant.environment}}-${{ hashFiles('**/Podfile.lock', './src/**', './vendor/**') }}
restore-keys: |
${{ runner.os }}-${{matrix.variant.environment}}-
- name: MSVC Setup
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
- name: ccache
uses: hendrikmuhs/ccache-action@v1
if: ${{ matrix.variant.environment == 'react-native' }}
with:
key: ${{ runner.os }}-${{ matrix.variant.os }}-${{ matrix.variant.arch }}
max-size: '2.0G'
# in CI file timestamps change with every run so instead rely on file content hashing
# https://reactnative.dev/docs/build-speed#using-this-approach-on-a-ci
- name: Configure ccache
if: ${{ matrix.variant.environment == 'react-native' }}
run: ccache --set-config="compiler_check=content"
- name: Install IOS tools
if: ${{ (matrix.variant.os == 'ios') }}
run: |
npm install -g ios-deploy
- name: Set xvfb wrapper for Linux / electron tests
if: ${{ (matrix.variant.os == 'linux') && (matrix.variant.environment == 'electron' )}}
run: |
sudo apt-get install xvfb
echo "wrapper=xvfb-run" >> $GITHUB_ENV
- name: Download bundles
uses: actions/download-artifact@v3
with:
name: realm-js-bundles
- name: Download prebuilds
uses: actions/download-artifact@v3
with:
name: realm-js-prebuilds
- name: Install dependencies
run: npm ci
env:
# Ensure we install the prebuild built in the previous job
npm_config_realm_local_prebuilds: ${{github.workspace}}/packages/realm/prebuilds
- name: Invoke the simulator (making subsequent "open -a Simulator" calls work)
if: ${{ (matrix.variant.os == 'ios') }}
run: open -a ${{ env.DEVELOPER_DIR }}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
- name: Create Mocha Remote Context
id: mocha-env
run: echo "context=syncLogLevel=warn,longTimeout=${{ env.LONG_TIMEOUT }},realmBaseUrl=${{ steps.baas-config.outputs.url }}" >> $GITHUB_OUTPUT
- name: Wait for the server to start
run: npx wait-on ${{ steps.baas-config.outputs.url }}
- name: Run ${{matrix.variant.target}} (${{ matrix.variant.os}} / ${{ matrix.variant.environment }})
if: ${{ (matrix.variant.os != 'android') && (matrix.variant.os != 'ios') }}
env:
MOCHA_REMOTE_CONTEXT: ${{ steps.mocha-env.outputs.context }}
# The non react native environments should not take so long
timeout-minutes: 60
run: ${{ env.wrapper }} npm run ${{ matrix.variant.target}} --prefix integration-tests/environments/${{ matrix.variant.environment }}
- name: Run ${{matrix.variant.target}} (${{ matrix.variant.os}} / ${{ matrix.variant.environment }})
if: ${{ (matrix.variant.os == 'ios') }}
env:
MOCHA_REMOTE_CONTEXT: ${{ steps.mocha-env.outputs.context }}
timeout-minutes: 75
run: npm run ${{ matrix.variant.target}} --prefix integration-tests/environments/${{ matrix.variant.environment }}
- name: Setup Java Gradle cache for android test app
if: ${{ (matrix.variant.os == 'android') }}
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Android Emulator cache
if: ${{ (matrix.variant.os == 'android') }}
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- uses: actions/setup-java@v3
if: ${{ (matrix.variant.os == 'android') }}
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Run ${{matrix.variant.target}} (${{ matrix.variant.os}} / ${{ matrix.variant.environment }})
if: ${{ (matrix.variant.os == 'android') }}
env:
MOCHA_REMOTE_CONTEXT: ${{ steps.mocha-env.outputs.context }}
timeout-minutes: 75
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
arch: x86
ndk: ${{ env.NDK_VERSION }}
cmake: 3.22.1
script: npm run ${{ matrix.variant.target}} --prefix integration-tests/environments/${{ matrix.variant.environment }}