Gabriel Peal | 06fdee2 | 2018-02-17 18:08:04 -0800 | [diff] [blame] | 1 | #! /bin/bash |
Gabriel Peal | 83c6f1e | 2018-11-13 08:28:22 -0800 | [diff] [blame] | 2 | set -e |
Gabriel Peal | 6815d7d | 2018-03-15 18:35:53 -0700 | [diff] [blame] | 3 | if [ -z $TRAVIS_PULL_REQUEST_SLUG ] && [ "$TRAVIS_REPO_SLUG" != "airbnb/lottie-android" ]; then |
Gabriel Peal | 06fdee2 | 2018-02-17 18:08:04 -0800 | [diff] [blame] | 4 | echo "Skipping gcloud run for PR because api keys are not available from forks." |
| 5 | exit 0 |
| 6 | fi |
| 7 | |
Gabriel Peal | 6f2645a | 2018-07-25 21:36:46 -0700 | [diff] [blame] | 8 | if [ ! -f ${HOME}/google-cloud-sdk/install.sh ]; then |
| 9 | mkdir $HOME/.cache |
| 10 | echo "File not found!" |
Gabriel Peal | 6f2645a | 2018-07-25 21:36:46 -0700 | [diff] [blame] | 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 |
| 14 | fi |
Gabriel Peal | 8ce8f8d | 2018-08-11 13:24:45 -0700 | [diff] [blame] | 15 | echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/.cache/gcloud-service-key.json |
Gabriel Peal | 12de9c5 | 2018-07-25 22:09:50 -0700 | [diff] [blame] | 16 | gcloud auth activate-service-account --key-file ${HOME}/.cache/gcloud-service-key.json |
Gabriel Peal | 0babb2c | 2018-03-10 15:03:04 -0800 | [diff] [blame] | 17 | gcloud config set project lottie-snapshots |
| 18 | |
Gabriel Peal | 3f9ee24 | 2018-07-26 11:22:59 -0700 | [diff] [blame] | 19 | RunTests() |
| 20 | { |
Gabriel Peal | 947b954 | 2018-03-15 18:35:35 -0700 | [diff] [blame] | 21 | gcloud 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 Peal | 6f2645a | 2018-07-25 21:36:46 -0700 | [diff] [blame] | 22 | result=$? |
Gabriel Peal | 3f9ee24 | 2018-07-26 11:22:59 -0700 | [diff] [blame] | 23 | } |
| 24 | |
Gabriel Peal | 83c6f1e | 2018-11-13 08:28:22 -0800 | [diff] [blame] | 25 | ./gradlew :LottieSample:assembleDebug :LottieSample:assembleAndroidTest |
Gabriel Peal | 3f9ee24 | 2018-07-26 11:22:59 -0700 | [diff] [blame] | 26 | RunTests |
| 27 | |
| 28 | if [ "$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 |
| 32 | fi |
| 33 | |
| 34 | if [ "$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 |
| 38 | fi |
| 39 | |
Gabriel Peal | 12de9c5 | 2018-07-25 22:09:50 -0700 | [diff] [blame] | 40 | if [ "$result" -eq "0" ]; then |
| 41 | ./post_pr_comment.js |
| 42 | fi |
Gabriel Peal | 6f2645a | 2018-07-25 21:36:46 -0700 | [diff] [blame] | 43 | exit $result |