-
Notifications
You must be signed in to change notification settings - Fork 2.3k
457 lines (407 loc) · 18.3 KB
/
tests_e2e_ios.yml
File metadata and controls
457 lines (407 loc) · 18.3 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
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
name: Testing E2E iOS
on:
workflow_dispatch:
inputs:
iterations:
description: 'Number of iterations to run. Default 1. Max 122.'
required: true
default: 1
type: number
pull_request:
branches:
- '**'
paths-ignore:
- 'docs/**'
- 'website/**'
- '.spellcheck.dict.txt'
- '**/*.md'
push:
branches:
- main
- v14-release
paths-ignore:
- 'docs/**'
- 'website/**'
- '.spellcheck.dict.txt'
- '**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# We want to generate our matrix dynamically
# Initial job generates the matrix as a JSON, and following job will use deserialize and use the result
matrix_prep:
# Do not run the scheduled jobs on forks
if: (github.event_name == 'schedule' && github.repository == 'invertase/react-native-firebase') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.result }}
steps:
- id: build-matrix
# https://github.com/actions/github-script/releases
uses: actions/github-script@d746ffe35508b1917358783b479e04febd2b8f71 # v9.0.0
with:
script: |
// by default, we will run one iteration
let iterationArray = [0]
// workflow dispatch will be a drop-down of different options
if (context.eventName === "workflow_dispatch") {
const inputs = ${{ toJSON(inputs) }}
console.log('inputs is: ' + JSON.stringify(inputs))
const iterationInput = inputs.iterations
console.log('iterations input is: ' + iterationInput)
// this will expand for example with input 5 => [0, 1, 2, 3, 4]
iterationArray = []
for (let i = 0; i < iterationInput; i++) {
iterationArray.push(i);
}
console.log('iterationArray is: ' + iterationArray)
}
// If we are running on a schedule it's our periodic passive scan for flakes
// Goal is to run enough iterations on all systems that we have confidence there are no flakes
if (context.eventName === "schedule") {
const iterationCount = 15
for (let i = 0; i < iterationCount; i++) {
iterationArray.push(i);
}
}
// we want to test debug and release - they generate different code
let buildmode = ['debug', 'release'];
return {
"iteration": iterationArray,
"buildmode": buildmode
}
- name: Debug Output
run: echo "${{ steps.build-matrix.outputs.result }}"
# This uses the matrix generated from the matrix-prep stage
# it will run unit tests on whatever OS combinations are desired
ios:
name: iOS (${{ matrix.buildmode }}, ${{ matrix.iteration }})
runs-on: macos-15
needs: matrix_prep
# TODO matrix across APIs, at least 11 and 15 (lowest to highest)
timeout-minutes: 80
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CCACHE_SLOPPINESS: clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros
CCACHE_FILECLONE: true
CCACHE_DEPEND: true
CCACHE_INODECACHE: true
CCACHE_LIMIT_MULTIPLE: 0.95
# possibly pin to higher-performance versions (e.g. 26.0.1 was better than 26.2)
# but firebase-ios-sdk requires Xcode 26.2+ now, so unpinned at the moment.
XCODE_VERSION: latest-stable
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
steps:
- name: Setup Environment for Screen Recording
# https://github.com/guidepup/setup-action/releases
uses: guidepup/setup-action@4aa2ebd687ff687a31d7c17184beac3c606d64cd # v0.19.0
continue-on-error: true
with:
record: true
- name: Upload Screen Recording Environment Setup
# https://github.com/actions/upload-artifact/releases
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: always()
with:
name: screenrecording-setup-${{ matrix.buildmode }}-${{ matrix.iteration }}.mov
path: ./recordings/
# Set up tool versions
# https://github.com/actions/setup-node/releases
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
- name: Configure JDK
# https://github.com/actions/setup-java/releases
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
distribution: 'temurin'
java-version: '21'
# https://github.com/maxim-lobanov/setup-xcode/releases
- uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Workaround Simulator Availability issues
run: |
# If using `latest-stable` xcode-version above, this is likely not needed.
# If you use *anything* but latest-stable, you may inadvertently be using a SimRuntime that is no longer installed.
# This will install the needed SimRuntime if it is missing.
if [[ "$XCODE_VERSION" != "latest-stable" ]] && ! xcrun simctl list | grep "^iOS $XCODE_VERSION"; then
# note if you specify the build version to be exactly same as xcode version
# you may see "iOS <version> is not available for download"
#xcodebuild -downloadPlatform iOS -buildVersion "$XCODE_VERSION"
xcodebuild -downloadPlatform iOS
fi
# Apparently just listing the installed simulators fixes availability inconsistency
# Without this, runs fail *intermittently* with build target not available because simulators not available
# See https://github.com/actions/runner-images/issues/13459#issuecomment-3681674842
xcrun simctl list
# https://github.com/actions/checkout/releases
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 50
# Set path variables needed for caches
- name: Set workflow variables
id: workflow-variables
run: |
echo "metro-cache=$HOME/.metro" >> $GITHUB_OUTPUT
echo "xcode-version=$(xcodebuild -version|tail -1|cut -f3 -d' ')" >> $GITHUB_OUTPUT
- name: Yarn Cache Restore
# https://github.com/actions/cache/releases
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: yarn-cache
continue-on-error: true
with:
path: .yarn/cache
key: ${{ runner.os }}-ios-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-ios-yarn-v1
- name: Detox Framework Cache Restore
# https://github.com/actions/cache/releases
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: detox-cache
continue-on-error: true
with:
path: ~/Library/Detox/ios
key: ${{ runner.os }}-detox-framework-cache-${{ steps.workflow-variables.outputs.xcode-version }}
# Detox is compiled during yarn install, using Xcode, set up cache first
# https://github.com/hendrikmuhs/ccache-action/releases
- uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
name: Xcode Compile Cache
with:
key: ${{ runner.os }}-${{ matrix.buildmode }}-ios-v3 # makes a unique key w/related restore key internally
save: "${{ github.ref == 'refs/heads/main' }}"
create-symlink: true
max-size: 1500M
- name: Yarn Install
# https://github.com/nick-fields/retry/releases
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 15
retry_wait_seconds: 60
max_attempts: 3
command: yarn
- name: Setup Ruby
# https://github.com/ruby/setup-ruby/releases
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
with:
ruby-version: 3
- name: Update Ruby build tools
# https://github.com/nick-fields/retry/releases
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 2
retry_wait_seconds: 60
max_attempts: 3
command: gem update cocoapods xcodeproj
- name: Pods Cache Restore
# https://github.com/actions/cache/releases
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: pods-cache
continue-on-error: true
with:
path: tests/ios/Pods
key: ${{ runner.os }}-ios-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
restore-keys: ${{ runner.os }}-ios-pods-v3
- name: Pod Install
# https://github.com/nick-fields/retry/releases
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 20
retry_wait_seconds: 30
max_attempts: 3
command: yarn tests:ios:pod:install
- name: Firestore Emulator Restore
# https://github.com/actions/cache/releases
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: firestore-emulator-cache
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
path: ~/.cache/firebase/emulators
key: firebase-emulators-v1-${{ github.run_id }}
restore-keys: firebase-emulators-v1
- name: Start Firestore Emulator
run: yarn tests:emulator:start-ci
# https://bitrise.io/blog/post/xcode-15-performance-regressions
# https://developer.apple.com/forums/thread/805625?answerId=865340022#865340022
- name: Install yeetd and fix iOS perf issues
run: |
wget https://github.com/biscuitehh/yeetd/releases/download/1.0/yeetd-normal.pkg
sudo installer -pkg yeetd-normal.pkg -target /
yeetd &
launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Root.plist
- name: Install brew utilities
# https://github.com/nick-fields/retry/releases
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 5
retry_wait_seconds: 60
max_attempts: 3
command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew && HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils xcbeautify
- name: Build iOS App Debug
if: contains(matrix.buildmode, 'debug')
run: |
ccache -s
export SKIP_BUNDLING=1
export RCT_NO_LAUNCH_PACKAGER=1
set -o pipefail
echo $PATH
which clang
yarn tests:ios:build
ccache -s
shell: bash
- name: Build iOS App Release
if: contains(matrix.buildmode, 'release')
run: |
ccache -s
export RCT_NO_LAUNCH_PACKAGER=1
set -o pipefail
echo $PATH
which clang
yarn tests:ios:build:release
ccache -s
shell: bash
- name: Metro Bundler Cache Restore
if: contains(matrix.buildmode, 'debug')
# https://github.com/actions/cache/releases
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: metro-bundler-cache
continue-on-error: true
with:
path: ${{ steps.workflow-variables.outputs.metro-cache }}
key: ${{ runner.os }}-ios-metro-v1-${{ github.run_id }}
restore-keys: ${{ runner.os }}-ios-metro-v1
- name: Pre-fetch Javascript bundle
if: contains(matrix.buildmode, 'debug')
run: |
nohup yarn tests:packager:jet-ci &
printf 'Waiting for packager to come online'
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do
printf '.'
sleep 2
done
echo "Packager is online! Preparing bundle..."
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&inlineSourceMap=true"
echo "...javascript bundle ready"
- name: Start Screen and Simulator Recordings and System Logging
# With a little delay so the detox test below has time to spawn it, missing the first part of boot is fine
continue-on-error: true
run: |
nohup sh -c "sleep 314159265 | screencapture -v -C -k -T0 -g screenrecording.mov > screenrecording.log 2>&1 &"
nohup sh -c "log stream --backtrace --color none --style syslog > syslog.log 2>&1 &"
nohup sh -c "sleep 110 && xcrun simctl io booted recordVideo --codec=h264 -f simulator.mp4 2>&1 &"
- name: Create Simulator Log
# With a little delay so the detox test below has time to spawn it, missing the first part of boot is fine
# If you boot the simulator separately from detox, some other race fails and detox testee never sends ready to proxy
continue-on-error: true
run: nohup sh -c "sleep 110 && xcrun simctl spawn booted log stream --level debug --style compact > simulator.log 2>&1 &"
- name: Pre-Boot Simulator
# The goal here is to separate Simulator boot from Detox run,
# So that Simulator boot issues we seem to have may be handled separately
# https://github.com/nick-fields/retry/releases
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 5
retry_wait_seconds: 60
max_attempts: 3
command: ./.github/workflows/scripts/boot-simulator.sh
- name: Detox Test Debug
if: contains(matrix.buildmode, 'debug')
timeout-minutes: 55
run: yarn tests:ios:test-cover
- name: Detox Test Release
if: contains(matrix.buildmode, 'release')
timeout-minutes: 55
run: yarn tests:ios:test:release
- name: Stop Screen and App Video and System Logging
if: always()
continue-on-error: true
run: |
killall -int simctl
killall -int screencapture
killall -int log
- name: Upload App Video
# https://github.com/actions/upload-artifact/releases
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: always()
with:
name: simulator-${{ matrix.buildmode }}-${{ matrix.iteration }}_video
path: simulator.mp4
- name: Upload Simulator Log
# https://github.com/actions/upload-artifact/releases
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: always()
with:
name: simulator-${{ matrix.buildmode }}-${{ matrix.iteration }}_log
path: simulator.log
- name: Upload Screen Recording
# https://github.com/actions/upload-artifact/releases
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: always()
with:
name: screenrecording-${{ matrix.buildmode }}-${{ matrix.iteration }}
path: screenrecording.*
- name: Upload Firebase emulator script logs
# https://github.com/actions/upload-artifact/releases
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
if: always()
with:
name: emulator-scripts-logs-${{ matrix.buildmode }}-${{ matrix.iteration }}
path: .github/workflows/scripts/*.log
# https://github.com/codecov/codecov-action/releases
- uses: codecov/codecov-action@3f20e214133d0983f9a10f3d63b0faf9241a3daa # v6.0.0
if: contains(matrix.buildmode, 'debug')
continue-on-error: true
with:
verbose: true
- name: Yarn Cache Save
# https://github.com/actions/cache/releases
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: "${{ github.ref == 'refs/heads/main' }}"
continue-on-error: true
with:
path: .yarn/cache
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}
- name: Detox Framework Cache Save
# https://github.com/actions/cache/releases
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: "${{ github.ref == 'refs/heads/main' }}"
continue-on-error: true
with:
path: ~/Library/Detox/ios
key: ${{ steps.detox-cache.outputs.cache-primary-key }}
- name: Pods Cache Save
# https://github.com/actions/cache/releases
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: "${{ github.ref == 'refs/heads/main' }}"
continue-on-error: true
with:
path: tests/ios/Pods
key: ${{ steps.pods-cache.outputs.cache-primary-key }}
- name: Firestore Emulator Cache Save
# https://github.com/actions/cache/releases
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: "${{ github.ref == 'refs/heads/main' }}"
continue-on-error: true
with:
# The firebase emulators are pure javascript and java, OS-independent
enableCrossOsArchive: true
path: ~/.cache/firebase/emulators
key: ${{ steps.firestore-emulator-cache.outputs.cache-primary-key }}
- name: Metro Bundler Cache Save
# https://github.com/actions/cache/releases
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: "${{ contains(matrix.buildmode, 'debug') && github.ref == 'refs/heads/main' }}"
continue-on-error: true
with:
path: ${{ steps.workflow-variables.outputs.metro-cache }}
key: ${{ steps.metro-bundler-cache.outputs.cache-primary-key }}