Skip to content

Conversation

@gdeluna-branch
Copy link
Contributor

Reference

SDK-XXXX -- <TITLE>.

Summary

Motivation

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing Instructions

cc @BranchMetrics/saas-sdk-devs for visibility.

@gdeluna-branch gdeluna-branch marked this pull request as draft June 16, 2025 22:58
@matter-code-review
Copy link
Contributor

matter-code-review bot commented Jun 16, 2025

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

The GitHub Actions workflow .github/workflows/gptdriverautomation.yml has been significantly expanded. The previous static-analysis job has been replaced with a comprehensive BuildAndTestAppOnGPTDriver job. This new workflow now automates the process of extracting version information from the branch name, checking out both the iOS Branch SDK and a specific BranchLinkSimulator app repository, building the SDK framework, integrating it into the app, building the app with the local SDK, uploading the resulting .app bundle as an artifact, and finally, executing tests on an external GPTDriver service. 🚀

🔍 Impact of the Change

This change transforms the workflow from a simple static analysis check into a full-fledged CI/CD pipeline for validating iOS SDK changes against a specific application. It ensures that SDK modifications are compatible with the app and are tested automatically, streamlining the development and release process. The workflow's complexity and execution time will increase due to the multiple build and integration steps. ⚡

📁 Total Files Changed

  • .github/workflows/gptdriverautomation.yml: Major refactoring, replacing static analysis with a comprehensive build, integration, and test pipeline.

🧪 Test Added

This PR introduces an automated testing step (Run GPTDriver tests) which executes a script (gptdriverrunscript.sh) with the built iOS application bundle on an external GPTDriver service. This is a form of integration or end-to-end testing, ensuring the built SDK and app function correctly together. 🕵️

🔒Security Vulnerabilities

No new security vulnerabilities are directly introduced by this workflow. The use of GitHub secrets for API keys (secrets.MOBILEBOOST_API_ORG_KEY) is a standard and secure practice. The overall security posture depends on the gptdriverrunscript.sh and the external GPTDriver service's security. 🛡️

Tip

Quality Recommendations

  1. Consider adding error handling (e.g., set -e or explicit exit code checks) for xcodebuild commands to ensure the workflow fails gracefully on build errors.

  2. Review the VERSION_CODE_INT calculation (MAJOR * 10000 + MINOR * 100 + PATCH) to ensure it robustly handles potential version numbers where minor or patch components might exceed 99, which could lead to incorrect version codes.

  3. Evaluate if the BranchLinkSimulator app's branch (gptdriver/linkingTests) should be dynamic or configurable, rather than hardcoded, to allow for more flexible testing scenarios against different app versions.

Tanka Poem ♫

New pipeline flows,
SDK and app now unite,
Tests run, swift and true.
GPTDriver's eye watches,
Code's journey, now complete. ✨

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant SDK_Repo as iOS SDK Repository
    participant App_Repo as iOS App Repository
    participant GPTDriver as GPTDriver Service

    GH->>GH: Trigger workflow_dispatch
    Note over GH: Extract version from branch name (e.g., Release-X.Y.Z)
    GH->>SDK_Repo: Checkout BranchMetrics/ios-branch-deep-linking-attribution (ref: ${{ github.ref }})
    GH->>GH: Build Branch SDK Framework (xcodebuild build)
    GH->>App_Repo: Checkout BranchMetrics/BranchLinkSimulator (ref: gptdriver/linkingTests)
    GH->>GH: Copy BranchSDK.framework to ./ios-app-repo/Frameworks
    GH->>GH: Build iOS App with local SDK (xcodebuild build, passing MARKETING_VERSION, CURRENT_PROJECT_VERSION)
    GH->>GH: Echo .app bundle location
    GH->>GH: Upload BranchLinkSimulator.app as artifact
    GH->>GPTDriver: Execute gptdriverrunscript.sh (app_path, platform, env: API_ORG_KEY, API_KEY, TEST_TAGS)
    GPTDriver-->>GH: Test results/status
Loading

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Note

PR Review Skipped

PR review skipped as no relevant changes found due to large diff hunk OR part of a non-reviewable file.

📄Files skipped in review
  • undefined: undefined
💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Comment on lines +7 to +122
runs-on: macos-latest # macOS runner is required for iOS builds
steps:
# --- Step 1: Extract version from branch name ---
- name: Extract version from branch name
id: extract_version_step
run: |
BRANCH_NAME="${{ github.ref }}"
# Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0)
BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}"
# Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0)
VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p')

if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z"
exit 1
fi

echo "Extracted versionName: $VERSION"
echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV

# Convert semantic version to an integer for CFBundleVersion (versionCode equivalent)
# Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch)
# This should be adjusted based on the maximum expected values for major/minor/patch
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)

# Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer
# Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch
# This provides sufficient uniqueness for most common versioning schemes.
VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH ))
echo "Calculated versionCode: $VERSION_CODE_INT"
echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV


