onnxruntime/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar-test.yml
Caroline Zhu c73e6afa6c
Migrate Android Java E2E tests from App Center to Browserstack (#22117)
### Description
- removed installing AppCenter + pipeline step that runs AppCenter
Espresso tests
- added script for running AppCenter tests

### Motivation and Context
App Center is getting deprecated in the next year + we have upcoming
Android work that depends on working E2E testing.

---------

Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
2024-10-02 15:04:58 -07:00

91 lines
2.7 KiB
YAML

parameters:
- name: artifactName
displayName: Artifact Name
type: string
default: ''
- name: job_name_suffix
displayName: job name
type: string
default: ''
- name: packageName
displayName: Package Name
type: string
default: 'onnxruntime-android'
jobs:
- job: Final_AAR_Testing_Android_${{ parameters.job_name_suffix }}
workspace:
clean: all
pool:
vmImage: 'macOS-13'
variables:
- name: runCodesignValidationInjection
value: false
timeoutInMinutes: 90
dependsOn:
- Android_Java_API_AAR_Packaging_${{ parameters.job_name_suffix }}
steps:
- template: set-version-number-variables-step.yml
- task: DownloadPipelineArtifact@2
displayName: 'Download Final Android AAR'
inputs:
buildType: 'current'
artifactName: '${{parameters.artifactName}}'
targetPath: '$(Build.BinariesDirectory)/final-android-aar'
- task: JavaToolInstaller@0
displayName: Use jdk 17
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- template: use-android-ndk.yml
- template: use-android-emulator.yml
parameters:
create: true
start: true
- script: |
set -e -x
mkdir android_test
cd android_test
cp -av $(Build.SourcesDirectory)/java/src/test/android ./
cd ./android
mkdir -p app/libs
cp $(Build.BinariesDirectory)/final-android-aar/${{parameters.packageName}}-$(OnnxRuntimeVersion).aar app/libs/onnxruntime-android.aar
$(Build.SourcesDirectory)/java/gradlew --no-daemon clean connectedDebugAndroidTest --stacktrace
displayName: Run E2E test using Emulator
workingDirectory: $(Build.BinariesDirectory)
- template: use-android-emulator.yml
parameters:
stop: true
# we run e2e tests on one older device (Pixel 3) and one newer device (Galaxy 23)
- script: |
set -e -x
pip install requests
python $(Build.SourcesDirectory)/tools/python/upload_and_run_browserstack_tests.py \
--test_platform espresso \
--app_apk_path "debug/app-debug.apk" \
--test_apk_path "androidTest/debug/app-debug-androidTest.apk" \
--devices "Samsung Galaxy S23-13.0" "Google Pixel 3-9.0"
displayName: Run E2E tests using Browserstack
workingDirectory: $(Build.BinariesDirectory)/android_test/android/app/build/outputs/apk
timeoutInMinutes: 15
env:
BROWSERSTACK_ID: $(browserstack_username)
BROWSERSTACK_TOKEN: $(browserstack_access_key)
- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()