Procházet zdrojové kódy

Build SPM quickstart for FirebaseAI (#14818)

Co-authored-by: Andrew Heard <andrewheard@google.com>
Paul Beusterien před 11 měsíci
rodič
revize
a1476e8f69

+ 13 - 0
.github/workflows/firebaseai.yml

@@ -5,6 +5,8 @@ on:
     paths:
     - 'FirebaseAI**'
     - '.github/workflows/firebaseai.yml'
+    - 'scripts/quickstart_build_spm.sh'
+    - 'scripts/quickstart_spm_xcodeproj.sh'
     - 'Gemfile*'
   schedule:
     # Run every day at 11pm (PST) - cron uses UTC times
@@ -162,3 +164,14 @@ jobs:
       run: sed -i "" "s#s.swift_version = '5.9'#s.swift_version = '${{ matrix.swift_version}}'#" FirebaseAI.podspec
     - name: Build and test
       run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAI.podspec --platforms=${{ matrix.target }} ${{ matrix.warnings }}
+
+  quickstart:
+    # Verifies the quickstart builds with this PR. Only run on pulls where branch is available.
+    if: github.event_name == 'pull_request'
+    runs-on: macos-15
+    env:
+      BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+    steps:
+    - uses: actions/checkout@v4
+    - name: Build Quickstart
+      run: scripts/quickstart_build_spm.sh FirebaseAI

+ 40 - 0
scripts/quickstart_build_spm.sh

@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Verifies changes to firebase-ios-sdk repo can continue to build the
+# product's SPM quickstart.
+
+set -xeuo pipefail
+
+SAMPLE=$1
+
+scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+"$scripts_dir/setup_bundler.sh"
+
+gem install xcpretty
+
+git clone https://github.com/firebase/quickstart-ios.git
+
+cd quickstart-ios
+
+source "$scripts_dir/quickstart_spm_xcodeproj.sh" "$SAMPLE"
+
+# Placeholder GoogleService-Info.plist good enough for build only testing.
+cp ./mock-GoogleService-Info.plist ./firebaseai/GoogleService-Info.plist
+
+SAMPLE=$1 DIR=$1 SPM="true" TEST="false" ./scripts/test.sh

+ 31 - 0
scripts/quickstart_spm_xcodeproj.sh

@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Modify a .xcodeproj to use a specific branch.
+# TODO: Update to transform from a release, as well as from `main`.
+
+set -xeuo pipefail
+
+SAMPLE=$1
+XCODEPROJ=${SAMPLE}/${SAMPLE}Example.xcodeproj/project.pbxproj
+
+if grep -q "branch = main;" "$XCODEPROJ"; then
+  sed -i "" "s#branch = main;#branch = $BRANCH_NAME;#" "$XCODEPROJ"
+else
+  echo "Failed to update quickstart's Xcode project to the current branch"
+  exit 1
+fi