Skip to content

Commit 931db57

Browse files
test gptdriver integration
1 parent 27eaf94 commit 931db57

File tree

6 files changed

+256
-9
lines changed

6 files changed

+256
-9
lines changed

.github/gptdriverrunscript.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
# Constants should ideally be set as environment variables for security
6+
readonly API_URL="https://api.mobileboost.io"
7+
readonly API_ORG_KEY="${API_ORG_KEY}"
8+
readonly API_TOKEN="${API_TOKEN:-null}"
9+
readonly TEST_TIMEOUT="${TEST_TIMEOUT:-7200}"
10+
readonly TEST_TAGS="${TEST_TAGS:-}"
11+
12+
# Function to post data using curl and handle errors
13+
post_data() {
14+
local url=$1
15+
local body=$2
16+
if ! response=$(curl -s -f -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d "$body" "$url"); then
17+
echo "Error: Network request failed with error $response" >&2
18+
exit 1
19+
fi
20+
echo "$response"
21+
}
22+
23+
# Validate inputs
24+
if [[ -z "$1" || -z "$2" ]]; then
25+
echo "Usage: $0 <build_filename> <build_platform>"
26+
exit 1
27+
fi
28+
29+
# Validate environment variables
30+
if [[ -z "$API_ORG_KEY" ]]; then
31+
echo "Please set API_ORG_KEY to your organization key"
32+
exit 1
33+
fi
34+
35+
buildFilename="$1"
36+
buildPlatform="$2"
37+
tags=()
38+
39+
# Check if TEST_TAGS is provided and split into an array
40+
if [[ -n "$TEST_TAGS" ]]; then
41+
IFS=',' read -ra tags <<< "$TEST_TAGS"
42+
fi
43+
44+
# Upload build file
45+
echo -n "Uploading build from $buildFilename for $buildPlatform: "
46+
if ! uploadedBuildResponse=$(curl -s -f -X POST \
47+
-H "Authorization: Bearer $API_TOKEN" \
48+
-H "Content-Type: multipart/form-data" \
49+
-F "build=@$buildFilename" \
50+
-F "organisation_key=$API_ORG_KEY" \
51+
-F "platform=$buildPlatform" \
52+
-F "metadata={}" \
53+
"$API_URL/uploadBuild/"); then
54+
echo "Error: Failed to upload build" >&2
55+
exit 1
56+
fi
57+
58+
# Extract the buildId
59+
if ! buildId=$(jq -r '.buildId' <<< "$uploadedBuildResponse") || [ -z "$buildId" ]; then
60+
echo "Error: Failed to extract build ID from the response" >&2
61+
exit 1
62+
fi
63+
echo "uploaded (ID: $buildId), app link: $(jq -r '.app_link' <<< "$uploadedBuildResponse")"
64+
65+
# Execute test suite
66+
echo "Executing test suite..."
67+
jsonPayload="{\"organisationId\": \"$API_ORG_KEY\", \"uploadId\": \"$buildId\""
68+
if [ ${#tags[@]} -gt 0 ]; then
69+
jsonTags=$(printf ',\"%s\"' "${tags[@]}")
70+
jsonTags="[${jsonTags:1}]"
71+
jsonPayload+=", \"tags\": $jsonTags"
72+
fi
73+
jsonPayload+="}"
74+
if ! testSuiteRunId=$(post_data "$API_URL/tests/execute" "$jsonPayload" | jq -r '.test_suite_ids[0]') || [ -z "$testSuiteRunId" ]; then
75+
echo "Error: Test suite execution failed" >&2
76+
exit 1
77+
fi
78+
79+
# Wait for test suite to finish
80+
echo -n "Waiting for test suite to finish..."
81+
startTime=$(date +%s)
82+
while true; do
83+
if ! testSuiteData=$(curl -s -f "$API_URL/testSuiteRuns/$testSuiteRunId/gh"); then
84+
echo "Error: Failed to retrieve test suite data" >&2
85+
exit 1
86+
fi
87+
testSuiteStatus=$(jq -r '.status' <<< "$testSuiteData")
88+
89+
if [[
90+
"$testSuiteStatus" == "completed"
91+
]]; then
92+
echo "Status is $testSuiteStatus!" >&2
93+
break
94+
fi
95+
96+
if (( $(date +%s) - startTime >= TEST_TIMEOUT )); then
97+
echo "Timeout exceeded while waiting for test suite to finish." >&2
98+
exit 1
99+
fi
100+
101+
echo -n "."
102+
sleep 1
103+
done
104+
echo " done!"
105+
106+
# Write test suite summary to file if available
107+
if [[ -n "$GITHUB_STEP_SUMMARY" && -w "$GITHUB_STEP_SUMMARY" ]]; then
108+
jq -r '.markdown' <<< "$testSuiteData" >> "$GITHUB_STEP_SUMMARY"
109+
echo "Step summary written to $GITHUB_STEP_SUMMARY"
110+
fi
111+
112+
# Check test suite result
113+
if ! testSuiteResult=$(jq -r '.result' <<< "$testSuiteData"); then
114+
echo "Test suite did not pass, result: $testSuiteResult" >&2
115+
exit 1
116+
fi
117+
118+
if [[ "$testSuiteResult" == "succeeded" ]]; then
119+
echo "Test passed successfully"
120+
exit 0
121+
else
122+
echo "Test suite did not pass, result: $testSuiteResult" >&2
123+
exit 1
124+
fi
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: iOS Release Build and GPTDriver Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'Release-*' # Trigger for branches starting with "Release-"
7+
8+
jobs:
9+
BuildAndTestAppOnGPTDriver: # Updated job name
10+
runs-on: macos-latest # macOS runner is required for iOS builds
11+
steps:
12+
# --- Step 1: Extract version from branch name ---
13+
- name: Extract version from branch name
14+
id: extract_version_step
15+
run: |
16+
BRANCH_NAME="${{ github.ref }}"
17+
# Remove 'refs/heads/' prefix (e.g., refs/heads/Release-0.0.0 -> Release-0.0.0)
18+
BRANCH_NAME_WITHOUT_PREFIX="${BRANCH_NAME#refs/heads/}"
19+
# Extract version after "Release-" (e.g., Release-0.0.0 -> 0.0.0)
20+
VERSION=$(echo "$BRANCH_NAME_WITHOUT_PREFIX" | sed -n 's/^Release-\([0-9]*\.[0-9]*\.[0-9]*\)$/\1/p')
21+
22+
if [ -z "$VERSION" ]; then
23+
echo "Error: Could not extract version from branch name '$BRANCH_NAME_WITHOUT_PREFIX'. Expected format: Release-X.Y.Z"
24+
exit 1
25+
fi
26+
27+
echo "Extracted versionName: $VERSION"
28+
echo "VERSION_STRING=$VERSION" >> $GITHUB_ENV
29+
30+
# Convert semantic version to an integer for CFBundleVersion (versionCode equivalent)
31+
# Example: 1.2.3 -> 102003 (assuming max 2 digits for minor/patch)
32+
# This should be adjusted based on the maximum expected values for major/minor/patch
33+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
34+
MINOR=$(echo "$VERSION" | cut -d. -f2)
35+
PATCH=$(echo "$VERSION" | cut -d. -f3)
36+
37+
# Calculate versionCode (CFBundleVersion) - ensure this fits in a 32-bit integer
38+
# Standard Android-like conversion: Major * 10000 + Minor * 100 + Patch
39+
# This provides sufficient uniqueness for most common versioning schemes.
40+
VERSION_CODE_INT=$(( MAJOR * 10000 + MINOR * 100 + PATCH ))
41+
echo "Calculated versionCode: $VERSION_CODE_INT"
42+
echo "VERSION_CODE_INT=$VERSION_CODE_INT" >> $GITHUB_ENV
43+
44+
45+
# --- Step 2: Checkout the iOS Branch SDK repository ---
46+
- name: Checkout BranchMetrics/ios-branch-deep-linking-attribution (SDK)
47+
uses: actions/checkout@v4
48+
with:
49+
repository: BranchMetrics/ios-branch-deep-linking-attribution
50+
ref: ${{ github.ref }} # Use the same branch that triggered the workflow
51+
path: ./branch-ios-sdk-repo # Checkout into a subdirectory
52+
53+
# --- Step 3: Build the iOS Branch SDK Framework ---
54+
- name: Build Branch SDK Framework
55+
run: |
56+
# Build for simulator. Adjust scheme if necessary.
57+
# The output framework will be in build/Debug-iphonesimulator/BranchSDK.framework
58+
xcodebuild build -project Branch-SDK/Branch-SDK.xcodeproj \
59+
-scheme BranchSDK \
60+
-configuration Debug \
61+
-sdk iphonesimulator \
62+
BUILD_DIR="${{ github.workspace }}/branch-ios-sdk-repo/build" \
63+
SKIP_INSTALL=NO
64+
working-directory: ./branch-ios-sdk-repo # Run xcodebuild from the SDK's checkout directory
65+
66+
# --- Step 4: Checkout the iOS Branch Link Simulator App repository ---
67+
- name: Checkout BranchMetrics/BranchLinkSimulator (App)
68+
uses: actions/checkout@v4
69+
with:
70+
repository: BranchMetrics/BranchLinkSimulator
71+
ref: gptdriver/linkingTests # Checkout the specific app branch
72+
path: ./ios-app-repo # Checkout into another subdirectory
73+
74+
# --- Step 5: Copy the generated SDK Framework to the App's project ---
75+
- name: Copy generated SDK Framework to App's project
76+
run: |
77+
# Create a 'Frameworks' directory within the app repo for the local SDK
78+
mkdir -p ./ios-app-repo/Frameworks
79+
# Copy the built framework
80+
cp -R ./branch-ios-sdk-repo/build/Debug-iphonesimulator/BranchSDK.framework ./ios-app-repo/Frameworks/
81+
working-directory: ${{ github.workspace }} # Run from the root of the GITHUB_WORKSPACE
82+
83+
# --- Step 6: Build the iOS Branch Link Simulator App using the local SDK Framework ---
84+
- name: Build iOS App with local SDK
85+
run: |
86+
# Build the app. Adjust project/workspace, scheme, and destination if necessary.
87+
# We're passing MARKETING_VERSION (versionName) and CURRENT_PROJECT_VERSION (versionCode)
88+
xcodebuild build -project BranchLinkSimulator.xcodeproj \
89+
-scheme BranchLinkSimulator \
90+
-configuration Debug \
91+
-sdk iphonesimulator \
92+
-destination 'platform=iOS Simulator,name=iPhone 15' \
93+
MARKETING_VERSION=${{ env.VERSION_STRING }} \
94+
CURRENT_PROJECT_VERSION=${{ env.VERSION_CODE_INT }} \
95+
FRAMEWORK_SEARCH_PATHS="$(SRCROOT)/Frameworks" \
96+
# You might also need LD_RUNPATH_SEARCH_PATHS if it's an embedded framework
97+
# LD_RUNPATH_SEARCH_PATHS="@loader_path/../Frameworks"
98+
working-directory: ./ios-app-repo # Run xcodebuild from the App's checkout directory
99+
100+
# --- Step 7: Echo the location of the generated .app bundle ---
101+
- name: Echo .app bundle location
102+
run: |
103+
APP_PATH="./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app"
104+
echo "Generated .app bundle location: $APP_PATH"
105+
106+
# --- Step 8: Upload Build Artifacts ---
107+
- name: Upload Build Artifacts
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: BranchLinkSimulator-iOS-Debug-Build
111+
path: ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app
112+
113+
# --- Step 9: Upload and run tests on GPTDriver service. ---
114+
- name: Run GPTDriver tests
115+
run: |
116+
# Ensure the script is executable
117+
chmod +x ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh
118+
# Execute the script, passing the .app path and platform
119+
bash ./branch-ios-sdk-repo/.github/gptdriverrunscript.sh ./ios-app-repo/build/Debug-iphonesimulator/BranchLinkSimulator.app ios
120+
env:
121+
API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
122+
API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
123+
TEST_TAGS: Release

BranchSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "BranchSDK"
3-
s.version = "3.12.1"
3+
s.version = "0.0.1"
44
s.summary = "Create an HTTP URL for any piece of content in your app"
55
s.description = <<-DESC
66
- Want the highest possible conversions on your sharing feature?

BranchSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@
20162016
"@executable_path/Frameworks",
20172017
"@loader_path/Frameworks",
20182018
);
2019-
MARKETING_VERSION = 3.12.1;
2019+
MARKETING_VERSION = 0.0.1;
20202020
OTHER_LDFLAGS = (
20212021
"-weak_framework",
20222022
LinkPresentation,
@@ -2051,7 +2051,7 @@
20512051
"@executable_path/Frameworks",
20522052
"@loader_path/Frameworks",
20532053
);
2054-
MARKETING_VERSION = 3.12.1;
2054+
MARKETING_VERSION = 0.0.1;
20552055
OTHER_LDFLAGS = (
20562056
"-weak_framework",
20572057
LinkPresentation,
@@ -2257,7 +2257,7 @@
22572257
"@loader_path/Frameworks",
22582258
);
22592259
MACH_O_TYPE = staticlib;
2260-
MARKETING_VERSION = 3.12.1;
2260+
MARKETING_VERSION = 0.0.1;
22612261
OTHER_LDFLAGS = (
22622262
"-weak_framework",
22632263
LinkPresentation,
@@ -2296,7 +2296,7 @@
22962296
"@loader_path/Frameworks",
22972297
);
22982298
MACH_O_TYPE = staticlib;
2299-
MARKETING_VERSION = 3.12.1;
2299+
MARKETING_VERSION = 0.0.1;
23002300
OTHER_LDFLAGS = (
23012301
"-weak_framework",
23022302
LinkPresentation,
@@ -2333,7 +2333,7 @@
23332333
"@executable_path/Frameworks",
23342334
"@loader_path/Frameworks",
23352335
);
2336-
MARKETING_VERSION = 3.12.1;
2336+
MARKETING_VERSION = 0.0.1;
23372337
OTHER_LDFLAGS = (
23382338
"-weak_framework",
23392339
LinkPresentation,
@@ -2368,7 +2368,7 @@
23682368
"@executable_path/Frameworks",
23692369
"@loader_path/Frameworks",
23702370
);
2371-
MARKETING_VERSION = 3.12.1;
2371+
MARKETING_VERSION = 0.0.1;
23722372
OTHER_LDFLAGS = (
23732373
"-weak_framework",
23742374
LinkPresentation,

Sources/BranchSDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "BNCConfig.h"
1010

11-
NSString * const BNC_SDK_VERSION = @"3.12.1";
11+
NSString * const BNC_SDK_VERSION = @"0.0.1";
1212
NSString * const BNC_LINK_URL = @"https://bnc.lt";
1313
NSString * const BNC_CDN_URL = @"https://cdn.branch.io";
1414

scripts/version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Options:
3030
USAGE
3131
}
3232

33-
version=3.12.1
33+
version=0.0.1
3434
prev_version="$version"
3535

3636
if (( $# == 0 )); then

0 commit comments

Comments
 (0)