# --- Step 2: Checkout the iOS Branch SDK repository ---
- name: Checkout BranchMetrics/ios-branch-deep-linking-attribution (SDK)
uses: actions/checkout@v4
with:
repository: BranchMetrics/ios-branch-deep-linking-attribution
ref: ${{ github.ref }} # Use the same branch that triggered the workflow
path: ./branch-ios-sdk-repo # Checkout into a subdirectory

# --- Step 3: Build the iOS Branch SDK Framework ---
- name: Build Branch SDK Framework
run: |
# Build for simulator. Adjust scheme if necessary.
# The output framework will be in build/Debug-iphonesimulator/BranchSDK.framework
xcodebuild build -project Branch-SDK/Branch-SDK.xcodeproj \
-scheme BranchSDK \
-configuration Debug \
-sdk iphonesimulator \
BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" \
SKIP_INSTALL=NO
working-directory: ./branch-ios-sdk-repo # Run xcodebuild from the SDK's checkout directory

# --- Step 4: Checkout the iOS Branch Link Simulator App repository ---
- name: Checkout BranchMetrics/BranchLinkSimulator (App)
uses: actions/checkout@v4
with:
repository: BranchMetrics/BranchLinkSimulator
ref: gptdriver/linkingTests # Checkout the specific app branch
path: ./ios-app-repo # Checkout into another subdirectory

# --- Step 5: Copy the generated SDK Framework to the App's project ---
- name: Copy generated SDK Framework to App's libs directory
run: |
# Create a 'Frameworks' directory within the app repo for the local SDK
mkdir -p ./ios-app-repo/Frameworks
# Copy the built framework
cp -R ./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework ./ios-app-repo/Frameworks/
working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE

# --- Step 6: Build the iOS Branch Link Simulator App using the local SDK Framework ---
- name: Build iOS App with local SDK
run: |
# Build the app. Adjust project/workspace, scheme, and destination if necessary.
# We're passing MARKETING_VERSION (versionName) and CURRENT_PROJECT_VERSION (versionCode)
xcodebuild build -project BranchLinkSimulator.xcodeproj \
-scheme BranchLinkSimulator \
-configuration Debug \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15' \
MARKETING_VERSION=${{ env.VERSION_STRING }} \
CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT }} \
# Adjust Framework Search Paths if your Xcode project doesn't automatically find it
# For example, if you need to point directly to the copied framework:
# FRAMEWORK_SEARCH_PATHS="$(SRCROOT)/Frameworks"
working-directory: ./ios-app-repo # Run xcodebuild from the App's checkout directory

# --- Step 7: Echo the location of the generated .app bundle ---
- name: Echo .app bundle location
run: |
APP_PATH="./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app"
echo "Generated .app bundle location: $APP_PATH"
# You can also use 'find' to be more dynamic if the name might change
# find ./ios-app-repo/build -name "*.app"

# --- Step 8: Upload Build Artifacts ---
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: BranchLinkSimulator-iOS-Debug-Build
path: ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app

# --- Step 9: Upload and run tests on GPTDriver service. ---
- name: Run GPTDriver tests
run: |
# Ensure the script is executable
chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh
# Execute the script, passing the .app path and platform
bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app ios
env:
API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} # As per vendor design
TEST_TAGS: Release

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To address the issue, we should explicitly declare the workflow/job-level permissions for the minimum needed by the workflow. The least privilege necessary for such build and artifact upload workflows usually is contents: read, as the workflow does not appear to require write access to repository contents, nor permissions to issues, pull requests, or any other scopes. If uploading artifacts (using actions/upload-artifact) or using secrets, these do not require additional permissions on GITHUB_TOKEN in most cases, unless the artifact is being published as a release asset or similar (which is not shown here). The best way is to add a top-level permissions: section (above jobs:), setting contents: read. This will apply to all jobs unless overridden.

Required change:

  • Add a permissions: block as the top-level key in .github/workflows/gptdriverautomation.yml, above jobs:.
  • Use contents: read.
    No code logic, steps, or functionality needs to change.

Suggested changeset 1
.github/workflows/gptdriverautomation.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/gptdriverautomation.yml b/.github/workflows/gptdriverautomation.yml
--- a/.github/workflows/gptdriverautomation.yml
+++ b/.github/workflows/gptdriverautomation.yml
@@ -2,6 +2,8 @@
 on:
   workflow_dispatch: {}
 
+permissions:
+  contents: read
 jobs:
   BuildAndTestAppOnGPTDriver: # Job name, as chosen
     runs-on: macos-latest # macOS runner is required for iOS builds
EOF
@@ -2,6 +2,8 @@
on:
workflow_dispatch: {}

permissions:
contents: read
jobs:
BuildAndTestAppOnGPTDriver: # Job name, as chosen
runs-on: macos-latest # macOS runner is required for iOS builds
Copilot is powered by AI and may make mistakes. Always verify output.
@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants