-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathconfig.yml
558 lines (460 loc) · 17.1 KB
/
config.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
#
# Copyright (c) 2016-present Invertase Limited & Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this library except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
aliases:
# -------------------------
# CACHE
# -------------------------
- &restore-yarn-cache
key: v1-yarn-cache-{{ arch }}-{{ checksum "~/.checksumfiles/package.json" }}-{{ checksum "yarn.lock" }}
- &save-yarn-cache
paths:
- ~/.cache/yarn
- ~/Library/Detox
key: v1-yarn-cache-{{ arch }}-{{ checksum "~/.checksumfiles/package.json" }}-{{ checksum "yarn.lock" }}
# -------------------------
# iOS
# -------------------------
- &save-pods-cache
paths:
- ~/react-native-firebase/tests/ios/Pods
key: v1-pods-cache-{{ arch }}-{{ checksum "~/.checksumfiles/combined.podspec" }}-{{ checksum "tests/ios/Podfile" }}-{{ checksum "tests/ios/Podfile.lock" }}
when: always
- &restore-pods-cache
key: v1-pods-cache-{{ arch }}-{{ checksum "~/.checksumfiles/combined.podspec" }}-{{ checksum "tests/ios/Podfile" }}-{{ checksum "tests/ios/Podfile.lock" }}
- &save-ios-build-cache
paths:
- ~/react-native-firebase/tests/ios/build/Build
key: v1-ios-pods-build-cache-{{ arch }}-{{ checksum "~/.checksumfiles/combined.podspec" }}-{{ checksum "tests/ios/Podfile" }}-{{ checksum "tests/ios/Podfile.lock" }}
when: always
- &restore-ios-build-cache
key: v1-ios-pods-build-cache-{{ arch }}-{{ checksum "~/.checksumfiles/combined.podspec" }}-{{ checksum "tests/ios/Podfile" }}-{{ checksum "tests/ios/Podfile.lock" }}
# -------------------------
# Android
# -------------------------
- &save-gradle-home-caches
name: Saving Gradle home cache
paths:
- ~/.gradle/caches/
key: v1-gradle-home-cache-{{ checksum "~/.checksumfiles/build.gradle" }}-{{ checksum "~/.checksumfiles/settings.gradle" }}
- &restore-gradle-home-caches
keys:
- v1-gradle-home-cache-{{ checksum "~/.checksumfiles/build.gradle" }}-{{ checksum "~/.checksumfiles/settings.gradle" }}
- v1-gradle-home-cache
- &save-gradle-wrapper-cache
name: Saving Gradle wrapper cache
paths:
- ~/.gradle/wrapper/
key: v1-gradle-wrapper-{{ checksum "tests/android/gradle/wrapper/gradle-wrapper.properties" }}
- &restore-gradle-wrapper-cache
keys:
- v1-gradle-wrapper-{{ checksum "tests/android/gradle/wrapper/gradle-wrapper.properties" }}
- &collect-gradle-build-caches
name: Collecting Gradle Build caches for saving
command: |
mkdir -p ~/gradle-build-caches
[ -d ~/.gradle/caches ] &&
[ -n "$(ls -Ad ~/.gradle/caches/build-cache-* 2>/dev/null)" ] &&
rm -rf ~/gradle-build-caches/* &&
mv ~/.gradle/caches/build-cache-* ~/gradle-build-caches || true
when: always
- &save-gradle-debug-build-cache
name: Saving Gradle Build caches
paths:
- ~/gradle-build-caches
key: v1-gradle-debug-build-cache-{{ .Revision }}
when: always
- &save-gradle-release-build-cache
name: Saving Gradle Build caches
paths:
- ~/gradle-build-caches
key: v1-gradle-release-build-cache-{{ .Revision }}
when: always
- &disperse-gradle-build-caches
name: Dispersing Gradle Build caches for restoring
command: |
[ -d ~/gradle-build-caches ] &&
[ -n "$(ls -A ~/gradle-build-caches)" ] &&
rm -rf ~/.gradle/caches/build-cache-* &&
mkdir -p ~/.gradle/caches/ &&
mv ~/gradle-build-caches/* ~/.gradle/caches/ || true
- &restore-gradle-debug-build-cache
name: Restoring Gradle Build caches
keys:
- v1-gradle-debug-build-cache-{{ .Revision }}
- v1-gradle-debug-build-cache
- &restore-gradle-release-build-cache
name: Restoring Gradle Build caches
keys:
- v1-gradle-release-build-cache-{{ .Revision }}
- v1-gradle-release-build-cache
# -------------------------
# BREW
# -------------------------
- &save-brew-cache-ios
paths:
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
key: v7-brew-cache-{{ arch }}-ios
- &restore-brew-cache-ios
keys:
- v7-brew-cache-{{ arch }}-ios
- &save-brew-cache-android
paths:
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
key: v7-brew-cache-{{ arch }}-android
- &restore-brew-cache-android
keys:
- v7-brew-cache-{{ arch }}-android
# -------------------------
# SHARED RUN COMMANDS
# -------------------------
- &packager-jet
name: Start React Native Packager (background)
background: true
command: yarn run tests:packager:jet || true
- &packager-warmup
name: Warm up Packager
background: true
command: node .circleci/scripts/packager-warmup.js
- &make-cache-check-files
name: Make Cache Checksum Files
command: |
mkdir -p ~/.checksumfiles
find . -type f -name 'build.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.checksumfiles/build.gradle
find . -type f -name 'settings.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.checksumfiles/settings.gradle
find . -type f -name '*.podspec' -not -path "*node_modules*" -exec cat {} + >> ~/.checksumfiles/combined.podspec
find . -type f -name 'package.json' -not -path "*node_modules*" -exec cat {} + >> ~/.checksumfiles/package.json
# -------------------------
# INSTALLATION
# -------------------------
- &yarn
name: Yarn Install
command: |
yarn install --non-interactive --cache-folder ~/.cache/yarn
# -------------------------
# ANALYSE
# -------------------------
# eslint
- &eslint
name: Lint JS Code (ESLint)
command: yarn run validate:all:js
# typescript
- &validate-ts-declarations
name: Validate TypeScript Declarations
command: yarn run validate:all:ts
# flow
- &validate-flow-declarations
name: Validate Flow Declarations
command: yarn run validate:all:flow
# -------------------------
# ANDROID
# -------------------------
# - &android-accept-licenses
# name: Accept Android Licenses
# shell: /bin/bash -e
# command: |
# yes | sdkmanager --licenses
# yes | sdkmanager --update
# -------------------------
# DEFAULTS
# -------------------------
defaults: &defaults
working_directory: ~/react-native-firebase
environment:
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
# JAVASCRIPT
js_defaults: &js_defaults
<<: *defaults
docker:
- image: circleci/node:8
environment:
- PATH: '/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
# ANDROID
android_defaults: &android_defaults
<<: *defaults
docker:
- image: invertase/react-native-firebase-android:release
resource_class: 'xlarge'
working_directory: ~/react-native-firebase
environment:
- _JAVA_OPTIONS: '-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xmx2048m'
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError -Xmx2048m"'
# IOS
macos_defaults: &macos_defaults
<<: *defaults
resource_class: 'medium'
macos:
xcode: '10.1.0'
# -------------------------
# JOBS
# -------------------------
version: 2
jobs:
# Set up a Node environment for downstream jobs
checkout-code:
<<: *js_defaults
steps:
- checkout
- persist_to_workspace:
root: .
paths: .
analyse:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/react-native-firebase
- run: *make-cache-check-files
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *eslint
- run: *validate-flow-declarations
- run: *validate-ts-declarations
# -------------------------
# ANDROID - BUILD
# -------------------------
android-build-debug:
<<: *android_defaults
steps:
- attach_workspace:
at: ~/react-native-firebase
- run: *make-cache-check-files
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- restore-cache: *restore-gradle-wrapper-cache
- restore_cache: *restore-gradle-home-caches
- restore-cache: *restore-gradle-debug-build-cache
- run: *disperse-gradle-build-caches
# - run: *android-accept-licenses
# download and cache dependencies and Gradle
- run:
name: Downloading Gradle Dependencies
command: cd tests/android && ./gradlew --max-workers 6 downloadDependencies
- save-cache: *save-gradle-wrapper-cache
- save-cache: *save-gradle-home-caches
- run:
name: Build Android Testing App
command: cd tests/android && chmod +x gradlew && ./gradlew --build-cache --max-workers 6 --continue assembleDebug assembleAndroidTest -DtestBuildType=debug --stacktrace
- run: *collect-gradle-build-caches
- save-cache: *save-gradle-debug-build-cache
- persist_to_workspace:
root: ~/react-native-firebase
paths:
- tests/android/app/build/outputs/apk
android-build-release:
<<: *android_defaults
steps:
- attach_workspace:
at: ~/react-native-firebase
- run: *make-cache-check-files
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- restore-cache: *restore-gradle-wrapper-cache
- restore_cache: *restore-gradle-home-caches
- restore-cache: *restore-gradle-release-build-cache
- run: *disperse-gradle-build-caches
# - run: *android-accept-licenses
# download and cache dependencies and Gradle
- run:
name: Downloading Dependencies
command: cd tests/android && ./gradlew --max-workers 6 downloadDependencies
- save-cache: *save-gradle-wrapper-cache
- save-cache: *save-gradle-home-caches
- run:
name: Build Android Testing App
command: cd tests/android && chmod +x gradlew && ./gradlew --build-cache --max-workers 2 --continue assembleRelease
- run: *collect-gradle-build-caches
- save-cache: *save-gradle-release-build-cache
- persist_to_workspace:
root: ~/react-native-firebase
paths:
- tests/android/app/build/outputs/apk
# -------------------------
# ANDROID - TEST E2E
# -------------------------
android-test-e2e:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native-firebase
- run: *make-cache-check-files
- run:
name: Configure Environment Variables
command: |
echo 'export PATH="$PATH:/usr/local/opt/node@8/bin:~/.yarn/bin:~/react-native-firebase/node_modules/.bin:~/react-native-firebase/tests/node_modules/.bin"' >> $BASH_ENV
echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV
echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> $BASH_ENV
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
echo 'export JAVA_HOME=/Library/Java/Home' >> $BASH_ENV
source $BASH_ENV
- restore-cache: *restore-brew-cache-android
- run:
name: Configure Detox Environment + Android SDK Tools
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install intel-haxm >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install node@8 >/dev/null >/dev/null
- save-cache: *save-brew-cache-android
# Yarn install - to ensure detox post install builds + Symlinks are created
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
# must always be after environment config job but before ios build
- run: *packager-jet
- run: *packager-warmup
- run:
name: Install Android Emulator
shell: /bin/bash -e
command: |
yes | sdkmanager "platform-tools" "tools" >/dev/null
yes | sdkmanager "platforms;android-28" "system-images;android-28;google_apis;x86" >/dev/null
yes | sdkmanager "emulator" --channel=3 >/dev/null
yes | sdkmanager "build-tools;28.0.3" >/dev/null
yes | sdkmanager --licenses >/dev/null
yes | sdkmanager --list
# to force ssh key generation for emulators
- run:
name: ADB Start Stop
command: |
adb start-server
adb devices
adb kill-server
ls -la ~/.android
- run:
name: Create Android Emulator (API 28)
command: avdmanager create avd --force -n TestingAVD -k "system-images;android-28;google_apis;x86" -g google_apis -d "Nexus 4"
- run:
name: Start Android Emulator (API 28) in background
command: |
/usr/local/share/android-sdk/emulator/emulator @TestingAVD -version
/usr/local/share/android-sdk/emulator/emulator @TestingAVD -skin 470x860 -cores 2 -gpu auto -accel on -memory 2048 -no-audio -no-snapshot -no-window -no-boot-anim -logcat *:W | grep -i 'ReactNative\|RNFB\|com.testing\|io.invertase\|firebase'
background: true
- run:
name: Wait for AVD to be ready (API 28)
no_output_timeout: "5m"
command: sh ./.circleci/scripts/wait-for-avd.sh
- run:
name: Run Tests (API 28)
command: yarn run tests:android:test-cover
- run:
name: Submit Coverage
command: yarn run codecov
- store_artifacts:
path: ~/detox-artifacts
# - store_artifacts:
# path: ~/react-native-firebase/coverage
# -------------------------
# iOS - TEST E2E
# -------------------------
ios-test-e2e:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native-firebase
- run: *make-cache-check-files
- run:
name: Start iPhone X simulator (background)
background: true
command: xcrun simctl boot "iPhone X" || true
- run:
name: Configure Environment Variables
command: |
echo 'export PATH="$PATH:/usr/local/opt/node@8/bin:~/.yarn/bin:~/react-native-firebase/node_modules/.bin:~/react-native-firebase/tests/node_modules/.bin"' >> $BASH_ENV
source $BASH_ENV
# Brew
- restore-cache: *restore-brew-cache-ios
- run:
name: Configure Detox Environment
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install node@8 >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install watchman >/dev/null
touch .watchmanconfig
node -v
- save-cache: *save-brew-cache-ios
# Yarn install - to ensure detox post install builds
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
# must always be after environment config job but before ios build
- run: *packager-jet
- run: *packager-warmup
# Pods
- restore-cache: *restore-pods-cache
- run:
name: Install CocoaPods + Pod Install
command: |
cd tests/ios
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
pod install
- save-cache: *save-pods-cache
# XCode Build
- restore-cache: *restore-ios-build-cache
- run:
name: Build iOS Testing App
command: yarn run tests:ios:build
- save-cache: *save-ios-build-cache
- run: mkdir ~/detox-artifacts
# Now Test \o/
- run:
name: Run Jet Tests
command: yarn run tests:ios:test-cover
- run:
name: Submit Coverage
command: yarn run codecov
- store_artifacts:
path: ~/detox-artifacts
# - store_artifacts:
# path: ~/react-native-firebase/coverage
# -------------------------
# WORK FLOWS
# -------------------------
workflows:
version: 2
# filters:
# branches:
# only: master
JS:
jobs:
- checkout-code
- analyse:
requires:
- checkout-code
Android:
jobs:
- checkout-code
- android-build-debug:
requires:
- checkout-code
- android-build-release:
requires:
- checkout-code
- android-test-e2e:
requires:
- android-build-debug
iOS:
jobs:
- checkout-code
- ios-test-e2e:
requires:
- checkout-code