diff --git a/circle.yml b/circle.yml index 7f95f04a1b7ed9..5eca82328ecbe1 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 2697ed9925e7af..3920cc0c0732aa 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 +} +