mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-18 21:21:17 +00:00
### Description Combining android build and test step into one job ### Motivation and Context Reduce runtime by removing additional machine allocation, and artifact uploading and downloading. --------- Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
83 lines
2.8 KiB
YAML
83 lines
2.8 KiB
YAML
# Android Emulator helpers
|
|
|
|
parameters:
|
|
- name: create
|
|
type: boolean
|
|
default: false
|
|
|
|
- name: start
|
|
type: boolean
|
|
default: false
|
|
|
|
- name: stop
|
|
type: boolean
|
|
default: false
|
|
|
|
steps:
|
|
- ${{ if eq(parameters.create, true) }}:
|
|
- script: |
|
|
if [[ ":$PATH:" == *":${ANDROID_SDK_ROOT}/emulator:"* ]]; then
|
|
echo "${ANDROID_SDK_ROOT}/emulator is in PATH"
|
|
else
|
|
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "emulator"
|
|
echo "##vso[task.prependpath]${ANDROID_SDK_ROOT}/emulator"
|
|
fi
|
|
displayName: Check if emulator are installed and add to PATH
|
|
|
|
- script: |
|
|
if [[ ":$PATH:" == *":${ANDROID_SDK_ROOT}/platform-tools:"* ]]; then
|
|
echo "${ANDROID_SDK_ROOT}/platform-tools is in PATH"
|
|
else
|
|
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "platform-tools"
|
|
echo "##vso[task.prependpath]${ANDROID_SDK_ROOT}/platform-tools"
|
|
fi
|
|
ls -R ${ANDROID_SDK_ROOT}/platform-tools
|
|
displayName: Check if platform tools are installed and add to PATH
|
|
|
|
- script: |
|
|
set -e -x
|
|
python3 tools/python/run_android_emulator.py \
|
|
--android-sdk-root $(ANDROID_SDK_ROOT) \
|
|
--create-avd --system-image "system-images;android-31;default;x86_64"
|
|
displayName: Create Android Emulator
|
|
|
|
- ${{ if eq(parameters.start, true) }}:
|
|
- script: |
|
|
if test -f $(Build.BinariesDirectory)/emulator.pid; then
|
|
echo "Emulator PID file was not expected to exist but does and has pid:" \
|
|
`cat $(Build.BinariesDirectory)/emulator.pid`
|
|
exit 1
|
|
fi
|
|
displayName: Check emulator.pid does not exist
|
|
|
|
# Add -verbose to --emulator-extra-args to enable additional logging.
|
|
- script: |
|
|
set -e -x
|
|
python3 tools/python/run_android_emulator.py \
|
|
--android-sdk-root $(ANDROID_SDK_ROOT) \
|
|
--start --emulator-extra-args="-partition-size 2047" \
|
|
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
|
|
echo "Emulator PID:"`cat $(Build.BinariesDirectory)/emulator.pid`
|
|
displayName: Start Android Emulator
|
|
|
|
- ${{ if eq(parameters.stop, true) }}:
|
|
- script: |
|
|
set -e -x
|
|
python3 -m pip install psutil
|
|
displayName: Install psutil for emulator shutdown by run_android_emulator.py
|
|
condition: always()
|
|
|
|
- script: |
|
|
set -e -x
|
|
if test -f $(Build.BinariesDirectory)/emulator.pid; then
|
|
echo "Emulator PID:"`cat $(Build.BinariesDirectory)/emulator.pid`
|
|
python3 tools/python/run_android_emulator.py \
|
|
--android-sdk-root $(ANDROID_SDK_ROOT) \
|
|
--stop \
|
|
--emulator-pid-file $(Build.BinariesDirectory)/emulator.pid
|
|
rm $(Build.BinariesDirectory)/emulator.pid
|
|
else
|
|
echo "Emulator PID file was expected to exist but does not."
|
|
fi
|
|
displayName: Stop Android Emulator
|
|
condition: always()
|