Skip to content
Closed
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
75 changes: 75 additions & 0 deletions .github/actions/get-browserstack-build-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 'Get BrowserStack Build Info'
description: 'Fetches PR info and generates sanitized BrowserStack project and build names'
inputs:
project-name:
description: 'BrowserStack project name (e.g., "quickstart - Flutter")'
required: true
platform-suffix:
description: 'Optional platform suffix to append to build name (e.g., " (Android)", " (iOS)")'
required: false
default: ''
title-max-length:
description: 'Maximum length for PR title in build name'
required: false
default: '100'
commit-max-length:
description: 'Maximum length for commit message in build name'
required: false
default: '140'
outputs:
project-name:
description: 'BrowserStack project name'
value: ${{ steps.generate.outputs.project-name }}
build-name:
description: 'BrowserStack build name with PR and commit info'
value: ${{ steps.generate.outputs.build-name }}
pr-number:
description: 'PR number (if available)'
value: ${{ steps.generate.outputs.pr-number }}
pr-title:
description: 'Sanitized PR title (if available)'
value: ${{ steps.generate.outputs.pr-title }}

runs:
using: 'composite'
steps:
- name: Generate BrowserStack build info
id: generate
shell: bash
run: |
# Fetch PR info using GitHub CLI
# Use head_ref for pull_request events, ref_name for push events
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
PR_INFO=$(gh pr view "$BRANCH_NAME" --json number,title --jq '{number:.number, title:.title}' 2>/dev/null || echo '{}')
PR_NUMBER=$(echo "$PR_INFO" | jq -r '.number // empty')
PR_TITLE=$(echo "$PR_INFO" | jq -r '.title // empty')
COMMIT_MSG="${{ github.event.head_commit.message }}"

# Sanitize - keep only BrowserStack-allowed chars: A-Z a-z 0-9 . : - [ ] / @ & ' _
PR_TITLE_CLEAN=$(echo "$PR_TITLE" | sed "s/[^A-Za-z0-9.:[\]\/@&' _-]//g")
COMMIT_FIRST_LINE=$(echo "$COMMIT_MSG" | head -n1)
COMMIT_MSG_CLEAN=$(echo "$COMMIT_FIRST_LINE" | sed "s/[^A-Za-z0-9.:[\]\/@&' _-]//g")

# Truncate to specified lengths
PR_TITLE_PART="${PR_TITLE_CLEAN:0:${{ inputs.title-max-length }}}"
COMMIT_MSG_PART="${COMMIT_MSG_CLEAN:0:${{ inputs.commit-max-length }}}"

PROJECT_NAME="${{ inputs.project-name }}"
PLATFORM_SUFFIX="${{ inputs.platform-suffix }}"

# Generate build name
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
BUILD_NAME="PR-$PR_NUMBER: $PR_TITLE_PART - $COMMIT_MSG_PART$PLATFORM_SUFFIX"
else
BUILD_NAME="Build-${{ github.run_number }}$PLATFORM_SUFFIX"
fi

# Output all values
echo "project-name=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "build-name=$BUILD_NAME" >> $GITHUB_OUTPUT
echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "pr-title=$PR_TITLE_CLEAN" >> $GITHUB_OUTPUT

# Also output for debugging
echo "📦 Project: $PROJECT_NAME"
echo "🏗️ Build: $BUILD_NAME"
115 changes: 115 additions & 0 deletions .github/browserstack-devices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
# BrowserStack Device Configuration
#
# Centralized configuration for all BrowserStack testing across CI workflows.
# Each SDK/app has its own configuration section below.
#
# Device Selection Criteria:
# - Coverage: Test across multiple OS versions (latest, current-1, current-2)
# - Market share: Focus on popular devices (Pixel, Samsung Galaxy, iPhone)
# - OS baseline: Ensure minimum supported OS versions are tested
#
# References:
# - Mobile devices: https://www.browserstack.com/docs/app-automate/api-reference/appium/devices
# - Desktop browsers: https://www.browserstack.com/docs/automate/api-reference/selenium/list-of-browsers-and-platforms

# Android C++ QuickStart
android-cpp:
devices:
- "Google Pixel 7-13.0" # Android 13 baseline

# Android Java QuickStart
android-java:
devices:
- "Google Pixel 8-14.0" # Latest Android 14
- "Samsung Galaxy S23-13.0" # Popular flagship, Android 13
- "Google Pixel 6-12.0" # Android 12 support
- "OnePlus 9-11.0" # Android 11 minimum baseline

# Android Kotlin QuickStart
android-kotlin:
devices:
- "Google Pixel 8-14.0" # Latest Android 14
- "Samsung Galaxy S23-13.0" # Popular flagship, Android 13
- "Google Pixel 6-12.0" # Android 12 support
- "OnePlus 9-11.0" # Android 11 minimum baseline

