install_prereqs.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #!/usr/bin/env bash
  2. # Copyright 2018 Google LLC
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Within Travis, installs prerequisites for a build.
  16. # Examines the following configured environment variables that should be
  17. # specified in an env: block
  18. # - PROJECT - Firebase or Firestore
  19. # - METHOD - xcodebuild or cmake; default is xcodebuild
  20. set -euo pipefail
  21. # Set up secrets for integration tests and metrics collection. This does not work for pull
  22. # requests from forks. See
  23. # https://docs.travis-ci.com/user/pull-requests#pull-requests-and-security-restrictions
  24. function install_secrets() {
  25. if [[ -n "${encrypted_de2056405dcb_key:-}" && $secrets_installed != true ]]; then
  26. secrets_installed=true
  27. openssl aes-256-cbc -K $encrypted_de2056405dcb_key -iv $encrypted_de2056405dcb_iv \
  28. -in scripts/travis-encrypted/Secrets.tar.enc \
  29. -out scripts/travis-encrypted/Secrets.tar -d
  30. tar xvf scripts/travis-encrypted/Secrets.tar
  31. cp Secrets/Storage/App/GoogleService-Info.plist FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist
  32. # Firebase Installations
  33. fis_resources_dir=FirebaseInstallations/Source/Tests/Resources/
  34. mkdir -p "$fis_resources_dir"
  35. cp Secrets/Installations/GoogleService-Info.plist "$fis_resources_dir"
  36. # FirebaseInstanceID
  37. iid_resources_dir=Example/InstanceID/Resources/
  38. mkdir -p "$iid_resources_dir"
  39. cp Secrets/Installations/GoogleService-Info.plist "$iid_resources_dir"
  40. fi
  41. }
  42. # apt_install program package
  43. #
  44. # Installs the given package if the given command is missing
  45. function apt_install() {
  46. local program="$1"
  47. local package="$2"
  48. which "$program" >& /dev/null || sudo apt-get install "$package"
  49. }
  50. function install_xcpretty() {
  51. gem install xcpretty
  52. if [[ -n "${TRAVIS:-}" ]]; then
  53. gem install xcpretty-travis-formatter
  54. fi
  55. }
  56. secrets_installed=false
  57. # Default values, if not supplied on the command line or environment
  58. platform="iOS"
  59. method="xcodebuild"
  60. if [[ $# -eq 0 ]]; then
  61. # Take arguments from the environment
  62. project=$PROJECT
  63. platform=${PLATFORM:-${platform}}
  64. method=${METHOD:-${method}}
  65. else
  66. project="$1"
  67. if [[ $# -gt 1 ]]; then
  68. platform="$2"
  69. fi
  70. if [[ $# -gt 2 ]]; then
  71. method="$3"
  72. fi
  73. fi
  74. echo "Installing prerequisites for $project for $platform using $method"
  75. if [[ "$method" != "cmake" ]]; then
  76. scripts/setup_bundler.sh
  77. fi
  78. if [[ ! -z "${QUICKSTART:-}" ]]; then
  79. install_secrets
  80. scripts/setup_quickstart.sh "$QUICKSTART"
  81. fi
  82. case "$project-$platform-$method" in
  83. FirebasePod-iOS-*)
  84. install_xcpretty
  85. bundle exec pod install --project-directory=CoreOnly/Tests/FirebasePodTest --repo-update
  86. ;;
  87. Auth-*)
  88. # Install the workspace for integration testing.
  89. install_xcpretty
  90. bundle exec pod install --project-directory=FirebaseAuth/Tests/Sample --repo-update
  91. ;;
  92. Crashlytics-*)
  93. ;;
  94. Database-*)
  95. ;;
  96. Functions-*)
  97. # Start server for Functions integration tests.
  98. ./Functions/Backend/start.sh synchronous
  99. ;;
  100. Storage-*)
  101. ;;
  102. Installations-*)
  103. install_secrets
  104. ;;
  105. # There is purposefully not a dash to include InstanceIDCron.
  106. InstanceID*)
  107. install_secrets
  108. ;;
  109. InAppMessaging-*-xcodebuild)
  110. install_xcpretty
  111. bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
  112. ;;
  113. Firestore-*-xcodebuild | Firestore-*-fuzz)
  114. install_xcpretty
  115. # The Firestore Podfile is multi-platform by default, but this doesn't work
  116. # with command-line builds using xcodebuild. The PLATFORM environment
  117. # variable forces the project to be set for just that single platform.
  118. export PLATFORM="$platform"
  119. bundle exec pod install --project-directory=Firestore/Example --repo-update
  120. ;;
  121. Firestore-iOS-cmake | Firestore-tvOS-cmake | Firestore-macOS-cmake)
  122. brew outdated cmake || brew upgrade cmake
  123. brew outdated go || brew upgrade go # Somehow the build for Abseil requires this.
  124. brew install ccache
  125. brew install ninja
  126. # Install python packages required to generate proto sources
  127. pip install six
  128. ;;
  129. Firestore-Linux-cmake)
  130. apt_install ccache ccache
  131. apt_install cmake cmake
  132. apt_install go golang-go
  133. apt_install ninja ninja-build
  134. # Install python packages required to generate proto sources
  135. pip install six
  136. ;;
  137. SymbolCollision-*-*)
  138. install_xcpretty
  139. bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
  140. ;;
  141. MessagingSample-*)
  142. install_xcpretty
  143. bundle exec pod install --project-directory=FirebaseMessaging/Apps/Sample --repo-update
  144. ;;
  145. GoogleDataTransport-watchOS-xcodebuild)
  146. install_xcpretty
  147. bundle exec pod install --project-directory=GoogleDataTransport/GDTWatchOSTestApp/ --repo-update
  148. ;;
  149. GoogleDataTransportCCTSupport-watchOS-xcodebuild)
  150. install_xcpretty
  151. bundle exec pod install --project-directory=GoogleDataTransportCCTSupport/GDTCCTWatchOSTestApp/ --repo-update
  152. ;;
  153. *-pod-lib-lint)
  154. ;;
  155. *)
  156. echo "Unknown project-platform-method combo" 1>&2
  157. echo " PROJECT=$project" 1>&2
  158. echo " PLATFORM=$platform" 1>&2
  159. echo " METHOD=$method" 1>&2
  160. exit 1
  161. ;;
  162. esac