install_prereqs.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. cp Secrets/Storage/App/GoogleService-Info.plist Example/Database/App/GoogleService-Info.plist
  33. cp Secrets/Metrics/database.config Metrics/database.config
  34. # Firebase Installations
  35. fis_resources_dir=FirebaseInstallations/Source/Tests/Resources/
  36. mkdir -p "$fis_resources_dir"
  37. cp Secrets/Installations/GoogleService-Info.plist "$fis_resources_dir"
  38. # FirebaseInstanceID
  39. iid_resources_dir=Example/InstanceID/Resources/
  40. mkdir -p "$iid_resources_dir"
  41. cp Secrets/Installations/GoogleService-Info.plist "$iid_resources_dir"
  42. fi
  43. }
  44. # apt_install program package
  45. #
  46. # Installs the given package if the given command is missing
  47. function apt_install() {
  48. local program="$1"
  49. local package="$2"
  50. which "$program" >& /dev/null || sudo apt-get install "$package"
  51. }
  52. function install_xcpretty() {
  53. gem install xcpretty
  54. if [[ -n "${TRAVIS:-}" ]]; then
  55. gem install xcpretty-travis-formatter
  56. fi
  57. }
  58. secrets_installed=false
  59. # Default values, if not supplied on the command line or environment
  60. platform="iOS"
  61. method="xcodebuild"
  62. if [[ $# -eq 0 ]]; then
  63. # Take arguments from the environment
  64. project=$PROJECT
  65. platform=${PLATFORM:-${platform}}
  66. method=${METHOD:-${method}}
  67. else
  68. project="$1"
  69. if [[ $# -gt 1 ]]; then
  70. platform="$2"
  71. fi
  72. if [[ $# -gt 2 ]]; then
  73. method="$3"
  74. fi
  75. fi
  76. echo "Installing prerequisites for $project for $platform using $method"
  77. if [[ "$method" != "cmake" ]]; then
  78. scripts/setup_bundler.sh
  79. fi
  80. if [[ ! -z "${QUICKSTART:-}" ]]; then
  81. install_secrets
  82. scripts/setup_quickstart.sh "$QUICKSTART"
  83. fi
  84. case "$project-$platform-$method" in
  85. FirebasePod-iOS-*)
  86. install_xcpretty
  87. bundle exec pod install --project-directory=CoreOnly/Tests/FirebasePodTest --repo-update
  88. ;;
  89. Auth-*)
  90. # Install the workspace for integration testing.
  91. install_xcpretty
  92. bundle exec pod install --project-directory=FirebaseAuth/Tests/Sample --repo-update
  93. ;;
  94. Crashlytics-*)
  95. ;;
  96. Database-*)
  97. ;;
  98. Functions-*)
  99. # Start server for Functions integration tests.
  100. ./Functions/Backend/start.sh synchronous
  101. ;;
  102. Storage-*)
  103. ;;
  104. Installations-*)
  105. install_secrets
  106. ;;
  107. # There is purposefully not a dash to include InstanceIDCron.
  108. InstanceID*)
  109. install_secrets
  110. ;;
  111. InAppMessaging-*-xcodebuild)
  112. install_xcpretty
  113. bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
  114. ;;
  115. Firestore-*-xcodebuild | Firestore-*-fuzz)
  116. install_xcpretty
  117. # The Firestore Podfile is multi-platform by default, but this doesn't work
  118. # with command-line builds using xcodebuild. The PLATFORM environment
  119. # variable forces the project to be set for just that single platform.
  120. export PLATFORM="$platform"
  121. bundle exec pod install --project-directory=Firestore/Example --repo-update
  122. ;;
  123. Firestore-iOS-cmake | Firestore-tvOS-cmake | Firestore-macOS-cmake)
  124. brew outdated cmake || brew upgrade cmake
  125. brew outdated go || brew upgrade go # Somehow the build for Abseil requires this.
  126. brew install ccache
  127. brew install ninja
  128. # Install python packages required to generate proto sources
  129. pip install six
  130. ;;
  131. Firestore-Linux-cmake)
  132. apt_install ccache ccache
  133. apt_install cmake cmake
  134. apt_install go golang-go
  135. apt_install ninja ninja-build
  136. # Install python packages required to generate proto sources
  137. pip install six
  138. ;;
  139. SymbolCollision-*-*)
  140. install_xcpretty
  141. bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
  142. ;;
  143. MessagingSample-*)
  144. install_xcpretty
  145. bundle exec pod install --project-directory=FirebaseMessaging/Apps/Sample --repo-update
  146. ;;
  147. GoogleDataTransport-watchOS-xcodebuild)
  148. install_xcpretty
  149. bundle exec pod install --project-directory=GoogleDataTransport/GDTWatchOSTestApp/ --repo-update
  150. ;;
  151. GoogleDataTransportCCTSupport-watchOS-xcodebuild)
  152. install_xcpretty
  153. bundle exec pod install --project-directory=GoogleDataTransportCCTSupport/GDTCCTWatchOSTestApp/ --repo-update
  154. ;;
  155. *-pod-lib-lint)
  156. ;;
  157. *)
  158. echo "Unknown project-platform-method combo" 1>&2
  159. echo " PROJECT=$project" 1>&2
  160. echo " PLATFORM=$platform" 1>&2
  161. echo " METHOD=$method" 1>&2
  162. exit 1
  163. ;;
  164. esac