• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2set -e
3if [ -z $TRAVIS_PULL_REQUEST_SLUG ] && [ "$TRAVIS_REPO_SLUG" != "airbnb/lottie-android" ]; then
4  echo "Skipping gcloud run for PR because api keys are not available from forks."
5  exit 0
6fi
7
8if [ ! -f ${HOME}/google-cloud-sdk/install.sh ]; then
9  mkdir $HOME/.cache
10  echo "File not found!"
11  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
15echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/.cache/gcloud-service-key.json
16gcloud auth activate-service-account --key-file ${HOME}/.cache/gcloud-service-key.json
17gcloud config set project lottie-snapshots
18
19RunTests()
20{
21gcloud 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
22result=$?
23}
24
25./gradlew :LottieSample:assembleDebug :LottieSample:assembleAndroidTest
26RunTests
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
40if [ "$result" -eq "0" ]; then
41  ./post_pr_comment.js
42fi
43exit $result