# Flutter QuickStart (multi-platform)
flutter:
android:
devices:
- "Google Pixel 7-13.0" # Android 13 baseline
- "Samsung Galaxy S23-13.0" # Popular flagship
- "Google Pixel 6-12.0" # Android 12 support
ios:
devices:
- "iPhone 13-15" # iOS 15 support
- "iPhone 14-16" # iOS 16 current
- "iPhone 12-17" # iOS 17 latest

# Kotlin Multiplatform QuickStart
kotlin-multiplatform:
android:
devices:
- "Google Pixel 8-14.0" # Latest Android 14
- "Samsung Galaxy S23-13.0" # Popular flagship

# React Native QuickStart
react-native:
android:
devices:
- "Samsung Galaxy S22-12.0" # Android 12
- "Google Pixel 7-13.0" # Android 13
ios:
devices:
- "iPhone 15-17.0" # Latest iOS 17
- "iPhone 14-16.0" # iOS 16 support

# React Native Expo QuickStart
react-native-expo:
android:
devices:
- "Samsung Galaxy S22-12.0" # Android 12
- "Google Pixel 7-13.0" # Android 13
ios:
devices:
- "iPhone 15-17.0" # Latest iOS 17
- "iPhone 14-16.0" # iOS 16 support

# .NET MAUI QuickStart (multi-platform)
dotnet-maui:
android:
devices:
- "Google Pixel 8-14.0" # Latest Android 14
- "Samsung Galaxy S23-13.0" # Popular flagship
ios:
devices:
- "iPhone 15-17.0" # Latest iOS 17
- "iPhone 14-16.0" # iOS 16 support

# Swift/iOS QuickStart
swift:
devices:
- "iPhone 15 Pro-17" # Latest flagship with iOS 17

# Java Spring (web application)
# Tests web app in desktop browsers using Selenium WebDriver
java-spring:
platforms:
- os: "Windows"
osVersion: "11"
browserName: "Chrome"
browserVersion: "latest" # Always test latest Chrome

# JavaScript Web (React web application)
# Tests web app in multiple desktop browsers
javascript-web:
browsers:
- browser: "Chrome"
browser_version: "120.0"
os: "Windows"
os_version: "11"
- browser: "Firefox"
browser_version: "121.0"
os: "Windows"
os_version: "11"
46 changes: 27 additions & 19 deletions .github/scripts/browserstack-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"""

import time
import json
import sys
import os
import yaml
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
Expand Down Expand Up @@ -59,13 +59,29 @@ def run_test(browser_config):
)

# Set up BrowserStack options
# Include PR context for easier dashboard navigation
pr_number = os.environ.get('GITHUB_PR_NUMBER', '')
pr_title = os.environ.get('GITHUB_PR_TITLE', '')
# Truncate PR title to ensure project name stays under 100 chars
pr_title_truncated = pr_title[:75] if pr_title else ''
commit_msg = os.environ.get('GITHUB_COMMIT_MSG', '')

# Project name is always "quickstart - JavaScript Web"
project_name = "quickstart - JavaScript Web"

# Build name includes PR context
if pr_number and pr_title_truncated:
build_name = f"{os.environ.get('GITHUB_PR_TITLE', '')} #{pr_number}: {pr_title_truncated}"
else:
build_name = f"Build #{os.environ.get('GITHUB_RUN_NUMBER', '0')}"

bs_options = {
"browserVersion": browser_config["browser_version"],
"os": browser_config["os"],
"osVersion": browser_config["os_version"],
"sessionName": f"Ditto Tasks Test - {browser_config['browser']} {browser_config['browser_version']}",
"buildName": f"Ditto JavaScript Web Build #{os.environ.get('GITHUB_RUN_NUMBER', '0')}",
"projectName": "Ditto JavaScript Web",
"buildName": build_name,
"projectName": project_name,
"local": "true",
"debug": "true",
"video": "true",
Expand Down Expand Up @@ -125,7 +141,7 @@ def run_test(browser_config):
time.sleep(3)

# Check for GitHub test document
github_doc_id = os.environ.get("GITHUB_TEST_DOC_ID")
github_doc_id = os.environ.get("DITTO_CLOUD_TASK_TITLE")
if github_doc_id:
print(f"Checking for GitHub test document: {github_doc_id}")
if wait_for_sync_document(driver, github_doc_id):
Expand Down Expand Up @@ -226,21 +242,13 @@ def run_test(browser_config):

def main():
"""Main function to run all browser tests."""
# Browser configurations to test
browsers = [
{
"browser": "Chrome",
"browser_version": "120.0",
"os": "Windows",
"os_version": "11",
},
{
"browser": "Firefox",
"browser_version": "121.0",
"os": "Windows",
"os_version": "11",
},
]
# Load browser configurations from centralized config
config_path = os.path.join(
os.path.dirname(__file__), "..", "browserstack-devices.yml"
)
with open(config_path, "r") as f:
config = yaml.safe_load(f)
browsers = config["javascript-web"]["browsers"]

# Run tests on all browsers
results = []
Expand Down
79 changes: 0 additions & 79 deletions .github/scripts/retry-browserstack.sh

This file was deleted.

Loading
Loading