Skip to content
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

[SDK-2480] Created initial MobileBoost test apps and Github Actions #1461

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 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
88 changes: 88 additions & 0 deletions .github/workflows/receive-mobileboost-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Receive MobileBoost Results

on:
repository_dispatch:
types: [mobileboost-results]

jobs:
process-results:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Process results
id: process_results
run: |
import json
import os

# Get the JSON payload from the webhook
payload = ${{ toJson(github.event.client_payload) }}

# Process the results
total_tests = payload['totalTests']
failed_tests = payload['failedTests']
app_info = payload['appInfo']
app_version = f"{payload['appVersionName']} ({payload['appVersionCode']})"
platform = payload['platform']

# Create the Slack message blocks
blocks = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": f"MobileBoost Test Results for {app_info}",
"emoji": True
}
},
{
"type": "section",
"fields": [
{"type": "mrkdwn", "text": f"*Platform:* {platform.capitalize()}"},
{"type": "mrkdwn", "text": f"*Version:* {app_version}"},
{"type": "mrkdwn", "text": f"*Total Tests:* {total_tests}"},
{"type": "mrkdwn", "text": f"*Failed Tests:* {len(failed_tests)}"}
]
}
]

if failed_tests:
blocks.append({"type": "divider"})
blocks.append({
"type": "section",
"text": {"type": "mrkdwn", "text": "*Failed Tests:*"}
})
for test in failed_tests:
blocks.append({
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"• <{test['recording']}|{test['title']}>\n"
f" Device: {test['device']} ({test['os']})\n"
f" Error: {test['statusMessage']}"
}
})
else:
blocks.append({
"type": "section",
"text": {"type": "mrkdwn", "text": "All tests passed successfully! 🎉"}
})

# Set output for the next step
print(f"::set-output name=slack_payload::{json.dumps({'blocks': blocks})}")
shell: python

- name: Send message to Slack
uses: slackapi/[email protected]
with:
channel-id: "C07JDKLFU8N"
payload: ${{ steps.process_results.outputs.slack_payload }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
88 changes: 88 additions & 0 deletions .github/workflows/run-mobileboost-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Run MobileBoost Tests on PR
on:
pull_request:
types: [opened, reopened]
workflow_dispatch:

jobs:
build-and-test:
runs-on: macos-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Build Main Branch-TestBed
run: |
xcodebuild -project Branch-TestBed/Branch-TestBed.xcodeproj \
-scheme Branch-TestBed \
-sdk iphonesimulator \
-configuration Debug \
-derivedDataPath $PWD/build \
clean build

- name: Build DelayedInitTest
run: |
ls
xcodebuild -project Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/ \
-scheme DelayedInitTest \
-sdk iphonesimulator \
-configuration Debug \
-derivedDataPath $PWD/build_delayed \
clean build

- name: Build ScenesTest
run: |
xcodebuild -project Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj \
-scheme ScenesTest \
-sdk iphonesimulator \
-configuration Debug \
-derivedDataPath $PWD/build_scenes \
clean build

- name: Build SwiftUITest
run: |
xcodebuild -project Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj \
-scheme SwiftUITest \
-sdk iphonesimulator \
-configuration Debug \
-derivedDataPath $PWD/build_swiftui \
clean build

- name: Compress Main Branch-TestBed
run: |
cd $PWD/build/Build/Products/Debug-iphonesimulator/
zip -r Branch-TestBed.app.zip Branch-TestBed.app

- name: Compress DelayedInitTest
run: |
cd $PWD/build_delayed/Build/Products/Debug-iphonesimulator/
zip -r DelayedInitTest.app.zip DelayedInitTest.app

- name: Compress ScenesTest
run: |
cd $PWD/build_scenes/Build/Products/Debug-iphonesimulator/
zip -r ScenesTest.app.zip ScenesTest.app

- name: Compress SwiftUITest
run: |
cd $PWD/build_swiftui/Build/Products/Debug-iphonesimulator/
zip -r SwiftUITest.app.zip SwiftUITest.app

- name: Upload builds to Mobile Boost and Run Tests
run: |
echo "Uploading Branch-TestBed..."
curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build/Build/Products/Debug-iphonesimulator/Branch-TestBed.app.zip" ios

echo "Uploading DelayedInitTest.app.zip..."
curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_delayed/Build/Products/Debug-iphonesimulator/DelayedInitTest.app.zip" ios

echo "Uploading ScenesTest.app.zip..."
curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_scenes/Build/Products/Debug-iphonesimulator/ScenesTest.app.zip" ios

echo "Uploading SwiftUITest.app.zip..."
curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_swiftui/Build/Products/Debug-iphonesimulator/SwiftUITest.app.zip" ios
env:
API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }}
TEST_TAGS: Test
shell: bash
6 changes: 5 additions & 1 deletion Branch-TestBed/Branch-TestBed/Branch-TestBed-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>3.7.0</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are not happy with this change
XCTAssertEqualObjects(application.displayVersionString, @"1.1");

