From 83095f95b512cd96b4c7e1b6df9a1441f1107bfb Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Fri, 11 Mar 2016 13:32:42 -0800 Subject: [PATCH] =?UTF-8?q?Fixed=20CI=20stability:=20running=20android=20t?= =?UTF-8?q?ests=20via=20emulator=20not=20graddle:co=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary:Running CI tests with emulator, not a graddle wrapper. This should make things faster Closes https://github.com/facebook/react-native/pull/6421 Differential Revision: D3042505 fb-gh-sync-id: 455264f90044c22ed3ec8cf9cb6d5edc2efedcdb shipit-source-id: 455264f90044c22ed3ec8cf9cb6d5edc2efedcdb --- circle.yml | 10 +++++----- scripts/circle-ci-android-setup.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/circle.yml b/circle.yml index 7f95f04a1b..5eca82328e 100644 --- a/circle.yml +++ b/circle.yml @@ -52,19 +52,19 @@ test: # instrumentation tests # compile native libs with Gradle script - - ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -PdisablePreDex -Pjobs=1: + - ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1: timeout: 360 # 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 # build test APK - buck/bin/buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1 # run installed apk with tests - - ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests + - source scripts/circle-ci-android-setup.sh && retry3 ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests # Deprecated: run tests with Gradle, we keep them for a while to compare performance - - ./gradlew :ReactAndroid:testDebugUnitTest -PdisablePreDex - - ./gradlew :ReactAndroid:connectedAndroidTest -PdisablePreDex --stacktrace --info: - timeout: 360 + - ./gradlew :ReactAndroid:testDebugUnitTest + - ./gradlew :ReactAndroid:installDebugAndroidTest + - source scripts/circle-ci-android-setup.sh && retry3 ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests.gradle # Publish to Sinopia, create a new app using 'react-native init' and check the packager starts - ./scripts/e2e-test.sh --packager diff --git a/scripts/circle-ci-android-setup.sh b/scripts/circle-ci-android-setup.sh index 2697ed9925..3920cc0c07 100644 --- a/scripts/circle-ci-android-setup.sh +++ b/scripts/circle-ci-android-setup.sh @@ -20,3 +20,22 @@ function waitForAVD { echo "emulator status=$bootanim" done } + +function retry3 { + local n=1 + local max=3 + local delay=1 + while true; do + "$@" && break || { + if [[ $n -lt $max ]]; then + ((n++)) + echo "Command failed. Attempt $n/$max:" + sleep $delay; + else + echo "The command has failed after $n attempts." >&2 + return 1 + fi + } + done +} +