firebaseai.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. name: firebaseai
  2. on:
  3. pull_request:
  4. paths:
  5. - 'FirebaseAI**'
  6. - '.github/workflows/firebaseai.yml'
  7. - 'scripts/quickstart_build_spm.sh'
  8. - 'scripts/quickstart_spm_xcodeproj.sh'
  9. - 'Gemfile*'
  10. # Do not run for documentation-only PRs.
  11. - '!**.md'
  12. schedule:
  13. # Run every day at 11pm (PST) - cron uses UTC times
  14. - cron: '0 7 * * *'
  15. workflow_dispatch:
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  18. cancel-in-progress: true
  19. permissions:
  20. contents: read # Needed for actions/checkout
  21. actions: write # Needed for actions/cache (save and restore)
  22. jobs:
  23. spm-package-resolved:
  24. runs-on: macos-14
  25. outputs:
  26. cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
  27. env:
  28. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  29. steps:
  30. - uses: actions/checkout@v4
  31. - name: Generate Swift Package.resolved
  32. id: swift_package_resolve
  33. run: |
  34. swift package resolve
  35. - name: Generate cache key
  36. id: generate_cache_key
  37. run: |
  38. cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
  39. echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
  40. - uses: actions/cache/save@v4
  41. id: cache
  42. with:
  43. path: .build
  44. key: ${{ steps.generate_cache_key.outputs.cache_key }}
  45. spm-unit:
  46. strategy:
  47. matrix:
  48. include:
  49. - os: macos-14
  50. xcode: Xcode_16.2
  51. target: iOS
  52. - os: macos-15
  53. xcode: Xcode_16.3
  54. target: iOS
  55. - os: macos-15
  56. xcode: Xcode_16.3
  57. target: tvOS
  58. - os: macos-15
  59. xcode: Xcode_16.3
  60. target: macOS
  61. - os: macos-15
  62. xcode: Xcode_16.3
  63. target: watchOS
  64. - os: macos-15
  65. xcode: Xcode_16.3
  66. target: catalyst
  67. - os: macos-15
  68. xcode: Xcode_16.3
  69. target: visionOS
  70. runs-on: ${{ matrix.os }}
  71. needs: spm-package-resolved
  72. env:
  73. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  74. steps:
  75. - uses: actions/checkout@v4
  76. - uses: actions/cache/restore@v4
  77. with:
  78. path: .build
  79. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  80. - name: Clone mock responses
  81. run: scripts/update_vertexai_responses.sh
  82. - name: Xcode
  83. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  84. - name: Install visionOS, if needed.
  85. if: matrix.target == 'visionOS'
  86. run: xcodebuild -downloadPlatform visionOS
  87. - name: Initialize xcodebuild
  88. run: scripts/setup_spm_tests.sh
  89. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
  90. with:
  91. timeout_minutes: 120
  92. max_attempts: 3
  93. retry_on: error
  94. retry_wait_seconds: 120
  95. command: scripts/build.sh FirebaseAIUnit ${{ matrix.target }} spm
  96. testapp-integration:
  97. strategy:
  98. matrix:
  99. target: [iOS]
  100. os: [macos-15]
  101. include:
  102. - os: macos-15
  103. xcode: Xcode_16.3
  104. runs-on: ${{ matrix.os }}
  105. needs: spm-package-resolved
  106. env:
  107. TEST_RUNNER_FIRAAppCheckDebugToken: ${{ secrets.VERTEXAI_INTEGRATION_FAC_DEBUG_TOKEN }}
  108. TEST_RUNNER_VTXIntegrationImagen: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
  109. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  110. secrets_passphrase: ${{ secrets.GHASecretsGPGPassphrase1 }}
  111. steps:
  112. - uses: actions/checkout@v4
  113. - uses: actions/cache/restore@v4
  114. with:
  115. path: .build
  116. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  117. - name: Install Secret GoogleService-Info.plist
  118. run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/VertexAI/TestApp-GoogleService-Info.plist.gpg \
  119. FirebaseAI/Tests/TestApp/Resources/GoogleService-Info.plist "$secrets_passphrase"
  120. - name: Install Secret GoogleService-Info-Spark.plist
  121. run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/VertexAI/TestApp-GoogleService-Info-Spark.plist.gpg \
  122. FirebaseAI/Tests/TestApp/Resources/GoogleService-Info-Spark.plist "$secrets_passphrase"
  123. - name: Install Secret Credentials.swift
  124. run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/VertexAI/TestApp-Credentials.swift.gpg \
  125. FirebaseAI/Tests/TestApp/Tests/Integration/Credentials.swift "$secrets_passphrase"
  126. - name: Xcode
  127. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  128. - name: Run IntegrationTests
  129. run: scripts/build.sh FirebaseAIIntegration ${{ matrix.target }}
  130. - name: Upload xcodebuild logs
  131. if: failure()
  132. uses: actions/upload-artifact@v4
  133. with:
  134. name: xcodebuild-${{ matrix.target }}-${{ matrix.os }}-${{ matrix.xcode }}.log
  135. path: xcodebuild-*.log
  136. retention-days: 2
  137. pod-lib-lint:
  138. # Don't run on private repo unless it is a PR.
  139. if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  140. strategy:
  141. matrix:
  142. include:
  143. - os: macos-14
  144. xcode: Xcode_16.2
  145. swift_version: 5.9
  146. warnings:
  147. - os: macos-15
  148. xcode: Xcode_16.3
  149. swift_version: 5.9
  150. warnings:
  151. - os: macos-15
  152. xcode: Xcode_16.3
  153. swift_version: 6.0
  154. warnings:
  155. runs-on: ${{ matrix.os }}
  156. steps:
  157. - uses: actions/checkout@v4
  158. - name: Clone mock responses
  159. run: scripts/update_vertexai_responses.sh
  160. - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
  161. - name: Setup Bundler
  162. run: scripts/setup_bundler.sh
  163. - name: Xcode
  164. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  165. - name: Set Swift swift_version
  166. run: sed -i "" "s#s.swift_version = '5.9'#s.swift_version = '${{ matrix.swift_version}}'#" FirebaseAI.podspec
  167. - name: Build and test
  168. run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAI.podspec --platforms=${{ matrix.target }} ${{ matrix.warnings }}
  169. quickstart:
  170. # Verifies the quickstart builds with this PR. Only run on pulls where branch is available.
  171. if: github.event_name == 'pull_request'
  172. runs-on: macos-15
  173. env:
  174. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  175. steps:
  176. - uses: actions/checkout@v4
  177. - name: Build Quickstart
  178. run: scripts/quickstart_build_spm.sh FirebaseAI