Skip to content

Commit 8fa9984

Browse files
hramosfacebook-github-bot
authored andcommitted
Migrate to Circle 2.0
Summary: Following the migration guide. Let's see what happens here. Closes facebook#14955 Differential Revision: D5877682 Pulled By: hramos fbshipit-source-id: 2a40560120b5d8d28bc6c52cc5e5916fd1bba336
1 parent f01c73d commit 8fa9984

File tree

5 files changed

+433
-131
lines changed

5 files changed

+433
-131
lines changed

.circleci/config.yml

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
aliases:
2+
- &restore-cache
3+
keys:
4+
- v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
5+
# Fallback in case checksum fails
6+
- v1-dependencies-{{ .Branch }}-
7+
- &save-cache
8+
paths:
9+
- node_modules
10+
key: v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
11+
12+
- &restore-cache-website
13+
keys:
14+
- v1-website-dependencies-{{ .Branch }}-{{ checksum "website/package.json" }}
15+
# Fallback in case checksum fails
16+
- v1-website-dependencies-{{ .Branch }}-
17+
- &save-cache-website
18+
paths:
19+
- website/node_modules
20+
key: v1-website-dependencies-{{ .Branch }}-{{ checksum "website/package.json" }}
21+
22+
- &restore-cache-danger
23+
keys:
24+
- v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }}
25+
# Fallback in case checksum fails
26+
- v1-danger-dependencies-{{ .Branch }}-
27+
- &save-cache-danger
28+
paths:
29+
- danger/node_modules
30+
key: v1-danger-dependencies-{{ .Branch }}-{{ checksum "danger/package.json" }}
31+
32+
- &restore-cache-android-packages
33+
keys:
34+
- v1-android-sdkmanager-packages-{{ checksum "scripts/circle-ci-android-setup.sh" }}
35+
# Fallback in case checksum fails
36+
- v1-android-sdkmanager-packages-
37+
- &save-cache-android-packages
38+
paths:
39+
- /opt/android/sdk/system-images/android-23
40+
- /opt/android/sdk/system-images/android-19
41+
- /opt/android/sdk/platforms/android-26
42+
- /opt/android/sdk/platforms/android-23
43+
- /opt/android/sdk/platforms/android-19
44+
- /opt/android/sdk/build-tools/23.0.1
45+
- /opt/android/sdk/add-ons/addon-google_apis-google-23
46+
key: v1-android-sdkmanager-packages-{{ checksum "scripts/circle-ci-android-setup.sh" }}
47+
48+
- &restore-cache-ndk
49+
keys:
50+
- v1-android-ndk-r10e-32-64
51+
- &save-cache-ndk
52+
paths:
53+
- /opt/ndk
54+
key: v1-android-ndk-r10e-32-64
55+
56+
- &restore-cache-buck-downloads
57+
keys:
58+
- v1-buck-downloads-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
59+
# Fallback in case checksum fails
60+
- v1-buck-downloads-{{ .Branch }}-
61+
- &save-cache-buck-downloads
62+
paths:
63+
- "ReactAndroid/build/downloads"
64+
key: v1-buck-downloads-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }}
65+
66+
- &restore-cache-buck
67+
keys:
68+
- v1-buck-v2017.09.04.02
69+
- &save-cache-buck
70+
paths:
71+
- ~/buck
72+
key: v1-buck-v2017.09.04.02
73+
74+
- &restore-cache-watchman
75+
keys:
76+
- v1-watchman-v4.9.0
77+
- &save-cache-watchman
78+
paths:
79+
- ~/watchman
80+
key: v1-watchman-v4.9.0
81+
82+
defaults: &defaults
83+
working_directory: ~/react-native
84+
85+
version: 2
86+
jobs:
87+
test-node-8:
88+
<<: *defaults
89+
docker:
90+
- image: circleci/node:8
91+
steps:
92+
- checkout
93+
- run: npm install --no-package-lock
94+
- run: |
95+
npm run lint
96+
npm run flow -- check
97+
npm test -- --maxWorkers=2
98+
# eslint
99+
- run:
100+
name: Analyze Code
101+
command: |
102+
npm install github@0.2.4
103+
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
104+
105+
test-node-6:
106+
<<: *defaults
107+
docker:
108+
- image: circleci/node:6.11.0
109+
steps:
110+
- checkout
111+
- run: npm install
112+
- run: |
113+
npm run lint
114+
npm run flow -- check
115+
npm test -- --maxWorkers=2
116+
117+
test-node-4:
118+
<<: *defaults
119+
docker:
120+
- image: circleci/node:4.8.4
121+
steps:
122+
- checkout
123+
- run: npm install
124+
- run: |
125+
npm run lint
126+
npm run flow -- check
127+
npm test -- --maxWorkers=2
128+
129+
test-website:
130+
<<: *defaults
131+
docker:
132+
- image: circleci/node:8
133+
steps:
134+
- checkout
135+
- run:
136+
name: Install Dependencies
137+
command: |
138+
cd website
139+
npm install --no-package-lock
140+
- run:
141+
name: Test Website
142+
command: |
143+
cd website
144+
npm test
145+
- run:
146+
name: Test Build Static Website
147+
command: cd website && node ./server/generate.js
148+
149+
deploy-website:
150+
<<: *defaults
151+
docker:
152+
- image: circleci/node:8
153+
steps:
154+
- checkout
155+
- run:
156+
name: Install Dependencies
157+
command: |
158+
cd website
159+
npm install --no-package-lock
160+
- run:
161+
name: Build and Deploy Static Website
162+
command: |
163+
if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
164+
git config --global user.email "reactjs-bot@users.noreply.github.com"
165+
git config --global user.name "Website Deployment Script"
166+
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc
167+
168+
echo "Deploying website..."
169+
cd website && GIT_USER=reactjs-bot npm run gh-pages
170+
else
171+
echo "Skipping deploy."
172+
fi
173+
174+
build-js-bundle:
175+
<<: *defaults
176+
docker:
177+
- image: circleci/node:8
178+
steps:
179+
- checkout
180+
- run: npm install --no-package-lock
181+
- run:
182+
name: Build JavaScript Bundle
183+
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
184+
- persist_to_workspace:
185+
root: ReactAndroid/src/androidTest/assets/
186+
paths:
187+
- AndroidTestBundle.js
188+
- store_artifacts:
189+
path: ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
190+
191+
test-android:
192+
<<: *defaults
193+
docker:
194+
- image: circleci/android:api-26-alpha
195+
environment:
196+
- TERM: "dumb"
197+
- ADB_INSTALL_TIMEOUT: 10
198+
- GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"'
199+
- ANDROID_NDK: '/opt/ndk/android-ndk-r10e'
200+
- BUILD_THREADS: 2
201+
steps:
202+
- checkout
203+
# CircleCI does not support interpolating env variables in the environment: step above.
204+
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
205+
- run:
206+
name: Configure PATH
207+
command: |
208+
echo 'export PATH=${ANDROID_NDK}:~/react-native/gradle-2.9/bin:~/buck/bin:$PATH' >> $BASH_ENV
209+
source $BASH_ENV
210+
# Configure dependencies
211+
- run:
212+
name: Install Build Dependencies
213+
command: |
214+
sudo apt-get update -y
215+
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 -y
216+
- restore-cache: *restore-cache-android-packages
217+
- run:
218+
name: Install Android Packages
219+
command: source scripts/circle-ci-android-setup.sh && getAndroidSDK
220+
- save-cache: *save-cache-android-packages
221+
- run:
222+
name: Create Android Virtual Device
223+
command: source scripts/circle-ci-android-setup.sh && createAVD
224+
# Starting emulator in advance as it takes some time to boot.
225+
- run:
226+
name: Launch Android Virtual Device in Background
227+
command: source scripts/circle-ci-android-setup.sh && launchAVD
228+
background: true
229+
# Continue configuring dependencies while AVD boots.
230+
- run:
231+
name: Create Android NDK Directory
232+
command: |
233+
if [[ ! -e /opt/ndk ]]; then
234+
sudo mkdir /opt/ndk
235+
fi
236+
sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /opt/ndk
237+
- restore-cache: *restore-cache-ndk
238+
- run:
239+
name: Install Android NDK
240+
command: source scripts/circle-ci-android-setup.sh && getAndroidNDK
241+
- save-cache: *save-cache-ndk
242+
- restore-cache: *restore-cache-buck
243+
- run:
244+
name: Install Buck
245+
command: |
246+
if [[ ! -e ~/buck ]]; then
247+
git clone https://github.com/facebook/buck.git ~/buck --branch v2017.09.04.02 --depth=1
248+
fi
249+
cd ~/buck && ant
250+
buck --version
251+
- save-cache: *save-cache-buck
252+
- run:
253+
name: Install Node
254+
command: |
255+
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
256+
sudo apt-get install -y nodejs
257+
- run: npm install
258+
# - restore-cache: *restore-cache-watchman
259+
# - run:
260+
# name: Install Watchman Dependencies
261+
# command: |
262+
# sudo apt-get update -y
263+
# sudo apt-get install libtool pkg-config -y
264+
# - run:
265+
# name: Install Watchman
266+
# command: |
267+
# if [[ ! -e ~/watchman ]]; then
268+
# mkdir ~/watchman
269+
# git clone https://github.com/facebook/watchman.git ~/watchman --branch v4.9.0 --depth=1
270+
# cd ~/watchman
271+
# ./autogen.sh
272+
# ./configure
273+
# make
274+
# fi
275+
# cd ~/watchman
276+
# sudo make install
277+
# - save-cache: *save-cache-watchman
278+
- restore-cache: *restore-cache-buck-downloads
279+
- run:
280+
name: Download Android App Dependencies
281+
command: |
282+
buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
283+
buck fetch ReactAndroid/src/main/java/com/facebook/react
284+
buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
285+
buck fetch ReactAndroid/src/test/...
286+
buck fetch ReactAndroid/src/androidTest/...
287+
./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
288+
- save-cache: *save-cache-buck-downloads
289+
- run:
290+
name: Build Android App
291+
command: |
292+
buck build ReactAndroid/src/main/java/com/facebook/react
293+
buck build ReactAndroid/src/main/java/com/facebook/react/shell
294+
# Wait for AVD to finish booting before running tests
295+
- run:
296+
name: Wait for Android Virtual Device
297+
command: source scripts/circle-ci-android-setup.sh && waitForAVD
298+
# The JavaScript Bundle is built as part of the build-js-bundle workflow, and is required for instrumentation tests.
299+
- attach_workspace:
300+
at: ReactAndroid/src/androidTest/assets/
301+
- run:
302+
name: Check for JavaScript Bundle
303+
command: |
304+
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
305+
echo "JavaScript bundle missing, verify build-js-bundle step"; exit 1;
306+
else
307+
echo "JavaScript bundle found.";
308+
fi
309+
# Tests
310+
- run:
311+
name: Compile Native Libs for Unit and Integration Tests
312+
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS -Pcom.android.build.threadPoolSize=1
313+
no_output_timeout: 6m
314+
- run:
315+
name: Unit Tests
316+
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS
317+
# Integration Tests
318+
- run:
319+
name: Build and Install Test APK
320+
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
321+
# Failing test is expected
322+
# - run:
323+
# name: Run Installed APK with Tests
324+
# command: node ./scripts/run-android-ci-instrumentation-tests.js --retries 3 --path ./ReactAndroid/src/androidTest/java/com/facebook/react/tests --package com.facebook.react.tests
325+
# Should be disabled pending on https://our.intern.facebook.com/intern/tasks?t=16912142
326+
# - run:
327+
# name: Run Android End to End Tests
328+
# command: source scripts/circle-ci-android-setup.sh && retry3 node ./scripts/run-ci-e2e-tests.js --android --js --retries 2
329+
330+
# post (always runs)
331+
- run:
332+
name: Collect Test Results
333+
command: |
334+
mkdir -p ~/junit/
335+
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \;
336+
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \;
337+
# TODO circle does not understand Buck's report, maybe need to transform xml slightly
338+
# find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/junit/ \;
339+
when: always
340+
- store_test_results:
341+
path: ~/junit
342+
- store_artifacts:
343+
path: ~/junit
344+
345+
# Workflows enables us to run multiple jobs in parallel
346+
workflows:
347+
version: 2
348+
test_node:
349+
jobs:
350+
- test-node-8
351+
- test-node-6
352+
# Node 4 tests are already failing on Circle 1.0
353+
# - test-node-4
354+
website:
355+
jobs:
356+
- test-website
357+
- deploy-website:
358+
requires:
359+
- test-website
360+
filters:
361+
branches:
362+
only:
363+
- /.*-stable/
364+
- master
365+
test_android:
366+
jobs:
367+
- build-js-bundle:
368+
filters:
369+
branches:
370+
ignore: gh-pages
371+
- test-android:
372+
requires:
373+
- build-js-bundle

ReactAndroid/DEFS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs):
8686
'-XX:MaxPermSize=620m',
8787
'-Drobolectric.offline=true',
8888
]
89-
if os.path.isdir("/dev/shm"):
89+
if os.path.isdir("/dev/shm") and not os.environ['CIRCLECI']:
9090
extra_vm_args.append('-Djava.io.tmpdir=/dev/shm')
9191
else:
9292
extra_vm_args.append(
@@ -110,4 +110,4 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs):
110110

111111
original_cxx_library = cxx_library
112112
def cxx_library(allow_jni_merging=None, **kwargs):
113-
original_cxx_library(**kwargs)
113+
original_cxx_library(**kwargs)

0 commit comments

Comments
 (0)