Skip to content

Commit fa11fae

Browse files
hramosfacebook-github-bot
authored andcommittedFeb 6, 2018
Switch e2e to yarn
Summary: Addresses CI build failures due to use of scoped packages by metro. Closes #17878 Differential Revision: D6914937 Pulled By: hramos fbshipit-source-id: e6ce97561035f4deb128cd1e30d81ab4edea3e4c
1 parent 613afba commit fa11fae

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed
 

Diff for: ‎.circleci/config.yml

+28-16
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ aliases:
112112
sudo apt-get install -y nodejs
113113

114114
- &create-ndk-directory
115-
|
115+
name: Create Android NDK Directory
116+
command: |
116117
if [[ ! -e /opt/ndk ]]; then
117118
sudo mkdir /opt/ndk
118119
fi
@@ -121,16 +122,18 @@ aliases:
121122
# CircleCI does not support interpolating env variables in the environment
122123
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
123124
- &configure-android-path
124-
|
125+
name: Configure Environment Variables
126+
command: |
125127
echo 'export PATH=${ANDROID_NDK}:~/react-native/gradle-2.9/bin:~/buck/bin:$PATH' >> $BASH_ENV
126128
source $BASH_ENV
127129
128130
- &install-android-packages
129131
|
130132
source scripts/circle-ci-android-setup.sh && getAndroidSDK
131133

132-
- &install-build-dependencies
133-
|
134+
- &install-android-build-dependencies
135+
name: Install Android Build Dependencies
136+
command: |
134137
sudo apt-get update -y
135138
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
136139
@@ -171,7 +174,6 @@ aliases:
171174
- &build-js-bundle
172175
name: Build JavaScript Bundle
173176
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
174-
when: always
175177

176178
- &compile-native-libs
177179
name: Compile Native Libs for Unit and Integration Tests
@@ -184,7 +186,11 @@ aliases:
184186

185187
- &run-android-instrumentation-tests
186188
name: Run Instrumentation Tests
187-
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
189+
command: |
190+
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
191+
echo "JavaScript bundle missing, cannot run instrumentation tests. Verify build-js-bundle step completed successfully."; exit 1;
192+
fi
193+
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
188194
189195
- &collect-android-test-results
190196
name: Collect Test Results
@@ -254,6 +260,8 @@ jobs:
254260
path: ~/reports/junit
255261
- store_artifacts:
256262
path: ~/reports/junit
263+
- store_artifacts:
264+
path: ~/react-native/yarn.lock
257265

258266
# Runs JavaScript tests on Node 8
259267
js-node-8:
@@ -387,7 +395,7 @@ jobs:
387395

388396
# Configure Android dependencies
389397
- run: *configure-android-path
390-
- run: *install-build-dependencies
398+
- run: *install-android-build-dependencies
391399
- restore-cache: *restore-cache-android-packages
392400
- run: *install-android-packages
393401
- save-cache: *save-cache-android-packages
@@ -430,9 +438,9 @@ jobs:
430438
- checkout
431439
- run: *setup-artifacts
432440

433-
# Configure Android dependencies
441+
# Configure Android SDK and related dependencies
434442
- run: *configure-android-path
435-
- run: *install-build-dependencies
443+
- run: *install-android-build-dependencies
436444
- restore-cache: *restore-cache-android-packages
437445
- run: *install-android-packages
438446
- save-cache: *save-cache-android-packages
@@ -442,11 +450,8 @@ jobs:
442450
- run: *launch-avd
443451

444452
# Keep configuring Android dependencies while AVD boots up
445-
- run: *create-ndk-directory
446-
- restore-cache: *restore-cache-ndk
447-
- run: *install-ndk
448-
- save-cache: *save-cache-ndk
449453

454+
# Fetch dependencies using BUCK
450455
- restore-cache: *restore-cache-buck
451456
- run: *install-buck
452457
- save-cache: *save-cache-buck
@@ -458,10 +463,17 @@ jobs:
458463
- run: buck fetch ReactAndroid/src/androidTest/...
459464
- run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
460465

466+
# Install Android NDK
467+
- run: *create-ndk-directory
468+
- restore-cache: *restore-cache-ndk
469+
- run: *install-ndk
470+
- save-cache: *save-cache-ndk
471+
472+
# Build and compile
461473
- run: *build-android-app
462474
- run: *compile-native-libs
463475

