firestore.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. # Copyright 2020 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. name: firestore
  15. on:
  16. pull_request:
  17. schedule:
  18. # Run every day at 12am (PST) - cron uses UTC times
  19. - cron: '0 8 * * *'
  20. concurrency:
  21. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  22. cancel-in-progress: true
  23. jobs:
  24. changes:
  25. runs-on: macos-12
  26. # Only when this is not a scheduled run
  27. if: github.event_name != 'schedule'
  28. outputs:
  29. changed: ${{ steps.changes.outputs.changed }}
  30. steps:
  31. - uses: dorny/paths-filter@v2
  32. id: changes
  33. with:
  34. filters: |
  35. changed:
  36. # Firestore sources
  37. - 'Firestore/**'
  38. # Interop headers
  39. - 'FirebaseAuth/Interop/*.h'
  40. # FirebaseCore header change
  41. - 'FirebaseCore/Internal'
  42. - 'FirebaseCore/Sources/Public'
  43. # Podspec
  44. - 'FirebaseFirestoreInternal.podspec'
  45. - 'FirebaseFirestore.podspec'
  46. - 'FirebaseFirestoreSwift.podspec'
  47. # CMake
  48. - '**CMakeLists.txt'
  49. - 'cmake/**'
  50. # Build scripts to which Firestore is sensitive
  51. #
  52. # Note that this doesn't include check scripts because changing those will
  53. # already trigger the check workflow.
  54. - 'scripts/binary_to_array.py'
  55. - 'scripts/build.sh'
  56. - 'scripts/install_prereqs.sh'
  57. - 'scripts/localize_podfile.swift'
  58. - 'scripts/pod_lib_lint.rb'
  59. - 'scripts/run_firestore_emulator.sh'
  60. - 'scripts/setup_*'
  61. - 'scripts/sync_project.rb'
  62. - 'scripts/test_quickstart.sh'
  63. - 'scripts/xcresult_logs.py'
  64. # This workflow
  65. - '.github/workflows/firestore.yml'
  66. # Rebuild on Ruby infrastructure changes.
  67. - 'Gemfile*'
  68. check:
  69. needs: changes
  70. # Either a scheduled run from public repo, or a pull request with firestore changes.
  71. if: |
  72. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  73. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  74. runs-on: macos-12
  75. steps:
  76. - uses: actions/checkout@v3
  77. - uses: actions/setup-python@v4
  78. with:
  79. python-version: 3.11
  80. - name: Setup check
  81. run: scripts/setup_check.sh
  82. - name: Run check
  83. run: scripts/check.sh --test-only
  84. cmake:
  85. needs: check
  86. # Either a scheduled run from public repo, or a pull request with firestore changes.
  87. if: |
  88. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  89. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  90. strategy:
  91. matrix:
  92. os: [macos-12, ubuntu-latest]
  93. env:
  94. MINT_PATH: ${{ github.workspace }}/mint
  95. runs-on: ${{ matrix.os }}
  96. steps:
  97. - uses: actions/checkout@v3
  98. - name: Prepare ccache
  99. uses: actions/cache@v3
  100. with:
  101. path: ${{ runner.temp }}/ccache
  102. key: firestore-ccache-${{ runner.os }}-${{ github.sha }}
  103. restore-keys: |
  104. firestore-ccache-${{ runner.os }}-
  105. - name: Cache Mint packages
  106. uses: actions/cache@v3
  107. with:
  108. path: ${{ env.MINT_PATH }}
  109. key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
  110. restore-keys: ${{ runner.os }}-mint-
  111. - name: Setup build
  112. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  113. - name: Build and test
  114. run: |
  115. export EXPERIMENTAL_MODE=true
  116. export CCACHE_DIR=${{ runner.temp }}/ccache
  117. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  118. cmake-prod-db:
  119. # Either a scheduled run from public repo, or a pull request with firestore changes.
  120. if: |
  121. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  122. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  123. needs: check
  124. strategy:
  125. matrix:
  126. os: [macos-12]
  127. databaseId: [(default), test-db]
  128. env:
  129. plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  130. MINT_PATH: ${{ github.workspace }}/mint
  131. TARGET_DATABASE_ID: ${{ matrix.databaseId }}
  132. runs-on: ${{ matrix.os }}
  133. steps:
  134. - uses: actions/checkout@v3
  135. - name: Prepare ccache
  136. uses: actions/cache@v3
  137. with:
  138. path: ${{ runner.temp }}/ccache
  139. key: firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}-${{ github.sha }}
  140. restore-keys: |
  141. firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}-
  142. - name: Cache Mint packages
  143. uses: actions/cache@v3
  144. with:
  145. path: ${{ env.MINT_PATH }}
  146. key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
  147. restore-keys: ${{ runner.os }}-mint-
  148. - name: Install Secret GoogleService-Info.plist
  149. run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore.plist.gpg \
  150. Firestore/Example/App/GoogleService-Info.plist "$plist_secret"
  151. - name: Install Google Service Account key
  152. run: |
  153. scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore-integration.json.gpg \
  154. google-service-account.json "$plist_secret"
  155. # create composite indexes with Terraform
  156. - name: Set up Google Cloud SDK
  157. uses: google-github-actions/setup-gcloud@v1
  158. - name: Setup Terraform
  159. uses: hashicorp/setup-terraform@v2
  160. - name: Terraform Init
  161. run: |
  162. cd Firestore
  163. terraform init
  164. - name: Terraform Apply
  165. run: |
  166. cd Firestore
  167. # Define a temporary file, redirect both stdout and stderr to it
  168. output_file=$(mktemp)
  169. if ! terraform apply -var-file=../google-service-account.json -auto-approve > "$output_file" 2>&1 ; then
  170. cat "$output_file"
  171. if cat "$output_file" | grep -q "index already exists"; then
  172. echo "==================================================================================="
  173. echo "Terraform apply failed due to index already exists; We can safely ignore this error."
  174. echo "==================================================================================="
  175. fi
  176. exit 1
  177. fi
  178. rm -f "$output_file"
  179. env:
  180. GOOGLE_APPLICATION_CREDENTIALS: ../google-service-account.json
  181. continue-on-error: true
  182. - name: Setup build
  183. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  184. - name: Build and test
  185. run: |
  186. export CCACHE_DIR=${{ runner.temp }}/ccache
  187. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  188. sanitizers:
  189. # Either a scheduled run from public repo, or a pull request with firestore changes.
  190. if: |
  191. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  192. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  193. needs: check
  194. strategy:
  195. matrix:
  196. # TODO(b/260248007): Re-enable this once tsan passes on Linux
  197. os: [macos-12]
  198. sanitizer: [asan, tsan]
  199. runs-on: ${{ matrix.os }}
  200. env:
  201. SANITIZERS: ${{ matrix.sanitizer }}
  202. steps:
  203. - uses: actions/checkout@v3
  204. - name: Prepare ccache
  205. uses: actions/cache@v3
  206. with:
  207. path: ${{ runner.temp }}/ccache
  208. key: ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-${{ github.sha }}
  209. restore-keys: |
  210. ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-
  211. - name: Setup build
  212. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  213. - name: Build and test
  214. run: |
  215. export EXPERIMENTAL_MODE=true
  216. export CCACHE_DIR=${{ runner.temp }}/ccache
  217. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  218. xcodebuild:
  219. # Either a scheduled run from public repo, or a pull request with firestore changes.
  220. if: |
  221. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  222. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  223. runs-on: macos-12
  224. needs: check
  225. strategy:
  226. matrix:
  227. target: [iOS, tvOS, macOS]
  228. steps:
  229. - uses: actions/checkout@v3
  230. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  231. with:
  232. cache_key: ${{ matrix.target }}
  233. - uses: ruby/setup-ruby@v1
  234. - name: Setup build
  235. run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild
  236. - name: Build and test
  237. run: |
  238. export EXPERIMENTAL_MODE=true
  239. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ matrix.target }} xcodebuild
  240. pod-lib-lint:
  241. # Either a scheduled run from public repo, or a pull request with firestore changes.
  242. if: |
  243. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  244. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  245. runs-on: macos-13
  246. needs: check
  247. strategy:
  248. matrix:
  249. podspec: [
  250. 'FirebaseFirestoreInternal.podspec',
  251. 'FirebaseFirestore.podspec',
  252. 'FirebaseFirestoreSwift.podspec',
  253. ]
  254. steps:
  255. - uses: actions/checkout@v3
  256. - uses: ruby/setup-ruby@v1
  257. - name: Setup Bundler
  258. run: ./scripts/setup_bundler.sh
  259. - name: Xcode
  260. run: sudo xcode-select -s /Applications/Xcode_15.0.1.app/Contents/Developer
  261. - name: Pod lib lint
  262. # TODO(#9565, b/227461966): Remove --no-analyze when absl is fixed.
  263. run: |
  264. scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} \
  265. --platforms=ios \
  266. --allow-warnings \
  267. --no-analyze
  268. # `pod lib lint` takes a long time so only run the other platforms and static frameworks build in the cron.
  269. pod-lib-lint-cron:
  270. if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  271. needs: check
  272. strategy:
  273. matrix:
  274. podspec: [
  275. 'FirebaseFirestoreInternal.podspec',
  276. 'FirebaseFirestore.podspec',
  277. 'FirebaseFirestoreSwift.podspec',
  278. ]
  279. platforms: [
  280. 'macos',
  281. 'tvos',
  282. 'ios',
  283. ]
  284. flags: [
  285. '--use-static-frameworks',
  286. '',
  287. ]
  288. os: [macos-12, macos-13]
  289. # TODO: grpc and its dependencies don't build on Xcode 15 for macos because their minimum macos is lower than 10.11.
  290. exclude:
  291. - os: macos-13
  292. platforms: 'macos'
  293. # Skip matrix cells covered by pod-lib-lint job.
  294. - os: macos-13
  295. platforms: 'ios'
  296. include:
  297. - os: macos-12
  298. xcode: Xcode_14.2
  299. - os: macos-13
  300. xcode: Xcode_15.0.1
  301. runs-on: ${{ matrix.os }}
  302. steps:
  303. - uses: actions/checkout@v3
  304. - uses: ruby/setup-ruby@v1
  305. - name: Setup Bundler
  306. run: ./scripts/setup_bundler.sh
  307. - name: Xcode
  308. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  309. - name: Pod lib lint
  310. # TODO(#9565, b/227461966): Remove --no-analyze when absl is fixed.
  311. run: |
  312. scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }}\
  313. ${{ matrix.flags }} \
  314. --platforms=${{ matrix.platforms }} \
  315. --allow-warnings \
  316. --no-analyze
  317. spm-source:
  318. # Either a scheduled run from public repo, or a pull request with firestore changes.
  319. if: |
  320. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  321. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  322. strategy:
  323. matrix:
  324. target: [iOS, tvOS, macOS]
  325. os: [macos-12, macos-13]
  326. include:
  327. - os: macos-12
  328. xcode: Xcode_14.2
  329. - os: macos-13
  330. xcode: Xcode_15.0.1
  331. runs-on: ${{ matrix.os }}
  332. needs: check
  333. env:
  334. FIREBASE_SOURCE_FIRESTORE: 1
  335. steps:
  336. - uses: actions/checkout@v3
  337. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  338. with:
  339. cache_key: ${{ matrix.os }}
  340. - name: Xcode
  341. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  342. - name: Initialize xcodebuild
  343. run: scripts/setup_spm_tests.sh
  344. - name: iOS Build Test
  345. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore iOS spmbuildonly
  346. - name: Swift Build
  347. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift iOS spmbuildonly
  348. spm-binary:
  349. # Either a scheduled run from public repo, or a pull request with firestore changes.
  350. if: |
  351. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  352. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  353. runs-on: macos-12
  354. needs: check
  355. steps:
  356. - uses: actions/checkout@v3
  357. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  358. with:
  359. cache_key: ${{ matrix.os }}
  360. - name: Initialize xcodebuild
  361. run: scripts/setup_spm_tests.sh
  362. - name: iOS Build Test
  363. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore iOS spmbuildonly
  364. - name: Swift Build
  365. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift iOS spmbuildonly
  366. # TODO: Re-enable either in or after #11706.
  367. # spm-source-cron:
  368. # # Don't run on private repo.
  369. # if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  370. # runs-on: macos-12
  371. # strategy:
  372. # matrix:
  373. # target: [tvOS, macOS, catalyst]
  374. # env:
  375. # FIREBASE_SOURCE_FIRESTORE: 1
  376. # steps:
  377. # - uses: actions/checkout@v3
  378. # - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  379. # with:
  380. # cache_key: ${{ matrix.os }}
  381. # - name: Initialize xcodebuild
  382. # run: scripts/setup_spm_tests.sh
  383. # - name: Build Test - Binary
  384. # run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore ${{ matrix.target }} spmbuildonly
  385. # - name: Swift Build
  386. # run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly
  387. spm-binary-cron:
  388. # Don't run on private repo.
  389. if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  390. runs-on: macos-12
  391. strategy:
  392. matrix:
  393. target: [tvOS, macOS, catalyst]
  394. steps:
  395. - uses: actions/checkout@v3
  396. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  397. with:
  398. cache_key: ${{ matrix.os }}
  399. - name: Initialize xcodebuild
  400. run: scripts/setup_spm_tests.sh
  401. - name: Build Test - Binary
  402. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore ${{ matrix.target }} spmbuildonly
  403. - name: Swift Build
  404. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly
  405. # A job that fails if any required job in the test matrix fails,
  406. # to be used as a required check for merging.
  407. check-required-tests:
  408. runs-on: ubuntu-latest
  409. if: always()
  410. name: Check all required Firestore tests results
  411. needs: [cmake, cmake-prod-db, xcodebuild, spm-source, spm-binary]
  412. steps:
  413. - name: Check test matrix
  414. if: needs.cmake.result == 'failure' || needs.cmake-prod-db.result == 'failure' || needs.xcodebuild.result == 'failure' || needs.spm.result == 'failure'
  415. run: exit 1
  416. # Disable until FirebaseUI is updated to accept Firebase 9 and quickstart is updated to accept
  417. # Firebase UI 12
  418. # quickstart:
  419. # # Don't run on private repo unless it is a PR.
  420. # if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  421. # env:
  422. # plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  423. # signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  424. # runs-on: macos-12
  425. # needs: check
  426. # steps:
  427. # - uses: actions/checkout@v3
  428. # - name: Setup quickstart
  429. # run: scripts/setup_quickstart.sh firestore
  430. # - name: Install Secret GoogleService-Info.plist
  431. # run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/qs-firestore.plist.gpg \
  432. # quickstart-ios/firestore/GoogleService-Info.plist "$plist_secret"
  433. # - name: Test swift quickstart
  434. # run: ([ -z $plist_secret ] ||
  435. # scripts/third_party/travis/retry.sh scripts/test_quickstart.sh Firestore false)