Skip to content

Commit

Permalink
Switch e2e to yarn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hramos authored and facebook-github-bot committed Feb 6, 2018
1 parent 613afba commit fa11fae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
44 changes: 28 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ aliases:
sudo apt-get install -y nodejs

- &create-ndk-directory
|
name: Create Android NDK Directory
command: |
if [[ ! -e /opt/ndk ]]; then
sudo mkdir /opt/ndk
fi
Expand All @@ -121,16 +122,18 @@ aliases:
# 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
|
name: Configure Environment Variables
command: |
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
|
- &install-android-build-dependencies
name: Install Android Build Dependencies
command: |
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
Expand Down Expand Up @@ -171,7 +174,6 @@ aliases:
- &build-js-bundle
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
when: always

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

- &run-android-instrumentation-tests
name: Run Instrumentation Tests
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
command: |
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
echo "JavaScript bundle missing, cannot run instrumentation tests. Verify build-js-bundle step completed successfully."; exit 1;
fi
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
- &collect-android-test-results
name: Collect Test Results
Expand Down Expand Up @@ -254,6 +260,8 @@ jobs:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
- store_artifacts:
path: ~/react-native/yarn.lock

# Runs JavaScript tests on Node 8
js-node-8:
Expand Down Expand Up @@ -387,7 +395,7 @@ jobs:

# Configure Android dependencies
- run: *configure-android-path
- run: *install-build-dependencies
- run: *install-android-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
Expand Down Expand Up @@ -430,9 +438,9 @@ jobs:
- checkout
- run: *setup-artifacts

# Configure Android dependencies
# Configure Android SDK and related dependencies
- run: *configure-android-path
- run: *install-build-dependencies
- run: *install-android-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
Expand All @@ -442,11 +450,8 @@ jobs:
- run: *launch-avd

# 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

# Fetch dependencies using BUCK
- restore-cache: *restore-cache-buck
- run: *install-buck
- save-cache: *save-cache-buck
Expand All @@ -458,10 +463,17 @@ jobs:
- run: buck fetch ReactAndroid/src/androidTest/...
- run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders

# Install Android NDK
- run: *create-ndk-directory
- restore-cache: *restore-cache-ndk
- run: *install-ndk
- save-cache: *save-cache-ndk

# Build and compile
- run: *build-android-app
- run: *compile-native-libs

# The JavaScript Bundle is required for instrumentation tests.
# Build JavaScript Bundle for instrumentation tests
- run: *install-node
- run: *install-yarn
- restore-cache: *restore-yarn-cache
Expand All @@ -472,7 +484,7 @@ jobs:
# Wait for AVD to finish booting before running tests
- run: *wait-for-avd

# Tests
# Test Suite
- run: *run-android-unit-tests
- run: *run-android-instrumentation-tests

Expand Down Expand Up @@ -568,4 +580,4 @@ workflows:
- hold

- analyze-pull-request:
filters: *filter-ignore-master-stable
filters: *filter-ignore-master-stable
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ node_modules
*.log
.nvm
/bots/node_modules/

# TODO: Check in yarn.lock in open source. Right now we need to keep it out
# from the GitHub repo as importing it might conflict with internal workspaces
*/**/yarn.lock

# OS X
Expand Down
18 changes: 9 additions & 9 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* --android - 'react-native init' and check Android app doesn't redbox
* --js - 'react-native init' and only check the packager returns a bundle
* --skip-cli-install - to skip react-native-cli global installation (for local debugging)
* --retries [num] - how many times to retry possible flaky commands: npm install and running tests, default 1
* --retries [num] - how many times to retry possible flaky commands: yarn add and running tests, default 1
*/
/*eslint-disable no-undef */
require('shelljs/global');
Expand All @@ -44,12 +44,12 @@ let exitCode;
try {
// install CLI
cd('react-native-cli');
exec('npm pack');
exec('yarn pack');
const CLI_PACKAGE = path.join(ROOT, 'react-native-cli', 'react-native-cli-*.tgz');
cd('..');

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

if (exec('npm pack').code) {
if (exec('yarn pack').code) {
echo('Failed to pack react-native');
exitCode = 1;
throw Error(exitCode);
Expand All @@ -76,7 +76,7 @@ try {
if (tryExecNTimes(
() => {
exec('sleep 10s');
return exec(`react-native init EndToEndTest --version ${PACKAGE} --npm`).code;
return exec(`react-native init EndToEndTest --version ${PACKAGE}`).code;
},
numberOfRetries,
() => rm('-rf', 'EndToEndTest'))) {
Expand All @@ -92,7 +92,7 @@ try {
echo('Running an Android e2e test');
echo('Installing e2e framework');
if (tryExecNTimes(
() => 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,
() => 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,
numberOfRetries)) {
echo('Failed to install appium');
echo('Most common reason is npm registry connectivity, try again');
Expand Down Expand Up @@ -125,7 +125,7 @@ try {

echo(`Starting packager server, ${SERVER_PID}`);
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerProcess = spawn('npm', ['start', '--', '--max-workers 1'], {
const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], {
env: process.env
});
SERVER_PID = packagerProcess.pid;
Expand Down Expand Up @@ -158,7 +158,7 @@ try {
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
const packagerProcess = spawn('npm', ['start', '--', '--nonPersistent'],
const packagerProcess = spawn('yarn', ['start', '--nonPersistent'],
{
stdio: 'inherit',
env: packagerEnv
Expand Down Expand Up @@ -204,7 +204,7 @@ try {
exitCode = 1;
throw Error(exitCode);
}
if (exec('npm test').code) {
if (exec('yarn test').code) {
echo('Jest test failure');
exitCode = 1;
throw Error(exitCode);
Expand Down

0 comments on commit fa11fae

Please sign in to comment.