From 308612314e19404971474d21a1b85472763cbae8 Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Thu, 24 Dec 2015 10:39:19 -0800 Subject: [PATCH] added emulator support to circle.ci Summary: Closes https://github.com/facebook/react-native/pull/4911 Reviewed By: svcscm Differential Revision: D2789142 Pulled By: androidtrunkagent fb-gh-sync-id: 9fd9520c27fc9acb7b139de6843a71ca3f918249 --- ReactAndroid/build.gradle | 2 +- .../react/testing/ReactAppTestActivity.java | 3 +- circle.yml | 30 +++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index ae79f43cb..1ea9ab37d 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -187,7 +187,7 @@ task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConvers "NDK_LIBS_OUT=$buildDir/react-ndk/all", "THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk", '-C', file('src/main/jni/react/jni').absolutePath, - '--jobs', Runtime.runtime.availableProcessors() + '--jobs', project.hasProperty("jobs") ? project.property("jobs") : Runtime.runtime.availableProcessors() } task cleanReactNdkLib(type: Exec) { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java index 734cdfd2c..d63110551 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java @@ -36,7 +36,8 @@ public class ReactAppTestActivity extends FragmentActivity implements private static final String DEFAULT_BUNDLE_NAME = "AndroidTestBundle.js"; private static final int ROOT_VIEW_ID = 8675309; - private static final long IDLE_TIMEOUT_MS = 15000; + // we need a bigger timeout for CI builds because they run on a slow emulator + private static final long IDLE_TIMEOUT_MS = 60000; private CountDownLatch mLayoutEvent = new CountDownLatch(1); private @Nullable ReactBridgeIdleSignaler mBridgeIdleSignaler; diff --git a/circle.yml b/circle.yml index ff3c01145..3077d7ba9 100644 --- a/circle.yml +++ b/circle.yml @@ -1,16 +1,36 @@ machine: node: version: 5.1.0 + environment: + PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:$PATH" + TERM: "dumb" + ADB_INSTALL_TIMEOUT: "10" + GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"' dependencies: pre: - npm install -g npm@3.2 - + - wget "https://services.gradle.org/distributions/gradle-2.9-bin.zip"; unzip gradle-2.9-bin.zip test: + pre: + # starting emulator in advance because it takes very long to boot + # the side effect is that we loose 1GB of RAM for all the following commands + # if builds are running out of memory move the emulator start right before `wait-for-boot` + - emulator -avd circleci-android22 -no-audio -no-window: + background: true + parallel: true override: - # gradle is flaky in CI envs, found a solution here http://stackoverflow.com/questions/28409608/gradle-assembledebug-and-predexdebug-fail-with-circleci - - TERM=dumb ./gradlew testDebugUnitTest -PpreDexEnable=false -Pcom.android.build.threadPoolSize=1 -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xms512m -Xmx512m" -Dorg.gradle.daemon=false - # build JS bundle + # build ndkreactlib first because it consumes memory and downloads stuff + - ./gradlew :ReactAndroid:buildReactNdkLib -PdisablePreDex -Pjobs=1 + # unit tests + - ./gradlew :ReactAndroid:testDebugUnitTest -PdisablePreDex + # build JS bundle for instrumentation tests - node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/assets/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js # run instrumentation tests on device - - TERM=dumb ./gradlew connectedCheck + - circle-android wait-for-boot + - sleep 5 + # unlock the emulator screen + - adb shell input keyevent 82 + - sleep 5 + # run tests on the emulator + - ./gradlew :ReactAndroid:connectedAndroidTest -PdisablePreDex --stacktrace