-
Notifications
You must be signed in to change notification settings - Fork 565
267 lines (260 loc) · 10.9 KB
/
integration-tests.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
name: Integration Tests
on:
pull_request:
paths:
# Source code
- "*"
- "lib/**"
- "src/**"
- "types/**"
- "react-native/**"
- "vendor/**"
# Integration tests
- "integration-tests/**"
# No need to run when updating documentation
- "!**.md"
# Run this on updates to the workflow
- ".github/workflows/integration-tests.yml"
jobs:
node:
name: Node.js v${{ matrix.node }} on ${{ matrix.os }} (${{ matrix.type }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [12, 14]
#TODO: Reactivate debug when builds are optimized
#type: [release, debug]
type: [release]
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
registry-url: https://registry.npmjs.org/
- name: Install npm v7
# TODO: Remove the following line once we've found a workaround for https://github.com/dotnet/msbuild/issues/5726
if: ${{ matrix.os != 'windows-latest' }}
run: npm install -g npm@7
# The following is a noop on non-windows runners
- name: Install Microsoft Visual C++ cmd tools
uses: ilammy/msvc-dev-cmd@v1
- name: Windows Environment setup
if: ${{ matrix.os == 'windows-latest' }}
shell: powershell
run: |
Invoke-WebRequest -Uri https://static.realm.io/downloads/vcpkg.zip -OutFile C:\vcpkg.zip
Expand-Archive -Path C:\vcpkg.zip -DestinationPath C:\
# Install the root package (--ignore-scripts to avoid downloading or building the native module)
- run: npm ci --ignore-scripts
# Build the native module
- name: Prebuild release binary
run: npx prebuild
if: ${{ matrix.type == 'release' }}
- name: Prebuild debug binary
run: npx prebuild --debug
if: ${{ matrix.type == 'debug' }}
# Bootstrap lerna sub-packages (builds the packages and Realm JS native module)
- run: npx lerna bootstrap --scope realm-node-tests --include-dependencies
env:
npm_config_realm_local_prebuilds: ${{ github.workspace }}/prebuilds
# Run tests
- run: npm test --prefix integration-tests/environments/node
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
electron-linux:
name: Electron on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: Install npm v7
run: npm install -g npm@7
# Install the root package (--ignore-scripts to avoid downloading or building the native module)
- run: npm ci --ignore-scripts
# Bootstrap lerna sub-packages (builds the packages and Realm JS native module)
- run: npx lerna bootstrap --scope realm-electron-tests --include-dependencies
# Run tests (using xvfb-run to enable opening windows in a virtual framebuffer)
- name: Run tests (Electron / Main)
run: xvfb-run npm run test:main --prefix integration-tests/environments/electron
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
- name: Run tests (Electron / Renderer)
run: xvfb-run npm run test:renderer --prefix integration-tests/environments/electron
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
react-native-ios:
name: React Native on ${{matrix.platform.name}} (${{ matrix.type }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
#TODO: Reactivate debug when builds are optimized
#type: [Release, Debug]
type: [Release]
platform: [{ name: ios, build-configuration: simulator }, { name: catalyst, build-configuration: catalyst }]
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: Install npm v7
run: npm install -g npm@7
# Setup tools
- name: Install tools
run: brew install watchman
- name: Install ios-deploy
run: npm install -g ios-deploy
if: ${{matrix.platform.name == 'catalyst'}}
# TODO: Expose a way to skip building the Node.js native module
- name: Patch package.json to avoid building Node.js native module
run: cat <<< $(jq '.scripts.install = "echo skipping building Node.js binary"' < package.json) > package.json
# Caches
- uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-
- uses: actions/cache@v2
name: Restore iOS build folder from cache
with:
path: react-native/ios/build
key: ios-build-dir-${matrix.platform.name}-${matrix.type}-${{ hashFiles('src/**', 'react-native/ios/**', 'vendor/**') }}
restore-keys: |
ios-build-dir-
- uses: actions/cache@v2
name: Restore xcframework from cache
id: cache-xcframework
with:
path: react-native/ios/realm-js-ios.xcframework
key: xcframework-${matrix.platform.name}-${matrix.type}-${{ hashFiles('src/**', 'react-native/ios/**', 'vendor/**') }}
- uses: actions/cache@v2
name: Restore Xcode "derived data" from cache
with:
path: ~/Library/Developer/Xcode/DerivedData
key: xcode-derived-data-${matrix.platform.name}-${matrix.type}
- uses: actions/cache@v2
name: Restore CocoaPods from cache
with:
path: integration-tests/environments/react-native/ios/Pods
key: cocoapods-${matrix.platform.name}-${matrix.type}-${{ hashFiles('integration-tests/environments/react-native/ios/Podfile.lock') }}
restore-keys: | # Enables running from an old build
cocoapods-
- run: npm ci
# Build the iOS xcframework (if cache missed)
- run: ./scripts/build-ios.sh -c ${{ matrix.type }} ${{matrix.platform.build-configuration}}
if: ${{ steps.cache-xcframework.outputs.cache-hit != 'true' }}
# Bootstrap lerna sub-packages (builds the packages, the Realm JS native module and pod install)
- run: npx lerna bootstrap --scope '{realm-integration-tests,realm-react-native-tests}' --include-dependencies
# Run the tests
- name: Run tests (${{matrix.platform.name}}/ Native)
run: npm run test:${{matrix.platform.name}} --prefix integration-tests/environments/react-native
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
MOCHA_REMOTE_EXIT_ON_ERROR: true
- name: Run tests (${{matrix.platform.name}} / Chrome Debugging)
if: ${{ false }}
run: npm run test:${{matrix.platform.name}}:chrome --prefix integration-tests/environments/react-native
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
MOCHA_REMOTE_EXIT_ON_ERROR: true
HEADLESS_DEBUGGER: true
react-native-android:
name: React Native on Android (${{ matrix.type }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
#TODO: Reactivate debug when builds are optimized
#type: [Release, Debug]
type: [Release]
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: Install npm v7
run: npm install -g npm@7
# Setup tools
- name: Install tools
run: brew install watchman
# TODO: Expose a way to skip building the Node.js native module
- name: Patch package.json to avoid building Node.js native module
run: cat <<< $(jq '.scripts.install = "echo skipping building Node.js binary"' < package.json) > package.json
# Install the root package
- uses: actions/cache@v2
name: Restore node_modules
id: cache-node-modules
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
# Caches
- uses: actions/cache@v2
name: Restore Android build folders from cache
with:
path: |
build-realm-android
react-native/android/build
key: android-build-dir-${{ hashFiles('src/**', 'react-native/android/**', 'vendor/**') }}
restore-keys: |
android-build-dir-
- uses: actions/cache@v2
name: Restore Android librealm.so from cache
id: cache-android-so
with:
path: react-native/android/**/librealm.so
key: android-so-${{ hashFiles('src/**', 'react-native/android/**', 'vendor/**') }}
- run: npm ci
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
# Build the Android shared object file (if cache missed)
- run: ANDROID_NDK=$ANDROID_NDK_HOME node scripts/build-android.js --arch=x86 --build-type=${{ matrix.type }}
if: ${{ steps.cache-android-so.outputs.cache-hit != 'true' }}
# Bootstrap lerna sub-packages (builds the packages, the Realm JS native module and pod install)
- run: npx lerna bootstrap --scope '{realm-integration-tests,realm-react-native-tests}' --include-dependencies
# Run the tests
- name: Run tests (Android / Native)
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
emulator-build: 7425822 # https://github.com/ReactiveCircus/android-emulator-runner/issues/160
target: google_apis
script: npm run test:android --prefix integration-tests/environments/react-native
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
MOCHA_REMOTE_EXIT_ON_ERROR: true
SPAWN_LOGCAT: true
- name: Run tests (Android / Chrome Debugging)
if: ${{ false }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
emulator-build: 7425822 # https://github.com/ReactiveCircus/android-emulator-runner/issues/160
target: google_apis
script: npm run test:android:chrome --prefix integration-tests/environments/react-native
env:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
MOCHA_REMOTE_EXIT_ON_ERROR: true
HEADLESS_DEBUGGER: true
SPAWN_LOGCAT: true