Skip to content

Commit

Permalink
added emulator support to circle.ci
Browse files Browse the repository at this point in the history
Summary: Closes facebook#4911

Reviewed By: svcscm

Differential Revision: D2789142

Pulled By: androidtrunkagent

fb-gh-sync-id: 9fd9520c27fc9acb7b139de6843a71ca3f918249
  • Loading branch information
bestander authored and facebook-github-bot-7 committed Dec 24, 2015
1 parent c972cce commit 3086123
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 25 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]

- 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

0 comments on commit 3086123

Please sign in to comment.