Skip to content

[Draft] GPT Driver Automation #1499

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

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
Copy link
Contributor

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

A new GitHub Actions workflow, .github/workflows/gptdriverautomation.yaml, has been added. This workflow is designed to automate the iOS release build process and integrate with the GPTDriver testing service. It is configured to trigger on pushes to branches starting with Release-*.

The workflow executes a series of sequential steps:

  • Version Extraction: It extracts the semantic version (e.g., 0.0.0) from the branch name and calculates a corresponding integer versionCode (CFBundleVersion) for iOS applications.
  • SDK Checkout & Build: It checks out the BranchMetrics/ios-branch-deep-linking-attribution SDK repository and proceeds to build the BranchSDK.framework for the iOS simulator.
  • App Checkout & Integration: It then checks out the BranchMetrics/BranchLinkSimulator application repository (specifically targeting the gptdriver/linkingTests branch). The locally built SDK framework is subsequently copied into the app's Frameworks directory.
  • App Build: The BranchLinkSimulator app is built, with the extracted versionName and versionCode injected into its build process.
  • Artifact Upload: The generated .app bundle is uploaded as a GitHub Actions artifact, making it available for download.
  • GPTDriver Tests: Finally, a shell script (gptdriverrunscript.sh) located within the SDK repository is executed. This script is responsible for uploading the built .app bundle to the GPTDriver service and initiating automated tests, leveraging provided API keys and test tags.

🔍 Impact of the Change

This new workflow significantly enhances the CI/CD pipeline by automating a critical part of the iOS release process. By automatically building the SDK, integrating it into a sample app, and running tests via the GPTDriver service upon every push to a release branch, it ensures early detection of integration issues and build failures. This automation reduces manual overhead, improves the reliability and consistency of release builds, and accelerates the feedback loop for developers, ultimately contributing to a more robust and efficient release cycle.

📁 Total Files Changed

1 file changed.

🧪 Test Added

This Pull Request introduces a new CI/CD workflow that serves as an automated testing and build verification mechanism. The workflow's steps collectively act as a comprehensive test setup:

  • Build Verification: The workflow rigorously tests the ability to successfully build both the BranchSDK.framework and the BranchLinkSimulator.app, ensuring that all dependencies and configurations are correct for specific versioning.
  • SDK Integration Test: By copying the locally built SDK into the application's directory and then building the app, the workflow performs a crucial integration test, verifying that the SDK can be correctly linked and utilized by a consumer application.
  • External Service Testing (GPTDriver): The final and most significant test involves invoking the gptdriverrunscript.sh. This script is designed to upload the compiled .app bundle to the GPTDriver service, which then executes a suite of automated tests. These tests likely cover functional, UI, or deep linking scenarios, providing an end-to-end validation of the application's behavior with the integrated SDK.

🔒Security Vulnerabilities

No direct security vulnerabilities were detected in the provided workflow configuration. The use of GitHub Secrets (secrets.MOBILEBOOST_API_ORG_KEY) for sensitive API keys is correctly implemented, which is the recommended secure practice. It is noted that both API_KEY and API_ORG_KEY environment variables are mapped to the same secret; this should be confirmed as intentional and aligned with the vendor's design.

Tip

Quality Recommendations

  1. Consider using Release configuration for xcodebuild commands instead of Debug if this workflow is specifically for release builds, to ensure the build matches production requirements and optimizations.

  2. Parameterize the ref: gptdriver/linkingTests for BranchMetrics/BranchLinkSimulator checkout and the -destination 'platform=iOS Simulator,name=iPhone 15' to allow for greater flexibility and reusability of the workflow across different app branches or simulator types.

  3. Add a check for the existence of the built framework (./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework) before attempting to copy it in Step 5. This would make the workflow more robust against unexpected build failures in previous steps.

  4. Ensure the CFBundleVersion calculation (MAJOR * 10000 + MINOR * 100 + PATCH) is sufficient for all expected version numbers. If minor or patch versions can exceed 99, this calculation might lead to non-unique or incorrect version codes. Consider a more robust scheme if necessary, or add a comment clarifying the assumption.

  5. Add a newline character at the end of the file (.github/workflows/gptdriverautomation.yaml) for better file formatting and compatibility with various text editors and version control systems.

