blob: 9dc684270584661a7c625d5445f4f969bf77a934 [file] [log] [blame]
Gabriel Peal06fdee22018-02-17 18:08:04 -08001#! /bin/bash
Gabriel Peal83c6f1e2018-11-13 08:28:22 -08002set -e
Gabriel Peal6815d7d2018-03-15 18:35:53 -07003if [ -z $TRAVIS_PULL_REQUEST_SLUG ] && [ "$TRAVIS_REPO_SLUG" != "airbnb/lottie-android" ]; then
Gabriel Peal06fdee22018-02-17 18:08:04 -08004 echo "Skipping gcloud run for PR because api keys are not available from forks."
5 exit 0
6fi
7
Gabriel Peal6f2645a2018-07-25 21:36:46 -07008if [ ! -f ${HOME}/google-cloud-sdk/install.sh ]; then
9 mkdir $HOME/.cache
10 echo "File not found!"
Gabriel Peal6f2645a2018-07-25 21:36:46 -070011 curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-209.0.0-linux-x86_64.tar.gz -o gcloud.tar.gz
12 tar xzf gcloud.tar.gz -C ${HOME}
13 ${HOME}/google-cloud-sdk/install.sh --quiet --usage-reporting false
14fi
Gabriel Peal8ce8f8d2018-08-11 13:24:45 -070015echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/.cache/gcloud-service-key.json
Gabriel Peal12de9c52018-07-25 22:09:50 -070016gcloud auth activate-service-account --key-file ${HOME}/.cache/gcloud-service-key.json
Gabriel Peal0babb2c2018-03-10 15:03:04 -080017gcloud config set project lottie-snapshots
18
Gabriel Peal3f9ee242018-07-26 11:22:59 -070019RunTests()
20{
Gabriel Peal947b9542018-03-15 18:35:35 -070021gcloud firebase test android run --no-auto-google-login --type instrumentation --device model=Nexus5X,version=26 --app LottieSample/build/outputs/apk/debug/LottieSample-debug.apk --test LottieSample/build/outputs/apk/androidTest/debug/LottieSample-debug-androidTest.apk
Gabriel Peal6f2645a2018-07-25 21:36:46 -070022result=$?
Gabriel Peal3f9ee242018-07-26 11:22:59 -070023}
24
Gabriel Peal83c6f1e2018-11-13 08:28:22 -080025./gradlew :LottieSample:assembleDebug :LottieSample:assembleAndroidTest
Gabriel Peal3f9ee242018-07-26 11:22:59 -070026RunTests
27
28if [ "$result" -ne "0" ]; then
29 # Retry if it fails. Sometimes the tests fail on Firebase with a native error
30 echo "Firebase tests failed. Trying again."
31 RunTests
32fi
33
34if [ "$result" -ne "0" ]; then
35 # Retry if it fails. Sometimes the tests fail on Firebase with a native error
36 echo "Firebase tests failed. Trying again."
37 RunTests
38fi
39
Gabriel Peal12de9c52018-07-25 22:09:50 -070040if [ "$result" -eq "0" ]; then
41 ./post_pr_comment.js
42fi
Gabriel Peal6f2645a2018-07-25 21:36:46 -070043exit $result