react-native/scripts/circle-ci-android-setup.sh
Konstantin Raev 83095f95b5 Fixed CI stability: running android tests via emulator not graddle:co…
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
2016-03-11 13:33:26 -08:00

42 lines
999 B
Bash

# inspired by https://github.com/Originate/guide/blob/master/android/guide/Continuous%20Integration.md
function getAndroidSDK {
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
DEPS="$ANDROID_HOME/installed-dependencies"
if [ ! -e $DEPS ]; then
echo no | android create avd -n testAVD -f -t android-19 --abi default/armeabi-v7a &&
touch $DEPS
fi
}
function waitForAVD {
local bootanim=""
export PATH=$(dirname $(dirname $(which android)))/platform-tools:$PATH
until [[ "$bootanim" =~ "stopped" ]]; do
sleep 5
bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
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
}