install_prereqs.sh 5.7 KB

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