Skip to content

Commit

Permalink
try browserstack
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Nov 13, 2024
1 parent 49fb0cb commit 22f0556
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
name: Android AppCenter Tests
name: Android BrowserStack Tests

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'binding/android/CobraTestApp/cobra-test-app/build.gradle'
- '.github/workflows/android-appcenter.yml'
- '.github/workflows/android-browserstack.yml'

pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- 'binding/android/CobraTestApp/cobra-test-app/build.gradle'
- '.github/workflows/android-appcenter.yml'
- '.github/workflows/android-browserstack.yml'

defaults:
run:
working-directory: binding/android/CobraTestApp

jobs:
build:
name: Run Android Tests on AppCenter
name: Run Android Tests on BrowserStack
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
- name: Installing Python
uses: actions/setup-python@v5
with:
node-version: lts/*

- name: Install AppCenter CLI
run: npm install -g appcenter-cli
python-version: '3.10'
- run:
pip3 install requests

- name: set up JDK 11
uses: actions/setup-java@v3
Expand Down Expand Up @@ -62,30 +61,28 @@ jobs:
- name: Build androidTest
run: ./gradlew assembleAndroidTest

- name: Run tests on AppCenter
run: appcenter test run espresso
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Cobra-Android-Activity"
--devices "Picovoice/android-min-max"
--app-path cobra-test-app/build/outputs/apk/debug/cobra-test-app-debug.apk
--test-series "cobra-android"
--locale "en_US"
--build-dir cobra-test-app/build/outputs/apk/androidTest/debug
- name: Run tests on BrowserStack
run: python3 ../../../script/automation/browserstack.py
--type espresso
--username "${{secrets.BROWSERSTACK_USERNAME}}"
--access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}"
--project_name "Cobra-Migration-Test-Android-Build"
--app_path "cobra-test-app/build/outputs/apk/debug/cobra-test-app-debug.apk"
--test_path "cobra-test-app/build/outputs/apk/androidTest/debug/cobra-test-app-debug-androidTest.apk"

build-integ:
name: Run Android Integration Tests on AppCenter
name: Run Android Integration Tests on BrowserStack
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
- name: Installing Python
uses: actions/setup-python@v5
with:
node-version: lts/*

- name: Install AppCenter CLI
run: npm install -g appcenter-cli
python-version: '3.10'
- run:
pip3 install requests

- name: set up JDK 11
uses: actions/setup-java@v3
Expand Down Expand Up @@ -118,12 +115,11 @@ jobs:
- name: Build androidTest
run: ./gradlew assembleReleaseAndroidTest -DtestBuildType=integ

- name: Run tests on AppCenter
run: appcenter test run espresso
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Cobra-Android-Activity"
--devices "Picovoice/android-min-max"
--app-path cobra-test-app/build/outputs/apk/release/cobra-test-app-release.apk
--test-series "cobra-android"
--locale "en_US"
--build-dir cobra-test-app/build/outputs/apk/androidTest/release
- name: Run tests on BrowserStack
run: python3 ../../../script/automation/browserstack.py
--type espresso
--username "${{secrets.BROWSERSTACK_USERNAME}}"
--access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}"
--project_name "Cobra-Migration-Test-Android-Build-Integ"
--app_path "cobra-test-app/build/outputs/apk/release/cobra-test-app-release.apk"
--test_path "cobra-test-app/build/outputs/apk/androidTest/release/cobra-test-app-release-androidTest.apk"
30 changes: 14 additions & 16 deletions .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:

jobs:
build:
name: Run Android Speed Tests on AppCenter
name: Run Android Speed Tests on BrowserStack
runs-on: ubuntu-latest

strategy:
Expand All @@ -34,13 +34,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
- name: Installing Python
uses: actions/setup-python@v5
with:
node-version: lts/*

- name: Install AppCenter CLI
run: npm install -g appcenter-cli
python-version: '3.10'
- run:
pip3 install requests

- name: set up JDK 11
uses: actions/setup-java@v3
Expand Down Expand Up @@ -79,12 +78,11 @@ jobs:
- name: Build androidTest
run: ./gradlew assembleAndroidTest -DtestBuildType=perf

- name: Run tests on AppCenter
run: appcenter test run espresso
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Cobra-Android-Activity"
--devices "Picovoice/${{ matrix.device }}"
--app-path cobra-test-app/build/outputs/apk/debug/cobra-test-app-debug.apk
--test-series "cobra-android"
--locale "en_US"
--build-dir cobra-test-app/build/outputs/apk/androidTest/debug
- name: Run tests on BrowserStack
run: python3 ../../../script/automation/browserstack.py
--type espresso
--username "${{secrets.BROWSERSTACK_USERNAME}}"
--access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}"
--project_name "Cobra-Migration-Test-Android-Perf"
--app_path "cobra-test-app/build/outputs/apk/debug/cobra-test-app-debug.apk"
--test_path "cobra-test-app/build/outputs/apk/androidTest/debug/cobra-test-app-debug-androidTest.apk"
60 changes: 0 additions & 60 deletions .github/workflows/ios-appcenter.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: iOS BrowserStack Tests

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- '.github/workflows/ios-browserstack.yml'

pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- '.github/workflows/ios-browserstack.yml'


defaults:
run:
working-directory: binding/ios/CobraAppTest

jobs:
build:
name: Run iOS Tests on BrowserStack
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Installing Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- run:
pip3 install requests

- name: Make build dir
run: mkdir ddp

- name: Inject AccessKey
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
CobraAppTestUITests/CobraAppTestUITests.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-project CobraAppTest.xcodeproj
-sdk iphoneos
-scheme CobraAppTest
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

- name: Generating ipa
run: cd ddp/Build/Products/Debug-iphoneos/ &&
mkdir Payload &&
cp -r CobraAppTest.app Payload &&
zip --symlinks -r CobraAppTest.ipa Payload &&
rm -r Payload

- name: Zipping Tests
run: cd ddp/Build/Products/Debug-iphoneos/ &&
zip --symlinks -r CobraAppTestUITests.zip CobraAppTestUITests-Runner.app

- name: Run tests on BrowserStack
run: python3 ../../../script/automation/browserstack.py
--type xcuitest
--username "${{secrets.BROWSERSTACK_USERNAME}}"
--access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}"
--project_name "Cobra-Migration-Test-iOS"
--app_path "ddp/Build/Products/Debug-iphoneos/CobraAppTest.ipa"
--test_path "ddp/Build/Products/Debug-iphoneos/CobraAppTestUITests.zip"
40 changes: 25 additions & 15 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:

jobs:
build:
name: Run iOS Tests on AppCenter
name: Run iOS Tests on BrowserStack
runs-on: macos-latest

strategy:
Expand All @@ -33,13 +33,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
- name: Installing Python
uses: actions/setup-python@v5
with:
node-version: lts/*

- name: Install AppCenter CLI
run: npm install -g appcenter-cli
python-version: '3.10'
- run:
pip3 install requests

- name: Make build dir
run: mkdir ddp
Expand All @@ -65,11 +64,22 @@ jobs:
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO

- name: Run Tests on AppCenter
run: appcenter test run xcuitest
--token ${{secrets.APPCENTERAPITOKEN}}
--app "Picovoice/Cobra-iOS"
--devices "Picovoice/${{ matrix.device }}"
--test-series "cobra-ios"
--locale "en_US"
--build-dir ddp/Build/Products/Debug-iphoneos
- name: Generating ipa
run: cd ddp/Build/Products/Debug-iphoneos/ &&
mkdir Payload &&
cp -r CobraAppTest.app Payload &&
zip --symlinks -r CobraAppTest.ipa Payload &&
rm -r Payload

- name: Zipping Tests
run: cd ddp/Build/Products/Debug-iphoneos/ &&
zip --symlinks -r CobraAppTestUITests.zip CobraAppTestUITests-Runner.app

- name: Run tests on BrowserStack
run: python3 ../../../script/automation/browserstack.py
--type xcuitest
--username "${{secrets.BROWSERSTACK_USERNAME}}"
--access_key "${{secrets.BROWSERSTACK_ACCESS_KEY}}"
--project_name "Cobra-Migration-Test-iOS-Perf"
--app_path "ddp/Build/Products/Debug-iphoneos/CobraAppTest.ipa"
--test_path "ddp/Build/Products/Debug-iphoneos/CobraAppTestUITests.zip"
2 changes: 1 addition & 1 deletion binding/android/CobraTestApp/cobra-test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('com.microsoft.appcenter:espresso-test-extension:1.4')
androidTestImplementation('com.browserstack.automate:espresso:1.0.0')
androidTestImplementation('androidx.test.espresso:espresso-intents:3.5.1')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import com.microsoft.appcenter.espresso.Factory;
import com.microsoft.appcenter.espresso.ReportHelper;

import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
Expand Down Expand Up @@ -49,19 +46,13 @@
public class CobraTest {

@Rule
public ReportHelper reportHelper = Factory.getReportHelper();
Context testContext;
Context appContext;
AssetManager assetManager;
String testResourcesPath;

String accessKey = "";

@After
public void TearDown() {
reportHelper.label("Stopping App");
}

@Before
public void Setup() throws IOException {
testContext = InstrumentationRegistry.getInstrumentation().getContext();
Expand Down
Loading

0 comments on commit 22f0556

Please sign in to comment.