Skip to content

Commit

Permalink
Run xcodebuild in parallel for firestore (#11708)
Browse files Browse the repository at this point in the history
This PR includes a few improvements to Firestore's CI jobs:

- Always trigger Firestore workflow, but change the workflow to skip its jobs if no firestore changes are detected.
- Introduce a new job check-required-tests to the workflow to check if all required jobs are successful or skipped. This should be the required check.
Add parallelization parameters to xcodebuild
- Skip a build step with xcodebuild, and only do test which triggers build anyways. This removes a redundant build run.
  • Loading branch information
wu-hui authored Aug 22, 2023
1 parent 51d9e39 commit 3f9fb1b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 55 deletions.
144 changes: 90 additions & 54 deletions .github/workflows/firestore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,6 @@ name: firestore

on:
pull_request:
paths:
# Firestore sources
- 'Firestore/**'

# Interop headers
- 'FirebaseAuth/Interop/*.h'

# FirebaseCore header change
- 'FirebaseCore/Internal'
- 'FirebaseCore/Sources/Public'

# Podspec
- 'FirebaseFirestore.podspec'

# CMake
- '**CMakeLists.txt'
- 'cmake/**'

# Build scripts to which Firestore is sensitive
#
# Note that this doesn't include check scripts because changing those will
# already trigger the check workflow.
- 'scripts/binary_to_array.py'
- 'scripts/build.sh'
- 'scripts/install_prereqs.sh'
- 'scripts/localize_podfile.swift'
- 'scripts/pod_lib_lint.rb'
- 'scripts/run_firestore_emulator.sh'
- 'scripts/setup_*'
- 'scripts/sync_project.rb'
- 'scripts/test_quickstart.sh'
- 'scripts/xcresult_logs.py'

# This workflow
- '.github/workflows/firestore.yml'

# Rebuild on Ruby infrastructure changes.
- 'Gemfile*'

schedule:
# Run every day at 12am (PST) - cron uses UTC times
- cron: '0 8 * * *'
Expand All @@ -64,9 +25,60 @@ concurrency:
cancel-in-progress: true

jobs:
changes:
runs-on: macos-12
outputs:
changed: ${{ steps.changes.outputs.changed }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
changed:
# Firestore sources
- 'Firestore/**'
# Interop headers
- 'FirebaseAuth/Interop/*.h'
# FirebaseCore header change
- 'FirebaseCore/Internal'
- 'FirebaseCore/Sources/Public'
# Podspec
- 'FirebaseFirestore.podspec'
# CMake
- '**CMakeLists.txt'
- 'cmake/**'
# Build scripts to which Firestore is sensitive
#
# Note that this doesn't include check scripts because changing those will
# already trigger the check workflow.
- 'scripts/binary_to_array.py'
- 'scripts/build.sh'
- 'scripts/install_prereqs.sh'
- 'scripts/localize_podfile.swift'
- 'scripts/pod_lib_lint.rb'
- 'scripts/run_firestore_emulator.sh'
- 'scripts/setup_*'
- 'scripts/sync_project.rb'
- 'scripts/test_quickstart.sh'
- 'scripts/xcresult_logs.py'
# This workflow
- '.github/workflows/firestore.yml'
# Rebuild on Ruby infrastructure changes.
- 'Gemfile*'
check:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
needs: changes
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
runs-on: macos-12
steps:
- uses: actions/checkout@v3
Expand All @@ -83,10 +95,11 @@ jobs:


cmake:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
needs: check

# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
strategy:
matrix:
os: [macos-12, ubuntu-latest]
Expand Down Expand Up @@ -124,8 +137,10 @@ jobs:


cmake-prod-db:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
needs: check

strategy:
Expand Down Expand Up @@ -172,8 +187,10 @@ jobs:


sanitizers:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
needs: check

strategy:
Expand Down Expand Up @@ -209,8 +226,10 @@ jobs:


xcodebuild:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
runs-on: macos-12
needs: check

Expand All @@ -234,8 +253,10 @@ jobs:


pod-lib-lint:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
runs-on: macos-12
needs: check
strategy:
Expand Down Expand Up @@ -297,8 +318,10 @@ jobs:
--no-analyze
spm:
# Don't run on private repo unless it is a PR.
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
# Either a scheduled run from public repo, or a pull request with firestore changes.
if: |
(github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') ||
(github.event_name == 'pull_request' && needs.changes.outputs.changed == 'true')
runs-on: macos-12
needs: check
steps:
Expand Down Expand Up @@ -332,6 +355,19 @@ jobs:
- name: Swift Build
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseFirestoreSwift ${{ matrix.target }} spmbuildonly

# A job that fails if any required job in the test matrix fails,
# to be used as a required check for merging.
check-required-tests:
runs-on: ubuntu-latest
if: always()
name: Check all required Firestore tests results
needs: [cmake, cmake-prod-db, xcodebuild, spm]
steps:
- name: Check test matrix
if: needs.cmake.result == 'failure' || needs.cmake-prod-db.result == 'failure' || needs.xcodebuild.result == 'failure' || needs.spm.result == 'failure'
run: exit 1


# Disable until FirebaseUI is updated to accept Firebase 9 and quickstart is updated to accept
# Firebase UI 12
# quickstart:
Expand Down
1 change: 0 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ case "$product-$platform-$method" in
-scheme "Firestore_IntegrationTests_$platform" \
-enableCodeCoverage YES \
"${xcb_flags[@]}" \
build \
test
;;

Expand Down

0 comments on commit 3f9fb1b

Please sign in to comment.