464-
# The JavaScript Bundle is required for instrumentation tests.
476+
# Build JavaScript Bundle for instrumentation tests
465477
- run: *install-node
466478
- run: *install-yarn
467479
- restore-cache: *restore-yarn-cache
@@ -472,7 +484,7 @@ jobs:
472484
# Wait for AVD to finish booting before running tests
473485
- run: *wait-for-avd
474486

475-
# Tests
487+
# Test Suite
476488
- run: *run-android-unit-tests
477489
- run: *run-android-instrumentation-tests
478490

@@ -568,4 +580,4 @@ workflows:
568580
- hold
569581

570582
- analyze-pull-request:
571-
filters: *filter-ignore-master-stable
583+
filters: *filter-ignore-master-stable

Diff for: ‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ node_modules
5151
*.log
5252
.nvm
5353
/bots/node_modules/
54+
55+
# TODO: Check in yarn.lock in open source. Right now we need to keep it out
56+
# from the GitHub repo as importing it might conflict with internal workspaces
5457
*/**/yarn.lock
5558

5659
# OS X

Diff for: ‎scripts/run-ci-e2e-tests.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* --android - 'react-native init' and check Android app doesn't redbox
1818
* --js - 'react-native init' and only check the packager returns a bundle
1919
* --skip-cli-install - to skip react-native-cli global installation (for local debugging)
20-
* --retries [num] - how many times to retry possible flaky commands: npm install and running tests, default 1
20+
* --retries [num] - how many times to retry possible flaky commands: yarn add and running tests, default 1
2121
*/
2222
/*eslint-disable no-undef */
2323
require('shelljs/global');
@@ -44,12 +44,12 @@ let exitCode;
4444
try {
4545
// install CLI
4646
cd('react-native-cli');
47-
exec('npm pack');
47+
exec('yarn pack');
4848
const CLI_PACKAGE = path.join(ROOT, 'react-native-cli', 'react-native-cli-*.tgz');
4949
cd('..');
5050

5151
if (!argv['skip-cli-install']) {
52-
if (exec(`sudo npm install -g ${CLI_PACKAGE}`).code) {
52+
if (exec(`sudo yarn global add ${CLI_PACKAGE}`).code) {
5353
echo('Could not install react-native-cli globally.');
5454
echo('Run with --skip-cli-install to skip this step');
5555
exitCode = 1;
@@ -65,7 +65,7 @@ try {
6565
}
6666
}
6767

68-
if (exec('npm pack').code) {
68+
if (exec('yarn pack').code) {
6969
echo('Failed to pack react-native');
7070
exitCode = 1;
7171
throw Error(exitCode);
@@ -76,7 +76,7 @@ try {
7676
if (tryExecNTimes(
7777
() => {
7878
exec('sleep 10s');
79-
return exec(`react-native init EndToEndTest --version ${PACKAGE} --npm`).code;
79+
return exec(`react-native init EndToEndTest --version ${PACKAGE}`).code;
8080
},
8181
numberOfRetries,
8282
() => rm('-rf', 'EndToEndTest'))) {
@@ -92,7 +92,7 @@ try {
9292
echo('Running an Android e2e test');
9393
echo('Installing e2e framework');
9494
if (tryExecNTimes(
95-
() => exec('npm install --save-dev appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1', { silent: true }).code,
95+
() => exec('yarn add --dev appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1', { silent: true }).code,
9696
numberOfRetries)) {
9797
echo('Failed to install appium');
9898
echo('Most common reason is npm registry connectivity, try again');
@@ -125,7 +125,7 @@ try {
125125

126126
echo(`Starting packager server, ${SERVER_PID}`);
127127
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
128-
const packagerProcess = spawn('npm', ['start', '--', '--max-workers 1'], {
128+
const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], {
129129
env: process.env
130130
});
131131
SERVER_PID = packagerProcess.pid;
@@ -158,7 +158,7 @@ try {
158158
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
159159
const packagerEnv = Object.create(process.env);
160160
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
161-
const packagerProcess = spawn('npm', ['start', '--', '--nonPersistent'],
161+
const packagerProcess = spawn('yarn', ['start', '--nonPersistent'],
162162
{
163163
stdio: 'inherit',
164164
env: packagerEnv
@@ -204,7 +204,7 @@ try {
204204
exitCode = 1;
205205
throw Error(exitCode);
206206
}
207-
if (exec('npm test').code) {
207+
if (exec('yarn test').code) {
208208
echo('Jest test failure');
209209
exitCode = 1;
210210
throw Error(exitCode);

0 commit comments

Comments
 (0)
Please sign in to comment.