Sequence Diagram

sequenceDiagram
    participant GitHub as GitHub Push Event
    participant Workflow as iOS Release Build and GPTDriver Tests Workflow
    participant Extractor as Extract version from branch name
    participant CheckoutSDK as Checkout BranchMetrics/ios-branch-deep-linking-attribution
    participant BuildSDK as Build Branch SDK Framework
    participant CheckoutApp as Checkout BranchMetrics/BranchLinkSimulator
    participant CopySDK as Copy generated SDK Framework
    participant BuildApp as Build iOS App with local SDK
    participant EchoApp as Echo .app bundle location
    participant UploadArtifact as Upload Build Artifacts
    participant GPTDriver as Run GPTDriver tests

    GitHub->>Workflow: Push to 'Release-*' branch
    Workflow->>Extractor: Trigger
    Extractor->>Extractor: Get github.ref (e.g., refs/heads/Release-0.0.0)
    Extractor-->>Workflow: Set env.VERSION_STRING (e.g., 0.0.0)
    Extractor-->>Workflow: Set env.VERSION_CODE_INT (e.g., 102003)
    Workflow->>CheckoutSDK: uses: actions/checkout@v4 (repository: BranchMetrics/ios-branch-deep-linking-attribution, ref: ${{ github.ref }}, path: ./branch-ios-sdk-repo)
    CheckoutSDK-->>Workflow: SDK repository checked out
    Workflow->>BuildSDK: 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)
    BuildSDK-->>Workflow: BranchSDK.framework built
    Workflow->>CheckoutApp: uses: actions/checkout@v4 (repository: BranchMetrics/BranchLinkSimulator, ref: gptdriver/linkingTests, path: ./ios-app-repo)
    CheckoutApp-->>Workflow: App repository checked out
    Workflow->>CopySDK: mkdir -p ./ios-app-repo/Frameworks; cp -R ./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework ./ios-app-repo/Frameworks/ (working-directory: ${{ github.workspace }})
    CopySDK-->>Workflow: SDK Framework copied to App
    Workflow->>BuildApp: 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 }} (working-directory: ./ios-app-repo)
    BuildApp-->>Workflow: BranchLinkSimulator.app built
    Workflow->>EchoApp: echo "Generated .app bundle location: ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app"
    EchoApp-->>Workflow: App bundle path echoed
    Workflow->>UploadArtifact: uses: actions/upload-artifact@v4 (name: BranchLinkSimulator-iOS-Debug-Build, path: ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app)
    UploadArtifact-->>Workflow: App bundle uploaded as artifact
    Workflow->>GPTDriver: chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh; bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app ios (env: API_ORG_KEY, API_KEY, TEST_TAGS)
    GPTDriver-->>Workflow: GPTDriver tests initiated/completed
Loading

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

Comment on lines +10 to +125

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 2 months ago

To fix the issue, add a permissions block at the root level of the workflow file. This block will explicitly define the permissions required for the workflow, ensuring that the GITHUB_TOKEN has the least privileges necessary. Based on the workflow's operations, the contents: read permission is sufficient, as the workflow only needs to read repository contents (e.g., for checkout operations). No write permissions are required.

The permissions block should be added immediately after the name field at the top of the file.


Suggested changeset 1
.github/workflows/gptdriverautomation.yaml

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.yaml b/.github/workflows/gptdriverautomation.yaml
--- a/.github/workflows/gptdriverautomation.yaml
+++ b/.github/workflows/gptdriverautomation.yaml
@@ -1,2 +1,4 @@
 name: iOS Release Build and GPTDriver Tests
+permissions:
+  contents: read
 
EOF
@@ -1,2 +1,4 @@
name: iOS Release Build and GPTDriver Tests
permissions:
contents: read

Copilot is powered by AI and may make mistakes. Always verify output.
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.

1 participant