Skip to content

[Firebase AI] Run quickstart build test using branch #14879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/firebaseai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ jobs:
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 }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name || 'main' }}
steps:
- uses: actions/checkout@v4
- name: Build Quickstart
Expand Down
46 changes: 35 additions & 11 deletions scripts/quickstart_spm_xcodeproj.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,45 @@


# 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
SAMPLE_DIR=$(echo "$SAMPLE" | perl -ne 'print lc')
XCODEPROJ=${SAMPLE_DIR}/${SAMPLE}Example.xcodeproj/project.pbxproj

if grep -q "branch = main;" "$XCODEPROJ"; then
sed -i "" "s#branch = main;#branch = $BRANCH_NAME;#" "$XCODEPROJ"
# Regex matches SemVer `firebase-ios-sdk` dependency in project.pbxproj:
# {
# isa = XCRemoteSwiftPackageReference;
# repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
# requirement = {
# kind = upToNextMajorVersion;
# minimumVersion = xx.yy.zz;
# };
# };
REQUIREMENT_REGEX='({'\
'\s*isa = XCRemoteSwiftPackageReference;'\
'\s*repositoryURL = "https://github\.com/firebase/firebase-ios-sdk\.git";'\
'\s*requirement = {\s*)kind = upToNextMajorVersion;'\
'\s*minimumVersion = \d+\.\d+\.\d+;'\
'(\s*};'\
'\s*};)'

# Point SPM CI to the tip of `main` of
# https://github.com/google/GoogleAppMeasurement so that the release process
# can defer publishing the `GoogleAppMeasurement` tag until after testing.
export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1
else
echo "Failed to update quickstart's Xcode project to the current branch"
# Replaces the minimumVersion requirement with a branch requirement.
REPLACEMENT_REGEX="\1branch = $BRANCH_NAME;\n\t\t\t\tkind = branch;\2"

# Performs the replacement using Perl.
#
# -0777 Enables reading all input in one go (slurp), rather than line-by-line.
# -p Causes Perl to loop through the input line by line.
# -i Edits the file in place.
# -e Provides the expression to execute.
perl -0777 -i -pe "s#$REQUIREMENT_REGEX#$REPLACEMENT_REGEX#g" "$XCODEPROJ" || {
echo "Failed to update quickstart's Xcode project to the branch: $BRANCH_NAME"
exit 1
fi
}

# Point SPM CI to the tip of `main` of
# https://github.com/google/GoogleAppMeasurement so that the release process
# can defer publishing the `GoogleAppMeasurement` tag until after testing.
export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1
Loading