forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
479 lines (426 loc) · 15 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
aliases:
- &restore-node-cache
keys:
- v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
# Fallback in case checksum fails
- v1-dependencies-{{ arch }}-{{ .Branch }}-
- &save-node-cache
paths:
- node_modules
key: v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
- &restore-cache-analysis
keys:
- v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
# Fallback in case checksum fails
- v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-
- &save-cache-analysis
paths:
- node_modules
key: v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
- &restore-cache-android-packages
keys:
- v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }}
# Fallback in case checksum fails
- v1-android-sdkmanager-packages-{{ arch }}-
- &save-cache-android-packages
paths:
- /opt/android/sdk/system-images/android-23
- /opt/android/sdk/system-images/android-19
- /opt/android/sdk/platforms/android-26
- /opt/android/sdk/platforms/android-23
- /opt/android/sdk/platforms/android-19
- /opt/android/sdk/build-tools/23.0.1
- /opt/android/sdk/add-ons/addon-google_apis-google-23
key: v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }}
- &restore-cache-ndk
keys:
- v1-android-ndk-{{ arch }}-r10e-32-64
- &install-ndk
|
source scripts/circle-ci-android-setup.sh && getAndroidNDK
- &save-cache-ndk
paths:
- /opt/ndk
key: v1-android-ndk-{{ arch }}-r10e-32-64
- &restore-cache-buck-downloads
keys:
- v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
# Fallback in case checksum fails
- v1-buck-downloads-{{ arch }}-{{ .Branch }}-
- &save-cache-buck-downloads
paths:
- "ReactAndroid/build/downloads"
key: v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
- &restore-cache-buck
keys:
- v1-buck-{{ arch }}-v2017.11.16.01
- &save-cache-buck
paths:
- ~/buck
key: v1-buck-{{ arch }}-v2017.11.16.01
- &restore-cache-watchman
keys:
- v1-watchman-{{ arch }}-v4.9.0
- &save-cache-watchman
paths:
- ~/watchman
key: v1-watchman-{{ arch }}-v4.9.0
- &install-node-dependencies
|
npm install --no-package-lock --no-spin --no-progress
- &install-buck
|
if [[ ! -e ~/buck ]]; then
git clone https://github.com/facebook/buck.git ~/buck --branch v2017.09.04.02 --depth=1
fi
cd ~/buck && ant
buck --version
- &install-node
|
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
- &run-node-tests
|
npm test -- --maxWorkers=2
npm run lint
npm run flow -- check
- &filter-only-master-stable
branches:
only:
- /.*-stable/
- master
- &filter-only-stable
branches:
only:
- /.*-stable/
- &filter-ignore-gh-pages
branches:
ignore: gh-pages
- &filter-ignore-master-stable
branches:
ignore:
- master
- /.*-stable/
- gh-pages
- &create-ndk-directory
|
if [[ ! -e /opt/ndk ]]; then
sudo mkdir /opt/ndk
fi
sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /opt/ndk
# CircleCI does not support interpolating env variables in the environment
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
- &configure-android-path
|
echo 'export PATH=${ANDROID_NDK}:~/react-native/gradle-2.9/bin:~/buck/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
- &install-android-packages
|
source scripts/circle-ci-android-setup.sh && getAndroidSDK
- &install-build-dependencies
|
sudo apt-get update -y
sudo apt-get install ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev file -y
- &install-android-app-dependencies
|
buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
buck fetch ReactAndroid/src/main/java/com/facebook/react
buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
buck fetch ReactAndroid/src/test/...
buck fetch ReactAndroid/src/androidTest/...
./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
defaults: &defaults
working_directory: ~/react-native
android_defaults: &android_defaults
<<: *defaults
docker:
- image: circleci/android:api-26-alpha
resource_class: "large"
environment:
- TERM: "dumb"
- ADB_INSTALL_TIMEOUT: 10
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
- ANDROID_NDK: '/opt/ndk/android-ndk-r10e'
- BUILD_THREADS: 2
version: 2
jobs:
# Runs JavaScript tests on Node 8
test-js-node-8:
<<: *defaults
docker:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests
# Runs JavaScript tests on Node 6
test-js-node-6:
<<: *defaults
docker:
- image: circleci/node:6.11.0
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests
# Runs JavaScript tests on Node 4
test-js-node-4:
<<: *defaults
docker:
- image: circleci/node:4.8.4
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: *run-node-tests
# Runs unit tests on iOS devices
test-objc-ios:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/objc-test-ios.sh
# Runs unit tests on tvOS devices
test-objc-tvos:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "Apple TV 1080p (10.0)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/objc-test-tvos.sh
# Runs end to end tests
test-objc-e2e:
<<: *defaults
macos:
xcode: "9.0"
dependencies:
pre:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3;
# Checks podspec
test-podspec:
<<: *defaults
macos:
xcode: "9.0"
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run: ./scripts/process-podspecs.sh
# Publishes new version onto npm
deploy:
<<: *android_defaults
steps:
- checkout
# Configure Android dependencies
- run: *configure-android-path
- run: *install-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
- run: *create-ndk-directory
- restore-cache: *restore-cache-ndk
- run: *install-ndk
- save-cache: *save-cache-ndk
- restore-cache: *restore-cache-buck
- run: *install-buck
- save-cache: *save-cache-buck
- run: *install-node
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-cache-buck-downloads
- run: *install-android-app-dependencies
- save-cache: *save-cache-buck-downloads
- run:
name: Publish React Native Package
command: |
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
git config --global user.email "reactjs-bot@users.noreply.github.com"
git config --global user.name "npm Deployment Script"
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc
node ./scripts/publish-npm.js
else
echo "Skipping deploy."
fi
# Build JavaScript bundle for Android tests
build-js-bundle:
<<: *defaults
docker:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- run:
name: Build JavaScript Bundle
command: node local-cli/cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
- persist_to_workspace:
root: ReactAndroid/src/androidTest/assets/
paths:
- AndroidTestBundle.js
- store_artifacts:
path: ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# Runs unit tests tests on Android
test-android:
<<: *android_defaults
steps:
- checkout
# Configure Android dependencies
- run: *configure-android-path
- run: *install-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
# Starting emulator in advance as it takes some time to boot.
- run:
name: Create Android Virtual Device
command: source scripts/circle-ci-android-setup.sh && createAVD
- run:
name: Launch Android Virtual Device in Background
command: source scripts/circle-ci-android-setup.sh && launchAVD
background: true
# Keep configuring Android dependencies while AVD boots up
- run: *create-ndk-directory
- restore-cache: *restore-cache-ndk
- run: *install-ndk
- save-cache: *save-cache-ndk
- restore-cache: *restore-cache-buck
- run: *install-buck
- save-cache: *save-cache-buck
- run: *install-node
- restore-cache: *restore-node-cache
- run: *install-node-dependencies
- save-cache: *save-node-cache
- restore-cache: *restore-cache-buck-downloads
- run: *install-android-app-dependencies
- save-cache: *save-cache-buck-downloads
- run:
name: Build Android App
command: |
buck build ReactAndroid/src/main/java/com/facebook/react
buck build ReactAndroid/src/main/java/com/facebook/react/shell
# Wait for AVD to finish booting before running tests
- run:
name: Wait for Android Virtual Device
command: source scripts/circle-ci-android-setup.sh && waitForAVD
# The JavaScript Bundle is built as part of the build-js-bundle workflow,
# and is required for instrumentation tests.
- attach_workspace:
at: ReactAndroid/src/androidTest/assets/
- run:
name: Check for JavaScript Bundle
command: |
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
echo "JavaScript bundle missing, verify build-js-bundle step"; exit 1;
else
echo "JavaScript bundle found.";
fi
# Tests
- run:
name: Compile Native Libs for Unit and Integration Tests
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS -Pcom.android.build.threadPoolSize=1
no_output_timeout: 6m
- run:
name: Unit Tests
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS
# Integration Tests
- run:
name: Build and Install Test APK
command: source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
# post (always runs)
- run:
name: Collect Test Results
command: |
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \;
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
analyze-pull-request:
<<: *defaults
docker:
- image: circleci/node:8
steps:
- checkout
- restore-cache: *restore-cache-analysis
- run: *install-node-dependencies
- save-cache: *save-cache-analysis
- run:
name: Analyze Pull Request
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" npm run danger
else
echo "Skipping pull request analysis."
fi
when: always
- run:
name: Analyze Code
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow --silent -- check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js
else
echo "Skipping code analysis."
fi
# Workflows enables us to run multiple jobs in parallel
workflows:
version: 2
build:
jobs:
# Test Javascript on Node 8 and 6
- test-js-node-8:
filters: *filter-ignore-gh-pages
- test-js-node-6:
filters: *filter-ignore-gh-pages
# Test Android
- build-js-bundle:
filters: *filter-ignore-gh-pages
- test-android:
requires:
- build-js-bundle
# Test iOS & tvOS
- test-objc-ios:
filters: *filter-ignore-gh-pages
- test-objc-tvos:
filters: *filter-ignore-gh-pages
- test-objc-e2e:
filters: *filter-ignore-gh-pages
# If we are on a stable branch, deploy to `npm`
- hold:
type: approval
- deploy:
filters: *filter-only-stable
requires:
- hold
- analyze-pull-request:
filters: *filter-ignore-master-stable