diff --git a/.github/workflows/android-appcenter.yml b/.github/workflows/android-browserstack.yml similarity index 59% rename from .github/workflows/android-appcenter.yml rename to .github/workflows/android-browserstack.yml index 9d6ea4b..7c7db81 100644 --- a/.github/workflows/android-appcenter.yml +++ b/.github/workflows/android-browserstack.yml @@ -1,4 +1,4 @@ -name: Android AppCenter Tests +name: Android BrowserStack Tests on: workflow_dispatch: @@ -7,14 +7,14 @@ on: paths: - 'binding/android/OctopusTestApp/**' - 'res/audio/**' - - '.github/workflows/android-appcenter.yml' + - '.github/workflows/android-browserstack.yml' pull_request: branches: [ main, 'v[0-9]+.[0-9]+' ] paths: - 'binding/android/OctopusTestApp/**' - 'res/audio/**' - - '.github/workflows/android-appcenter.yml' + - '.github/workflows/android-browserstack.yml' defaults: run: @@ -22,24 +22,23 @@ defaults: 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/* + python-version: '3.10' + - run: + pip3 install requests - - name: Install AppCenter CLI - run: npm install -g appcenter-cli - - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Copy test_resources @@ -64,35 +63,34 @@ jobs: - name: Build androidTest run: ./gradlew assembleAndroidTest - - name: Run tests on AppCenter - run: appcenter test run espresso - --token ${{secrets.APPCENTERAPITOKEN}} - --app "Picovoice/Octopus-Android" - --devices "Picovoice/android-min-max" - --app-path octopus-test-app/build/outputs/apk/debug/octopus-test-app-debug.apk - --test-series "octopus-android" - --locale "en_US" - --build-dir octopus-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 "Octopus-Android" + --devices "android-min-max" + --app_path "octopus-test-app/build/outputs/apk/debug/octopus-test-app-debug.apk" + --test_path "octopus-test-app/build/outputs/apk/androidTest/debug/octopus-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 + - name: set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Copy test_resources @@ -120,13 +118,13 @@ jobs: - name: Build androidTest run: ./gradlew assembleReleaseAndroidTest -DtestBuildType=integ - - name: Run tests on AppCenter - run: appcenter test run espresso - --token ${{secrets.APPCENTERAPITOKEN}} - --app "Picovoice/Octopus-Android" - --devices "Picovoice/android-min-max" - --app-path octopus-test-app/build/outputs/apk/release/octopus-test-app-release.apk - --test-series "octopus-android" - --locale "en_US" - --build-dir octopus-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 "Octopus-Android-Integration" + --devices "android-min-max" + --app_path "octopus-test-app/build/outputs/apk/release/octopus-test-app-release.apk" + --test_path "octopus-test-app/build/outputs/apk/androidTest/release/octopus-test-app-release-androidTest.apk" diff --git a/.github/workflows/android-demos.yml b/.github/workflows/android-demos.yml index 12f47ad..e9ee638 100644 --- a/.github/workflows/android-demos.yml +++ b/.github/workflows/android-demos.yml @@ -25,10 +25,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Build diff --git a/.github/workflows/android-perf.yml b/.github/workflows/android-perf.yml index 360e1d5..580d243 100644 --- a/.github/workflows/android-perf.yml +++ b/.github/workflows/android-perf.yml @@ -22,35 +22,31 @@ defaults: jobs: build: - name: Run Android Speed Tests on AppCenter + name: Run Android Speed Tests on BrowserStack runs-on: ubuntu-latest strategy: matrix: - device: [single-android, 32bit-android] + device: [ android-perf ] include: - - device: single-android + - device: android-perf indexPerformanceThresholdSec: 4.0 searchPerformanceThresholdSec: 0.008 - - device: 32bit-android - indexPerformanceThresholdSec: 14 - searchPerformanceThresholdSec: 0.0048 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/* + python-version: '3.10' + - run: + pip3 install requests - - name: Install AppCenter CLI - run: npm install -g appcenter-cli - - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Copy test_resources @@ -87,13 +83,13 @@ jobs: - name: Build androidTest run: ./gradlew assembleAndroidTest -DtestBuildType=perf - - name: Run tests on AppCenter - run: appcenter test run espresso - --token ${{secrets.APPCENTERAPITOKEN}} - --app "Picovoice/Octopus-Android" - --devices "Picovoice/${{ matrix.device }}" - --app-path octopus-test-app/build/outputs/apk/debug/octopus-test-app-debug.apk - --test-series "octopus-android" - --locale "en_US" - --build-dir octopus-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 "Octopus-Android-Performance" + --devices "${{ matrix.device }}" + --app_path "octopus-test-app/build/outputs/apk/debug/octopus-test-app-debug.apk" + --test_path "octopus-test-app/build/outputs/apk/androidTest/debug/octopus-test-app-debug-androidTest.apk" diff --git a/.github/workflows/ios-appcenter.yml b/.github/workflows/ios-appcenter.yml deleted file mode 100644 index ec1b6bb..0000000 --- a/.github/workflows/ios-appcenter.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: iOS AppCenter Tests - -on: - workflow_dispatch: - push: - branches: [ main ] - paths: - - 'binding/ios/OctopusAppTest/Podfile.lock' - - 'res/audio/**' - - '.github/workflows/ios-appcenter.yml' - - pull_request: - branches: [ main, 'v[0-9]+.[0-9]+' ] - paths: - - 'binding/ios/OctopusAppTest/Podfile.lock' - - 'res/audio/**' - - '.github/workflows/ios-appcenter.yml' - -defaults: - run: - working-directory: binding/ios/OctopusAppTest - -jobs: - build: - name: Run iOS Tests on AppCenter - runs-on: macos-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Node.js LTS - uses: actions/setup-node@v3 - with: - node-version: lts/* - - - name: Install Cocoapods - run: gem install cocoapods - - - name: Install AppCenter CLI - run: npm install -g appcenter-cli - - - name: Make build dir - run: mkdir ddp - - - name: Run Cocoapods - run: pod install - - - name: Inject AccessKey - run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' - OctopusAppTestUITests/OctopusAppTestUITests.swift - - - name: Inject Performance Threshold - run: sed -i '.bak' 's:{PERFORMANCE_THRESHOLD_SEC}:0.1:' - OctopusAppTestUITests/OctopusAppTestUITests.swift - - - name: XCode Build - run: xcrun xcodebuild build-for-testing - -configuration Debug - -workspace OctopusAppTest.xcworkspace - -sdk iphoneos - -scheme OctopusAppTest - -derivedDataPath ddp - CODE_SIGNING_ALLOWED=NO - - # - name: Run Tests on AppCenter - # run: appcenter test run xcuitest - # --token ${{secrets.APPCENTERAPITOKEN}} - # --app "Picovoice/Octopus-iOS" - # --devices "Picovoice/ios-min-max" - # --test-series "octopus-ios" - # --locale "en_US" - # --build-dir ddp/Build/Products/Debug-iphoneos diff --git a/.github/workflows/ios-browserstack.yml b/.github/workflows/ios-browserstack.yml new file mode 100644 index 0000000..882f4a5 --- /dev/null +++ b/.github/workflows/ios-browserstack.yml @@ -0,0 +1,80 @@ +name: iOS BrowserStack Tests + +on: + workflow_dispatch: + push: + branches: [ main ] + paths: + - 'binding/ios/OctopusAppTest/Podfile.lock' + - 'res/audio/**' + - '.github/workflows/ios-browserstack.yml' + + pull_request: + branches: [ main, 'v[0-9]+.[0-9]+' ] + paths: + - 'binding/ios/OctopusAppTest/Podfile.lock' + - 'res/audio/**' + - '.github/workflows/ios-browserstack.yml' + +defaults: + run: + working-directory: binding/ios/OctopusAppTest + +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: Install Cocoapods + run: gem install cocoapods + + - name: Make build dir + run: mkdir ddp + + - name: Run Cocoapods + run: pod install + + - name: Inject AccessKey + run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' + OctopusAppTestUITests/BaseTest.swift + + - name: XCode Build + run: xcrun xcodebuild build-for-testing + -configuration Debug + -workspace OctopusAppTest.xcworkspace + -sdk iphoneos + -scheme OctopusAppTest + -derivedDataPath ddp + CODE_SIGNING_ALLOWED=NO + + - name: Generating ipa + run: cd ddp/Build/Products/Debug-iphoneos/ && + mkdir Payload && + cp -r OctopusAppTest.app Payload && + zip --symlinks -r OctopusAppTest.ipa Payload && + rm -r Payload + + - name: Zipping Tests + run: cd ddp/Build/Products/Debug-iphoneos/ && + zip --symlinks -r OctopusAppTestUITests.zip OctopusAppTestUITests-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 "Octopus-iOS" + --devices "ios-min-max" + --app_path "ddp/Build/Products/Debug-iphoneos/OctopusAppTest.ipa" + --test_path "ddp/Build/Products/Debug-iphoneos/OctopusAppTestUITests.zip" diff --git a/.github/workflows/ios-demos.yml b/.github/workflows/ios-demos.yml index 4bc07f8..f120e40 100644 --- a/.github/workflows/ios-demos.yml +++ b/.github/workflows/ios-demos.yml @@ -33,9 +33,6 @@ jobs: - name: Install Cocoapods run: gem install cocoapods - - name: Install AppCenter CLI - run: npm install -g appcenter-cli - - name: Make build dir run: mkdir ddp diff --git a/.github/workflows/ios-perf.yml b/.github/workflows/ios-perf.yml index c161c85..32c0f4d 100644 --- a/.github/workflows/ios-perf.yml +++ b/.github/workflows/ios-perf.yml @@ -21,7 +21,7 @@ defaults: jobs: build: - name: Run iOS Tests on AppCenter + name: Run iOS Tests on BrowserStack runs-on: macos-latest strategy: @@ -36,17 +36,16 @@ 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/* + python-version: '3.10' + - run: + pip3 install requests - name: Install Cocoapods run: gem install cocoapods - - name: Install AppCenter CLI - run: npm install -g appcenter-cli - - name: Make build dir run: mkdir ddp @@ -61,12 +60,14 @@ jobs: run: sed -i '.bak' 's:{NUM_TEST_ITERATIONS}:30:' PerformanceTest/PerformanceTest.swift - - name: Inject Performance Threshold - run: sed -i '.bak' 's:{INDEX_PERFORMANCE_THRESHOLD_SEC}:${{ matrix.indexPerformanceThresholdSec }}:' + - name: Inject Index Performance Threshold + run: sed -i '.bak' + '1,/{INDEX_PERFORMANCE_THRESHOLD_SEC}/s/{INDEX_PERFORMANCE_THRESHOLD_SEC}/${{ matrix.indexPerformanceThresholdSec }}/' PerformanceTest/PerformanceTest.swift - - name: Inject Performance Threshold - run: sed -i '.bak' 's:{SEARCH_PERFORMANCE_THRESHOLD_SEC}:${{ matrix.searchPerformanceThresholdSec }}:' + - name: Inject Search Performance Threshold + run: sed -i '.bak' + '1,/{SEARCH_PERFORMANCE_THRESHOLD_SEC}/s/{SEARCH_PERFORMANCE_THRESHOLD_SEC}/${{ matrix.searchPerformanceThresholdSec }}/' PerformanceTest/PerformanceTest.swift - name: XCode Build @@ -78,11 +79,23 @@ jobs: -derivedDataPath ddp CODE_SIGNING_ALLOWED=NO - - name: Run Tests on AppCenter - run: appcenter test run xcuitest - --token ${{secrets.APPCENTERAPITOKEN}} - --app "Picovoice/Octopus-iOS" - --devices "Picovoice/${{ matrix.device }}" - --test-series "octopus-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 OctopusAppTest.app Payload && + zip --symlinks -r OctopusAppTest.ipa Payload && + rm -r Payload + + - name: Zipping Tests + run: cd ddp/Build/Products/Debug-iphoneos/ && + zip --symlinks -r PerformanceTest.zip PerformanceTest-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 "Octopus-iOS-Performance" + --devices "${{ matrix.device }}" + --app_path "ddp/Build/Products/Debug-iphoneos/OctopusAppTest.ipa" + --test_path "ddp/Build/Products/Debug-iphoneos/PerformanceTest.zip" diff --git a/binding/android/OctopusTestApp/build.gradle b/binding/android/OctopusTestApp/build.gradle index ebfdad2..45cb544 100644 --- a/binding/android/OctopusTestApp/build.gradle +++ b/binding/android/OctopusTestApp/build.gradle @@ -1,5 +1,5 @@ ext { - defaultTargetSdkVersion = 31 + defaultTargetSdkVersion = 33 } buildscript { @@ -8,7 +8,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:8.2.2' } } @@ -19,6 +19,6 @@ allprojects { } } -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } diff --git a/binding/android/OctopusTestApp/gradle.properties b/binding/android/OctopusTestApp/gradle.properties index c09e1e3..683c3de 100644 --- a/binding/android/OctopusTestApp/gradle.properties +++ b/binding/android/OctopusTestApp/gradle.properties @@ -15,3 +15,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/binding/android/OctopusTestApp/gradle/wrapper/gradle-wrapper.properties b/binding/android/OctopusTestApp/gradle/wrapper/gradle-wrapper.properties index a899caf..667bf66 100644 --- a/binding/android/OctopusTestApp/gradle/wrapper/gradle-wrapper.properties +++ b/binding/android/OctopusTestApp/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed Jul 19 13:57:31 PDT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/binding/android/OctopusTestApp/octopus-test-app/build.gradle b/binding/android/OctopusTestApp/octopus-test-app/build.gradle index b68b338..1f27d4b 100644 --- a/binding/android/OctopusTestApp/octopus-test-app/build.gradle +++ b/binding/android/OctopusTestApp/octopus-test-app/build.gradle @@ -31,7 +31,7 @@ if (rootProject.file("local.properties").exists()) { } android { - compileSdkVersion defaultTargetSdkVersion + compileSdk defaultTargetSdkVersion defaultConfig { applicationId "ai.picovoice.octopus.testapp" @@ -106,6 +106,7 @@ android { lint { abortOnError false } + namespace 'ai.picovoice.octopus.testapp' } dependencies { @@ -119,13 +120,16 @@ 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('androidx.test.espresso:espresso-intents:3.5.1') } afterEvaluate { tasks."mergeDebugAssets".dependsOn "copyParams" tasks."mergeReleaseAssets".dependsOn "copyParams" + tasks."generateReleaseLintVitalReportModel".dependsOn "copyParams" + tasks."lintVitalAnalyzeRelease".dependsOn "copyParams" tasks."mergeDebugAssets".dependsOn "copyAudio" tasks."mergeReleaseAssets".dependsOn "copyAudio" + tasks."generateReleaseLintVitalReportModel".dependsOn "copyAudio" + tasks."lintVitalAnalyzeRelease".dependsOn "copyAudio" } diff --git a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/BaseTest.java b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/BaseTest.java index 02b33eb..f5c8d56 100644 --- a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/BaseTest.java +++ b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/BaseTest.java @@ -5,12 +5,7 @@ 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.Before; -import org.junit.Rule; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -21,8 +16,7 @@ import java.io.OutputStream; class BaseTest { - @Rule - public ReportHelper reportHelper = Factory.getReportHelper(); + Context testContext; Context appContext; AssetManager assetManager; @@ -30,11 +24,6 @@ class BaseTest { String accessKey = ""; - @After - public void TearDown() { - reportHelper.label("Stopping App"); - } - @Before public void Setup() throws IOException { testContext = InstrumentationRegistry.getInstrumentation().getContext(); diff --git a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/IntegrationTest.java b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/IntegrationTest.java index 5b92623..4737b92 100644 --- a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/IntegrationTest.java +++ b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/IntegrationTest.java @@ -16,9 +16,6 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.microsoft.appcenter.espresso.Factory; -import com.microsoft.appcenter.espresso.ReportHelper; - import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; @@ -74,9 +71,6 @@ public void perform(UiController uiController, View view) { @RunWith(AndroidJUnit4.class) public class IntegrationTest { - @Rule - public ReportHelper reportHelper = Factory.getReportHelper(); - @Rule public ActivityScenarioRule activityScenarioRule = new ActivityScenarioRule<>(MainActivity.class); @@ -91,11 +85,6 @@ public void intentsTeardown() { Intents.release(); } - @After - public void TearDown() { - reportHelper.label("Stopping App"); - } - @Test public void testOctopus() { onView(withId(R.id.testButton)).perform(click()); diff --git a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/PerformanceTest.java b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/PerformanceTest.java index 989bc73..f964ed1 100644 --- a/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/PerformanceTest.java +++ b/binding/android/OctopusTestApp/octopus-test-app/src/androidTest/java/ai/picovoice/octopus/testapp/PerformanceTest.java @@ -8,13 +8,8 @@ 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; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,8 +28,7 @@ @RunWith(AndroidJUnit4.class) public class PerformanceTest { - @Rule - public ReportHelper reportHelper = Factory.getReportHelper(); + Context testContext; Context appContext; AssetManager assetManager; @@ -43,11 +37,6 @@ public class PerformanceTest { int numTestIterations = 30; - @After - public void TearDown() { - reportHelper.label("Stopping App"); - } - @Before public void Setup() throws IOException { testContext = InstrumentationRegistry.getInstrumentation().getContext(); diff --git a/binding/android/OctopusTestApp/octopus-test-app/src/main/AndroidManifest.xml b/binding/android/OctopusTestApp/octopus-test-app/src/main/AndroidManifest.xml index 10a6317..6b3a882 100644 --- a/binding/android/OctopusTestApp/octopus-test-app/src/main/AndroidManifest.xml +++ b/binding/android/OctopusTestApp/octopus-test-app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/binding/ios/OctopusAppTest/OctopusAppTest.xcodeproj/project.pbxproj b/binding/ios/OctopusAppTest/OctopusAppTest.xcodeproj/project.pbxproj index 9c07f75..0120893 100644 --- a/binding/ios/OctopusAppTest/OctopusAppTest.xcodeproj/project.pbxproj +++ b/binding/ios/OctopusAppTest/OctopusAppTest.xcodeproj/project.pbxproj @@ -18,7 +18,7 @@ 1E00654627CFF260006FF6E9 /* OctopusAppTestUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0064E827CEEA66006FF6E9 /* OctopusAppTestUITests.swift */; }; 1E5B7B042800D9BE00F8BDDB /* PerformanceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E5B7B032800D9BE00F8BDDB /* PerformanceTest.swift */; }; 1E5B7B072800DD6600F8BDDB /* multiple_keywords.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1E5B7B062800DD6600F8BDDB /* multiple_keywords.wav */; }; - 36696536961DE78B3E1C06FA /* (null) in Frameworks */ = {isa = PBXBuildFile; }; + 36696536961DE78B3E1C06FA /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; C757D8CD28A1C77100F391C8 /* BaseTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C757D8CB28A1C77100F391C8 /* BaseTest.swift */; }; C757D8CE28A1C77100F391C8 /* OctopusLanguageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C757D8CC28A1C77100F391C8 /* OctopusLanguageTests.swift */; }; C757D8D628A1C85200F391C8 /* multiple_keywords_ko.wav in Resources */ = {isa = PBXBuildFile; fileRef = C757D8CF28A1C85100F391C8 /* multiple_keywords_ko.wav */; }; @@ -56,7 +56,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 060C8DEBFFA82E434C42783A /* Pods-OctopusAppTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTest.release.xcconfig"; path = "Target Support Files/Pods-OctopusAppTest/Pods-OctopusAppTest.release.xcconfig"; sourceTree = ""; }; 1E0064C427CEEA65006FF6E9 /* OctopusAppTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OctopusAppTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1E0064C727CEEA65006FF6E9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 1E0064CB27CEEA65006FF6E9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -72,12 +71,13 @@ 1E5B7B032800D9BE00F8BDDB /* PerformanceTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PerformanceTest.swift; sourceTree = ""; }; 1E5B7B052800D9D700F8BDDB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1E5B7B062800DD6600F8BDDB /* multiple_keywords.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = multiple_keywords.wav; path = ../../../../res/audio/multiple_keywords.wav; sourceTree = ""; }; - 3A109F9943E62FDC1E51D722 /* Pods-OctopusAppTestUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTestUITests.debug.xcconfig"; path = "Target Support Files/Pods-OctopusAppTestUITests/Pods-OctopusAppTestUITests.debug.xcconfig"; sourceTree = ""; }; + 3159E42AF97125B3BF92F4E2 /* Pods-OctopusAppTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTest.debug.xcconfig"; path = "Target Support Files/Pods-OctopusAppTest/Pods-OctopusAppTest.debug.xcconfig"; sourceTree = ""; }; 44786E307CC71BBF2D5286B6 /* libPods-PerformanceTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PerformanceTest.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 493470BF19F372CF4D8D103E /* Pods-PerformanceTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PerformanceTest.debug.xcconfig"; path = "Target Support Files/Pods-PerformanceTest/Pods-PerformanceTest.debug.xcconfig"; sourceTree = ""; }; 498BE0F0C0B5145436720B55 /* libPods-OctopusAppTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OctopusAppTest.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 4B652FC67B3D9F1FAF609384 /* libPods-OctopusAppTestUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OctopusAppTestUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 8F8DE7C85EEF4D52669142E7 /* Pods-PerformanceTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PerformanceTest.release.xcconfig"; path = "Target Support Files/Pods-PerformanceTest/Pods-PerformanceTest.release.xcconfig"; sourceTree = ""; }; + 4D2D4D3777C0F0BA199911F2 /* Pods-OctopusAppTestUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTestUITests.debug.xcconfig"; path = "Target Support Files/Pods-OctopusAppTestUITests/Pods-OctopusAppTestUITests.debug.xcconfig"; sourceTree = ""; }; + 7FCC31E53F4723E8437124BC /* Pods-OctopusAppTestUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTestUITests.release.xcconfig"; path = "Target Support Files/Pods-OctopusAppTestUITests/Pods-OctopusAppTestUITests.release.xcconfig"; sourceTree = ""; }; + BEE19B0361C1913B6BC6BAAB /* Pods-PerformanceTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PerformanceTest.release.xcconfig"; path = "Target Support Files/Pods-PerformanceTest/Pods-PerformanceTest.release.xcconfig"; sourceTree = ""; }; C757D8CB28A1C77100F391C8 /* BaseTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTest.swift; sourceTree = ""; }; C757D8CC28A1C77100F391C8 /* OctopusLanguageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OctopusLanguageTests.swift; sourceTree = ""; }; C757D8CF28A1C85100F391C8 /* multiple_keywords_ko.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = multiple_keywords_ko.wav; path = ../../../../res/audio/multiple_keywords_ko.wav; sourceTree = ""; }; @@ -94,8 +94,8 @@ C757D8E128A1D08B00F391C8 /* octopus_params_it.pv */ = {isa = PBXFileReference; lastKnownFileType = file; name = octopus_params_it.pv; path = ../../../../lib/common/param/octopus_params_it.pv; sourceTree = ""; }; C757D8E228A1D08B00F391C8 /* octopus_params_de.pv */ = {isa = PBXFileReference; lastKnownFileType = file; name = octopus_params_de.pv; path = ../../../../lib/common/param/octopus_params_de.pv; sourceTree = ""; }; C757D8E328A1D08B00F391C8 /* octopus_params_fr.pv */ = {isa = PBXFileReference; lastKnownFileType = file; name = octopus_params_fr.pv; path = ../../../../lib/common/param/octopus_params_fr.pv; sourceTree = ""; }; - F4E04511A77E54C10386FB49 /* Pods-OctopusAppTestUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTestUITests.release.xcconfig"; path = "Target Support Files/Pods-OctopusAppTestUITests/Pods-OctopusAppTestUITests.release.xcconfig"; sourceTree = ""; }; - F5AF54842119EA76E7CB3C85 /* Pods-OctopusAppTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTest.debug.xcconfig"; path = "Target Support Files/Pods-OctopusAppTest/Pods-OctopusAppTest.debug.xcconfig"; sourceTree = ""; }; + D0F4BDAB8DCEFACB0DD878B2 /* Pods-OctopusAppTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OctopusAppTest.release.xcconfig"; path = "Target Support Files/Pods-OctopusAppTest/Pods-OctopusAppTest.release.xcconfig"; sourceTree = ""; }; + F596BBCDD422A8A148A60A99 /* Pods-PerformanceTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PerformanceTest.debug.xcconfig"; path = "Target Support Files/Pods-PerformanceTest/Pods-PerformanceTest.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -111,7 +111,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 36696536961DE78B3E1C06FA /* (null) in Frameworks */, + 36696536961DE78B3E1C06FA /* BuildFile in Frameworks */, 16197350434656617777BDDE /* libPods-OctopusAppTestUITests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -134,8 +134,8 @@ 1E0064C627CEEA65006FF6E9 /* OctopusAppTest */, 1E0064E727CEEA66006FF6E9 /* OctopusAppTestUITests */, 1E0064C527CEEA65006FF6E9 /* Products */, - 81D82352532BDF40E30C02E9 /* Pods */, C61A87423E5B220A51E25364 /* Frameworks */, + 3B3C264F62BB7B471FB94F36 /* Pods */, ); sourceTree = ""; }; @@ -198,16 +198,17 @@ path = PerformanceTest; sourceTree = ""; }; - 81D82352532BDF40E30C02E9 /* Pods */ = { + 3B3C264F62BB7B471FB94F36 /* Pods */ = { isa = PBXGroup; children = ( - F5AF54842119EA76E7CB3C85 /* Pods-OctopusAppTest.debug.xcconfig */, - 060C8DEBFFA82E434C42783A /* Pods-OctopusAppTest.release.xcconfig */, - 3A109F9943E62FDC1E51D722 /* Pods-OctopusAppTestUITests.debug.xcconfig */, - F4E04511A77E54C10386FB49 /* Pods-OctopusAppTestUITests.release.xcconfig */, - 493470BF19F372CF4D8D103E /* Pods-PerformanceTest.debug.xcconfig */, - 8F8DE7C85EEF4D52669142E7 /* Pods-PerformanceTest.release.xcconfig */, - ); + 3159E42AF97125B3BF92F4E2 /* Pods-OctopusAppTest.debug.xcconfig */, + D0F4BDAB8DCEFACB0DD878B2 /* Pods-OctopusAppTest.release.xcconfig */, + 4D2D4D3777C0F0BA199911F2 /* Pods-OctopusAppTestUITests.debug.xcconfig */, + 7FCC31E53F4723E8437124BC /* Pods-OctopusAppTestUITests.release.xcconfig */, + F596BBCDD422A8A148A60A99 /* Pods-PerformanceTest.debug.xcconfig */, + BEE19B0361C1913B6BC6BAAB /* Pods-PerformanceTest.release.xcconfig */, + ); + name = Pods; path = Pods; sourceTree = ""; }; @@ -722,7 +723,7 @@ }; 1E0064EF27CEEA66006FF6E9 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F5AF54842119EA76E7CB3C85 /* Pods-OctopusAppTest.debug.xcconfig */; + baseConfigurationReference = 3159E42AF97125B3BF92F4E2 /* Pods-OctopusAppTest.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -752,7 +753,7 @@ }; 1E0064F027CEEA66006FF6E9 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 060C8DEBFFA82E434C42783A /* Pods-OctopusAppTest.release.xcconfig */; + baseConfigurationReference = D0F4BDAB8DCEFACB0DD878B2 /* Pods-OctopusAppTest.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -782,7 +783,7 @@ }; 1E00650627CFEC95006FF6E9 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3A109F9943E62FDC1E51D722 /* Pods-OctopusAppTestUITests.debug.xcconfig */; + baseConfigurationReference = 4D2D4D3777C0F0BA199911F2 /* Pods-OctopusAppTestUITests.debug.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -807,7 +808,7 @@ }; 1E00650727CFEC95006FF6E9 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F4E04511A77E54C10386FB49 /* Pods-OctopusAppTestUITests.release.xcconfig */; + baseConfigurationReference = 7FCC31E53F4723E8437124BC /* Pods-OctopusAppTestUITests.release.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -831,7 +832,7 @@ }; 1E5B7AFF2800D98500F8BDDB /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 493470BF19F372CF4D8D103E /* Pods-PerformanceTest.debug.xcconfig */; + baseConfigurationReference = F596BBCDD422A8A148A60A99 /* Pods-PerformanceTest.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; @@ -858,7 +859,7 @@ }; 1E5B7B002800D98500F8BDDB /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8F8DE7C85EEF4D52669142E7 /* Pods-PerformanceTest.release.xcconfig */; + baseConfigurationReference = BEE19B0361C1913B6BC6BAAB /* Pods-PerformanceTest.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; diff --git a/binding/ios/OctopusAppTest/OctopusAppTestUITests/OctopusLanguageTests.swift b/binding/ios/OctopusAppTest/OctopusAppTestUITests/OctopusLanguageTests.swift index 48c5c55..a50fadc 100644 --- a/binding/ios/OctopusAppTest/OctopusAppTestUITests/OctopusLanguageTests.swift +++ b/binding/ios/OctopusAppTest/OctopusAppTestUITests/OctopusLanguageTests.swift @@ -1,5 +1,5 @@ // -// Copyright 2022 Picovoice Inc. +// Copyright 2022-2024 Picovoice Inc. // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on @@ -28,54 +28,34 @@ class OctopusLanguageTests: BaseTest { ["pt", ["porco espinho": [[0.480, 1.792, 1]]]] ] - var language: String = "" - var modelPath: String = "" - var keywordPaths: [String] = [] - var testAudioPath: String = "" - var expectedResults: [String: [[Double]]] = [:] - - override class var defaultTestSuite: XCTestSuite { - get { - let xcTestSuite = XCTestSuite(name: NSStringFromClass(self)) - let bundle = Bundle(for: self) - - for testCase in testData { - let suffix = (testCase[0]) as! String == "en" ? "" : "_\(testCase[0])" - for invocation in testInvocations { - let newTestCase = OctopusLanguageTests(invocation: invocation) - - newTestCase.language = testCase[0] as! String - newTestCase.modelPath = bundle.path(forResource: "octopus_params\(suffix)", ofType: "pv")! - newTestCase.testAudioPath = bundle.path(forResource: "multiple_keywords\(suffix)", ofType: "wav")! - newTestCase.expectedResults = testCase[1] as! [String: [[Double]]] - xcTestSuite.addTest(newTestCase) - } - } - - return xcTestSuite - } - } - func testWrapper() throws { - - try XCTContext.runActivity(named: "(\(language))") { _ in - let octopus = try Octopus(accessKey: accessKey, modelPath: modelPath) - let metadata = try octopus.indexAudioFile(path: testAudioPath) - let matches = try octopus.search(metadata: metadata, phrases: Set(expectedResults.keys)) - - for (phrase, expectedMatches) in expectedResults { - XCTAssert(matches[phrase]!.count == expectedMatches.count) - - let phraseMatches = matches[phrase]! - for i in 0...phraseMatches.count - 1 { - XCTAssertEqual(phraseMatches[i].startSec, Float(expectedMatches[i][0]), accuracy: 0.01) - XCTAssertEqual(phraseMatches[i].endSec, Float(expectedMatches[i][1]), accuracy: 0.01) - XCTAssertEqual(phraseMatches[i].probability, Float(expectedMatches[i][2]), accuracy: 0.01) + let bundle = Bundle(for: type(of: self)) + + for testCase in OctopusLanguageTests.testData { + let suffix = (testCase[0]) as! String == "en" ? "" : "_\(testCase[0])" + let modelPath = bundle.path(forResource: "octopus_params\(suffix)", ofType: "pv")! + let testAudioPath = bundle.path(forResource: "multiple_keywords\(suffix)", ofType: "wav")! + let expectedResults = testCase[1] as! [String: [[Double]]] + + try XCTContext.runActivity(named: "(\(testCase[0]))") { _ in + let octopus = try Octopus(accessKey: accessKey, modelPath: modelPath) + let metadata = try octopus.indexAudioFile(path: testAudioPath) + let matches = try octopus.search(metadata: metadata, phrases: Set(expectedResults.keys)) + + for (phrase, expectedMatches) in expectedResults { + XCTAssert(matches[phrase]!.count == expectedMatches.count) + + let phraseMatches = matches[phrase]! + for i in 0...phraseMatches.count - 1 { + XCTAssertEqual(phraseMatches[i].startSec, Float(expectedMatches[i][0]), accuracy: 0.01) + XCTAssertEqual(phraseMatches[i].endSec, Float(expectedMatches[i][1]), accuracy: 0.01) + XCTAssertEqual(phraseMatches[i].probability, Float(expectedMatches[i][2]), accuracy: 0.01) + } } - } - metadata.delete() - octopus.delete() + metadata.delete() + octopus.delete() + } } } } diff --git a/binding/ios/OctopusAppTest/Podfile.lock b/binding/ios/OctopusAppTest/Podfile.lock index c889449..1cf72b6 100644 --- a/binding/ios/OctopusAppTest/Podfile.lock +++ b/binding/ios/OctopusAppTest/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 69ef501829b3c0bd33a90dca86df4aca3748b08b -COCOAPODS: 1.11.3 +COCOAPODS: 1.16.2 diff --git a/res/.lint/spell-check/dict.txt b/res/.lint/spell-check/dict.txt index 24f9888..f88e5a9 100644 --- a/res/.lint/spell-check/dict.txt +++ b/res/.lint/spell-check/dict.txt @@ -43,5 +43,6 @@ reindex testapp wargv whitespaces +xcuitest xcworkspace ytdlp \ No newline at end of file diff --git a/script/automation/browserstack.py b/script/automation/browserstack.py new file mode 100644 index 0000000..54c0e77 --- /dev/null +++ b/script/automation/browserstack.py @@ -0,0 +1,136 @@ +import argparse +import requests +import time + +APP_URI = 'https://api-cloud.browserstack.com/app-automate/{}/v2/app' +TEST_URI = 'https://api-cloud.browserstack.com/app-automate/{}/v2/test-suite' +BUILD_URI = 'https://api-cloud.browserstack.com/app-automate/{}/v2/build' +STATUS_URI = 'https://api-cloud.browserstack.com/app-automate/{}/v2/builds/{}' + +devices_dict = { + 'android-min-max': [ + 'Samsung Galaxy S8-7.0', + 'Samsung Galaxy M52-11.0', + 'Google Pixel 9-15.0' + ], + 'android-perf': [ + 'Google Pixel 6 Pro-15.0' + ], + 'ios-min-max': [ + 'iPhone SE 2022-15', + 'iPhone 14 Plus-16', + 'iPhone 14-18' + ], + 'ios-perf': [ + 'iPhone 13-18', + ] +} + + +def main(args: argparse.Namespace) -> None: + app_files = { + 'file': open(args.app_path, 'rb') + } + + app_response = requests.post( + APP_URI.format(args.type), + files=app_files, + auth=(args.username, args.access_key) + ) + app_response_json = app_response.json() + + if not app_response.ok: + print('App Upload Failed', app_response_json) + exit(1) + + test_files = { + 'file': open(args.test_path, 'rb') + } + test_response = requests.post( + TEST_URI.format(args.type), + files=test_files, + auth=(args.username, args.access_key) + ) + test_response_json = test_response.json() + + if not test_response.ok: + print('Test Upload Failed', test_response_json) + exit(1) + + build_headers = { + 'Content-Type': 'application/json' + } + build_data = { + 'app': app_response_json['app_url'], + 'testSuite': test_response_json['test_suite_url'], + 'project': args.project_name, + 'devices': devices_dict[args.devices], + 'deviceLogs': True + } + + while True: + build_response = requests.post( + BUILD_URI.format(args.type), + headers=build_headers, + json=build_data, + auth=(args.username, args.access_key) + ) + if (build_response is not None and 'message' in build_response.json() and '[BROWSERSTACK_ALL_PARALLELS_IN_USE]' + in build_response.json()['message']): + print('Parallel threads limit reached. Waiting...', flush=True) + time.sleep(60) + else: + break + + if build_response is None: + print('Build Failed') + exit(1) + + build_response_json = build_response.json() + + if not build_response.ok: + print('Build Failed', build_response.json()) + exit(1) + + if build_response_json['message'] != 'Success': + print('Build Unsuccessful') + exit(1) + + print( + 'View build results at https://app-automate.browserstack.com/dashboard/v2/builds/{}' + .format(build_response_json['build_id'])) + + while True: + time.sleep(60) + status_response = requests.get( + STATUS_URI.format(args.type, build_response_json['build_id']), + auth=(args.username, args.access_key) + ) + status_response_json = status_response.json() + status = status_response_json['status'] + + if not status_response.ok: + print('Status Request Failed', status_response_json) + exit(1) + + if status != 'queued' and status != 'running': + break + + print('Status:', status) + if status != 'passed': + exit(1) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--type', choices=['espresso', 'xcuitest'], required=True) + parser.add_argument('--username', required=True) + parser.add_argument('--access_key', required=True) + + parser.add_argument('--project_name', required=True) + parser.add_argument('--devices', choices=devices_dict.keys(), required=True) + parser.add_argument('--app_path', required=True) + parser.add_argument('--test_path', required=True) + args = parser.parse_args() + + main(args)