<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>branchtest</string>
</array>
<key>CFBundleURLName</key>
<string>io.branch.sdk.Branch-TestBed</string>
</dict>
</array>
<key>CFBundleVersion</key>
Expand Down
38 changes: 35 additions & 3 deletions Branch-TestBed/Branch-TestBed/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ - (IBAction)setUserIDButtonTouchUpInside:(id)sender {
dispatch_async(dispatch_get_main_queue(), ^{
[appDelegate setLogFile:nil];
if (!error) {
NSLog(@"Branch TestBed: Identity Successfully Set%@", params);
NSString* newIdentity = [BNCPreferenceHelper sharedInstance].userIdentity;

NSLog(@"Branch TestBed: Attempted to set Identity to: %@\nIdentity Successfully Set to: %@", user_id2, newIdentity);
[self performSegueWithIdentifier:@"ShowLogOutput"
sender:[NSString stringWithFormat:@"Identity set to: %@\n\n%@",
user_id2, params.description]];
sender:[NSString stringWithFormat:@"Attempted to set Identity to %@\n Identity set to: %@",
user_id2, newIdentity]];
} else {
NSLog(@"Branch TestBed: Error setting identity: %@", error);
[self showAlert:@"Unable to Set Identity" withDescription:error.localizedDescription];
Expand All @@ -239,6 +241,32 @@ - (IBAction)setUserIDButtonTouchUpInside:(id)sender {
}];
}

- (IBAction)setDMAParamsPressed:(id)sender {
[appDelegate setLogFile:@"SetDMAParams"];
[Branch setDMAParamsForEEA:true AdPersonalizationConsent:true AdUserDataUsageConsent:true];

BOOL eeaRegion = [BNCPreferenceHelper sharedInstance].eeaRegion;
BOOL adPersonalizationConsent = [BNCPreferenceHelper sharedInstance].adPersonalizationConsent;
BOOL adUserDataUsageConsent = [BNCPreferenceHelper sharedInstance].adUserDataUsageConsent;

// Check if all DMA parameters are set to true
if (!eeaRegion || !adPersonalizationConsent || !adUserDataUsageConsent) {
[self showAlert:@"Unable to Set DMA Params" withDescription:@"One or more DMA parameters are not set correctly."];
return;
}

NSLog(@"Branch TestBed: Set DMA Params: %@, %@, %@",
eeaRegion ? @"YES" : @"NO",
adPersonalizationConsent ? @"YES" : @"NO",
adUserDataUsageConsent ? @"YES" : @"NO");

[self performSegueWithIdentifier:@"ShowLogOutput" sender:[
NSString stringWithFormat:@"Set DMA Params: %@, %@, %@",
eeaRegion ? @"YES" : @"NO",
adPersonalizationConsent ? @"YES" : @"NO",
adUserDataUsageConsent ? @"YES" : @"NO"
]];
}

- (IBAction)logoutWithCallback {
Branch *branch = [Branch getInstance];
Expand Down Expand Up @@ -906,6 +934,10 @@ - (IBAction)shareLinkWithMetadata:(id)sender {
[bsl presentActivityViewControllerFromViewController:self anchor:nil];
}

- (IBAction)forceQuitAppPressed:(id)sender {
exit(0);
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
Expand Down
Loading
Loading