Skip to content

Commit f9b54b5

Browse files
authored
[Firebase AI] Run quickstart build test using branch (#14879)
1 parent c87b6c0 commit f9b54b5

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

.github/workflows/firebaseai.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ jobs:
175175
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAI.podspec --platforms=${{ matrix.target }} ${{ matrix.warnings }}
176176

177177
quickstart:
178-
# Verifies the quickstart builds with this PR. Only run on pulls where branch is available.
179-
if: github.event_name == 'pull_request'
180178
runs-on: macos-15
181179
env:
182-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
180+
BRANCH_NAME: ${{ github.head_ref || github.ref_name || 'main' }}
183181
steps:
184182
- uses: actions/checkout@v4
185183
- name: Build Quickstart

scripts/quickstart_spm_xcodeproj.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,45 @@
1616

1717

1818
# Modify a .xcodeproj to use a specific branch.
19-
# TODO: Update to transform from a release, as well as from `main`.
2019

2120
set -xeuo pipefail
2221

2322
SAMPLE=$1
24-
XCODEPROJ=${SAMPLE}/${SAMPLE}Example.xcodeproj/project.pbxproj
23+
SAMPLE_DIR=$(echo "$SAMPLE" | perl -ne 'print lc')
24+
XCODEPROJ=${SAMPLE_DIR}/${SAMPLE}Example.xcodeproj/project.pbxproj
2525

26-
if grep -q "branch = main;" "$XCODEPROJ"; then
27-
sed -i "" "s#branch = main;#branch = $BRANCH_NAME;#" "$XCODEPROJ"
26+
# Regex matches SemVer `firebase-ios-sdk` dependency in project.pbxproj:
27+
# {
28+
# isa = XCRemoteSwiftPackageReference;
29+
# repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
30+
# requirement = {
31+
# kind = upToNextMajorVersion;
32+
# minimumVersion = xx.yy.zz;
33+
# };
34+
# };
35+
REQUIREMENT_REGEX='({'\
36+
'\s*isa = XCRemoteSwiftPackageReference;'\
37+
'\s*repositoryURL = "https://github\.com/firebase/firebase-ios-sdk\.git";'\
38+
'\s*requirement = {\s*)kind = upToNextMajorVersion;'\
39+
'\s*minimumVersion = \d+\.\d+\.\d+;'\
40+
'(\s*};'\
41+
'\s*};)'
2842

29-
# Point SPM CI to the tip of `main` of
30-
# https://github.com/google/GoogleAppMeasurement so that the release process
31-
# can defer publishing the `GoogleAppMeasurement` tag until after testing.
32-
export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1
33-
else
34-
echo "Failed to update quickstart's Xcode project to the current branch"
43+
# Replaces the minimumVersion requirement with a branch requirement.
44+
REPLACEMENT_REGEX="\1branch = $BRANCH_NAME;\n\t\t\t\tkind = branch;\2"
45+
46+
# Performs the replacement using Perl.
47+
#
48+
# -0777 Enables reading all input in one go (slurp), rather than line-by-line.
49+
# -p Causes Perl to loop through the input line by line.
50+
# -i Edits the file in place.
51+
# -e Provides the expression to execute.
52+
perl -0777 -i -pe "s#$REQUIREMENT_REGEX#$REPLACEMENT_REGEX#g" "$XCODEPROJ" || {
53+
echo "Failed to update quickstart's Xcode project to the branch: $BRANCH_NAME"
3554
exit 1
36-
fi
55+
}
56+
57+
# Point SPM CI to the tip of `main` of
58+
# https://github.com/google/GoogleAppMeasurement so that the release process
59+
# can defer publishing the `GoogleAppMeasurement` tag until after testing.
60+
export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1

0 commit comments

Comments
 (0)