Skip to content

Commit a1476e8

Browse files
Build SPM quickstart for FirebaseAI (#14818)
Co-authored-by: Andrew Heard <andrewheard@google.com>
1 parent 0ba981f commit a1476e8

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

.github/workflows/firebaseai.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
paths:
66
- 'FirebaseAI**'
77
- '.github/workflows/firebaseai.yml'
8+
- 'scripts/quickstart_build_spm.sh'
9+
- 'scripts/quickstart_spm_xcodeproj.sh'
810
- 'Gemfile*'
911
schedule:
1012
# Run every day at 11pm (PST) - cron uses UTC times
@@ -162,3 +164,14 @@ jobs:
162164
run: sed -i "" "s#s.swift_version = '5.9'#s.swift_version = '${{ matrix.swift_version}}'#" FirebaseAI.podspec
163165
- name: Build and test
164166
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAI.podspec --platforms=${{ matrix.target }} ${{ matrix.warnings }}
167+
168+
quickstart:
169+
# Verifies the quickstart builds with this PR. Only run on pulls where branch is available.
170+
if: github.event_name == 'pull_request'
171+
runs-on: macos-15
172+
env:
173+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
174+
steps:
175+
- uses: actions/checkout@v4
176+
- name: Build Quickstart
177+
run: scripts/quickstart_build_spm.sh FirebaseAI

scripts/quickstart_build_spm.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# Verifies changes to firebase-ios-sdk repo can continue to build the
19+
# product's SPM quickstart.
20+
21+
set -xeuo pipefail
22+
23+
SAMPLE=$1
24+
25+
scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26+
27+
"$scripts_dir/setup_bundler.sh"
28+
29+
gem install xcpretty
30+
31+
git clone https://github.com/firebase/quickstart-ios.git
32+
33+
cd quickstart-ios
34+
35+
source "$scripts_dir/quickstart_spm_xcodeproj.sh" "$SAMPLE"
36+
37+
# Placeholder GoogleService-Info.plist good enough for build only testing.
38+
cp ./mock-GoogleService-Info.plist ./firebaseai/GoogleService-Info.plist
39+
40+
SAMPLE=$1 DIR=$1 SPM="true" TEST="false" ./scripts/test.sh

scripts/quickstart_spm_xcodeproj.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# Modify a .xcodeproj to use a specific branch.
19+
# TODO: Update to transform from a release, as well as from `main`.
20+
21+
set -xeuo pipefail
22+
23+
SAMPLE=$1
24+
XCODEPROJ=${SAMPLE}/${SAMPLE}Example.xcodeproj/project.pbxproj
25+
26+
if grep -q "branch = main;" "$XCODEPROJ"; then
27+
sed -i "" "s#branch = main;#branch = $BRANCH_NAME;#" "$XCODEPROJ"
28+
else
29+
echo "Failed to update quickstart's Xcode project to the current branch"
30+
exit 1
31+
fi

0 commit comments

Comments
 (0)