firestore.yml 20 KB

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