firestore.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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@v4
  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@v4
  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. - uses: actions/setup-python@v4
  112. with:
  113. python-version: '3.7'
  114. - name: Setup build
  115. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  116. - name: Build and test
  117. run: |
  118. export EXPERIMENTAL_MODE=true
  119. export CCACHE_DIR=${{ runner.temp }}/ccache
  120. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  121. cmake-prod-db:
  122. # Either a scheduled run from public repo, or a pull request with firestore changes.
  123. if: |
  124. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  125. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  126. needs: check
  127. strategy:
  128. matrix:
  129. os: [macos-12]
  130. databaseId: [(default), test-db]
  131. env:
  132. plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  133. MINT_PATH: ${{ github.workspace }}/mint
  134. TARGET_DATABASE_ID: ${{ matrix.databaseId }}
  135. runs-on: ${{ matrix.os }}
  136. steps:
  137. - uses: actions/checkout@v4
  138. - name: Prepare ccache
  139. uses: actions/cache@v3
  140. with:
  141. path: ${{ runner.temp }}/ccache
  142. key: firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}-${{ github.sha }}
  143. restore-keys: |
  144. firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}-
  145. - name: Cache Mint packages
  146. uses: actions/cache@v3
  147. with:
  148. path: ${{ env.MINT_PATH }}
  149. key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
  150. restore-keys: ${{ runner.os }}-mint-
  151. - uses: actions/setup-python@v4
  152. with:
  153. python-version: '3.7'
  154. - name: Install Secret GoogleService-Info.plist
  155. run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore.plist.gpg \
  156. Firestore/Example/App/GoogleService-Info.plist "$plist_secret"
  157. - name: Install Google Service Account key
  158. run: |
  159. scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore-integration.json.gpg \
  160. google-service-account.json "$plist_secret"
  161. # create composite indexes with Terraform
  162. - name: Set up Google Cloud SDK
  163. uses: google-github-actions/setup-gcloud@v1
  164. - name: Setup Terraform
  165. uses: hashicorp/setup-terraform@v2
  166. - name: Terraform Init
  167. run: |
  168. cd Firestore
  169. terraform init
  170. - name: Terraform Apply
  171. run: |
  172. cd Firestore
  173. # Define a temporary file, redirect both stdout and stderr to it
  174. output_file=$(mktemp)
  175. if ! terraform apply -var-file=../google-service-account.json -auto-approve > "$output_file" 2>&1 ; then
  176. cat "$output_file"
  177. if cat "$output_file" | grep -q "index already exists"; then
  178. echo "==================================================================================="
  179. echo "Terraform apply failed due to index already exists; We can safely ignore this error."
  180. echo "==================================================================================="
  181. fi
  182. exit 1
  183. fi
  184. rm -f "$output_file"
  185. env:
  186. GOOGLE_APPLICATION_CREDENTIALS: ../google-service-account.json
  187. continue-on-error: true
  188. - name: Setup build
  189. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  190. - name: Build and test
  191. run: |
  192. export CCACHE_DIR=${{ runner.temp }}/ccache
  193. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  194. sanitizers-mac:
  195. # Either a scheduled run from public repo, or a pull request with firestore changes.
  196. if: |
  197. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  198. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  199. needs: check
  200. strategy:
  201. matrix:
  202. os: [macos-12]
  203. sanitizer: [asan, tsan]
  204. runs-on: ${{ matrix.os }}
  205. env:
  206. SANITIZERS: ${{ matrix.sanitizer }}
  207. steps:
  208. - uses: actions/checkout@v4
  209. - name: Prepare ccache
  210. uses: actions/cache@v3
  211. with:
  212. path: ${{ runner.temp }}/ccache
  213. key: ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-${{ github.sha }}
  214. restore-keys: |
  215. ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-
  216. - uses: actions/setup-python@v4
  217. with:
  218. python-version: '3.7'
  219. - name: Setup build
  220. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  221. - name: Build and test
  222. run: |
  223. export EXPERIMENTAL_MODE=true
  224. export CCACHE_DIR=${{ runner.temp }}/ccache
  225. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  226. sanitizers-ubuntu:
  227. # Either a scheduled run from public repo, or a pull request with firestore changes.
  228. if: |
  229. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  230. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  231. needs: check
  232. strategy:
  233. matrix:
  234. os: [ubuntu-latest]
  235. # Excluding TSAN on ubuntu because of the warnings it generates around schedule.cc.
  236. # This could be due to Apple Clang provide additional support for synchronization
  237. # on Apple platforms, which is what we primarily care about.
  238. sanitizer: [asan]
  239. runs-on: ${{ matrix.os }}
  240. env:
  241. SANITIZERS: ${{ matrix.sanitizer }}
  242. ASAN_OPTIONS: detect_leaks=0
  243. steps:
  244. - uses: actions/checkout@v3
  245. - name: Prepare ccache
  246. uses: actions/cache@v3
  247. with:
  248. path: ${{ runner.temp }}/ccache
  249. key: ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-${{ github.sha }}
  250. restore-keys: |
  251. ${{ matrix.sanitizer }}-firestore-ccache-${{ runner.os }}-
  252. - uses: actions/setup-python@v4
  253. with:
  254. python-version: '3.7'
  255. - name: Setup build
  256. run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake
  257. - name: Build and test
  258. run: |
  259. export EXPERIMENTAL_MODE=true
  260. export CCACHE_DIR=${{ runner.temp }}/ccache
  261. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake
  262. xcodebuild:
  263. # Either a scheduled run from public repo, or a pull request with firestore changes.
  264. if: |
  265. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  266. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  267. runs-on: macos-12
  268. needs: check
  269. strategy:
  270. matrix:
  271. target: [iOS, tvOS, macOS]
  272. steps:
  273. - uses: actions/checkout@v4
  274. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  275. with:
  276. cache_key: ${{ matrix.target }}
  277. - uses: ruby/setup-ruby@v1
  278. - name: Setup build
  279. run: scripts/install_prereqs.sh Firestore ${{ matrix.target }} xcodebuild
  280. - name: Build and test
  281. run: |
  282. export EXPERIMENTAL_MODE=true
  283. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ matrix.target }} xcodebuild
  284. pod-lib-lint:
  285. # Either a scheduled run from public repo, or a pull request with firestore changes.
  286. if: |
  287. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  288. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  289. runs-on: macos-13
  290. needs: check
  291. strategy:
  292. matrix:
  293. podspec: [
  294. 'FirebaseFirestoreInternal.podspec',
  295. 'FirebaseFirestore.podspec',
  296. 'FirebaseFirestoreSwift.podspec',
  297. ]
  298. steps:
  299. - uses: actions/checkout@v4
  300. - uses: ruby/setup-ruby@v1
  301. - name: Setup Bundler
  302. run: ./scripts/setup_bundler.sh
  303. - name: Xcode
  304. run: sudo xcode-select -s /Applications/Xcode_15.1.app/Contents/Developer
  305. - name: Pod lib lint
  306. # TODO(#9565, b/227461966): Remove --no-analyze when absl is fixed.
  307. run: |
  308. scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} \
  309. --platforms=ios \
  310. --allow-warnings \
  311. --no-analyze
  312. # `pod lib lint` takes a long time so only run the other platforms and static frameworks build in the cron.
  313. pod-lib-lint-cron:
  314. if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  315. needs: check
  316. strategy:
  317. matrix:
  318. podspec: [
  319. 'FirebaseFirestoreInternal.podspec',
  320. 'FirebaseFirestore.podspec',
  321. 'FirebaseFirestoreSwift.podspec',
  322. ]
  323. platforms: [
  324. 'macos',
  325. 'tvos',
  326. 'ios',
  327. ]
  328. flags: [
  329. '--use-static-frameworks',
  330. '',
  331. ]
  332. os: [macos-12, macos-13]
  333. # TODO: grpc and its dependencies don't build on Xcode 15 for macos because their minimum macos is lower than 10.11.
  334. exclude:
  335. - os: macos-13
  336. platforms: 'macos'
  337. # Skip matrix cells covered by pod-lib-lint job.
  338. - os: macos-13
  339. platforms: 'ios'
  340. include:
  341. - os: macos-12
  342. xcode: Xcode_14.2
  343. - os: macos-13
  344. xcode: Xcode_15.1
  345. runs-on: ${{ matrix.os }}
  346. steps:
  347. - uses: actions/checkout@v4
  348. - uses: ruby/setup-ruby@v1
  349. - name: Setup Bundler
  350. run: ./scripts/setup_bundler.sh
  351. - name: Xcode
  352. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  353. - name: Pod lib lint
  354. # TODO(#9565, b/227461966): Remove --no-analyze when absl is fixed.
  355. run: |
  356. scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }}\
  357. ${{ matrix.flags }} \
  358. --platforms=${{ matrix.platforms }} \
  359. --allow-warnings \
  360. --no-analyze
  361. spm-source:
  362. # Either a scheduled run from public repo, or a pull request with firestore changes.
  363. if: |
  364. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  365. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  366. strategy:
  367. matrix:
  368. target: [iOS, tvOS, macOS]
  369. os: [macos-12, macos-13]
  370. include:
  371. - os: macos-12
  372. xcode: Xcode_14.2
  373. - os: macos-13
  374. xcode: Xcode_15.1
  375. runs-on: ${{ matrix.os }}
  376. needs: check
  377. env:
  378. FIREBASE_SOURCE_FIRESTORE: 1
  379. steps:
  380. - uses: actions/checkout@v4
  381. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  382. with:
  383. cache_key: spm${{ matrix.os }}-${{ matrix.xcode }}-${{ matrix.target }}
  384. - name: Xcode
  385. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  386. - name: Initialize xcodebuild
  387. run: scripts/setup_spm_tests.sh
  388. - name: iOS Build Test
  389. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore iOS spmbuildonly
  390. - name: Swift Build
  391. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift iOS spmbuildonly
  392. spm-binary:
  393. # Either a scheduled run from public repo, or a pull request with firestore changes.
  394. if: |
  395. (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
  396. (github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
  397. runs-on: macos-12
  398. needs: check
  399. steps:
  400. - uses: actions/checkout@v4
  401. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  402. with:
  403. cache_key: spm-binary
  404. - name: Initialize xcodebuild
  405. run: scripts/setup_spm_tests.sh
  406. - name: iOS Build Test
  407. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore iOS spmbuildonly
  408. - name: Swift Build
  409. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift iOS spmbuildonly
  410. # TODO: Re-enable either in or after #11706.
  411. # spm-source-cron:
  412. # # Don't run on private repo.
  413. # if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  414. # runs-on: macos-12
  415. # strategy:
  416. # matrix:
  417. # target: [tvOS, macOS, catalyst]
  418. # env:
  419. # FIREBASE_SOURCE_FIRESTORE: 1
  420. # steps:
  421. # - uses: actions/checkout@v4
  422. # - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  423. # with:
  424. # cache_key: ${{ matrix.os }}
  425. # - name: Initialize xcodebuild
  426. # run: scripts/setup_spm_tests.sh
  427. # - name: Build Test - Binary
  428. # run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore ${{ matrix.target }} spmbuildonly
  429. # - name: Swift Build
  430. # run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly
  431. spm-binary-cron:
  432. # Don't run on private repo.
  433. if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
  434. runs-on: macos-12
  435. strategy:
  436. matrix:
  437. target: [tvOS, macOS, catalyst]
  438. steps:
  439. - uses: actions/checkout@v4
  440. - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
  441. with:
  442. cache_key: ${{ matrix.target }}
  443. - name: Initialize xcodebuild
  444. run: scripts/setup_spm_tests.sh
  445. - name: Build Test - Binary
  446. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestore ${{ matrix.target }} spmbuildonly
  447. - name: Swift Build
  448. run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly
  449. # A job that fails if any required job in the test matrix fails,
  450. # to be used as a required check for merging.
  451. check-required-tests:
  452. runs-on: ubuntu-latest
  453. if: always()
  454. name: Check all required Firestore tests results
  455. needs: [cmake, cmake-prod-db, xcodebuild, spm-source, spm-binary]
  456. steps:
  457. - name: Check test matrix
  458. if: needs.cmake.result == 'failure' || needs.cmake-prod-db.result == 'failure' || needs.xcodebuild.result == 'failure' || needs.spm.result == 'failure'
  459. run: exit 1
  460. # Disable until FirebaseUI is updated to accept Firebase 9 and quickstart is updated to accept
  461. # Firebase UI 12
  462. # quickstart:
  463. # # Don't run on private repo unless it is a PR.
  464. # if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  465. # env:
  466. # plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  467. # signin_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  468. # runs-on: macos-12
  469. # needs: check
  470. # steps:
  471. # - uses: actions/checkout@v4
  472. # - name: Setup quickstart
  473. # run: scripts/setup_quickstart.sh firestore
  474. # - name: Install Secret GoogleService-Info.plist
  475. # run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/qs-firestore.plist.gpg \
  476. # quickstart-ios/firestore/GoogleService-Info.plist "$plist_secret"
  477. # - name: Test swift quickstart
  478. # run: ([ -z $plist_secret ] ||
  479. # scripts/third_party/travis/retry.sh scripts/test_quickstart.sh Firestore false)