|
1 | 1 | name: Setup Android Emulator |
2 | | -description: Run Android emulator tests using reactivecircus/android-emulator-runner |
| 2 | +description: Download system image, create AVD, and boot Android emulator |
3 | 3 |
|
4 | 4 | inputs: |
5 | 5 | api_level: |
6 | 6 | description: 'Android API level' |
7 | 7 | required: false |
8 | 8 | default: '30' |
9 | | - profile: |
| 9 | + device: |
10 | 10 | description: 'Android device profile' |
11 | 11 | required: false |
12 | 12 | default: 'Nexus 5X' |
13 | | - script: |
14 | | - description: 'Script to run inside the emulator' |
15 | | - required: true |
| 13 | + avd_name: |
| 14 | + description: 'AVD name' |
| 15 | + required: false |
| 16 | + default: 'test_avd' |
16 | 17 |
|
17 | 18 | runs: |
18 | 19 | using: composite |
19 | 20 | steps: |
20 | | - - name: Run tests on Android emulator |
21 | | - uses: reactivecircus/android-emulator-runner@v2 |
22 | | - with: |
23 | | - api-level: ${{ inputs.api_level }} |
24 | | - target: default |
25 | | - arch: arm64-v8a |
26 | | - profile: ${{ inputs.profile }} |
27 | | - script: ${{ inputs.script }} |
| 21 | + - name: Download Android system image |
| 22 | + run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-${{ inputs.api_level }};default;arm64-v8a" |
| 23 | + shell: bash |
| 24 | + |
| 25 | + - name: Create Android emulator |
| 26 | + run: | |
| 27 | + echo "Creating Android emulator..." |
| 28 | + $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n ${{ inputs.avd_name }} --device '${{ inputs.device }}' --package "system-images;android-${{ inputs.api_level }};default;arm64-v8a" --sdcard 512M --force |
| 29 | + shell: bash |
| 30 | + |
| 31 | + - name: Boot Android emulator |
| 32 | + run: | |
| 33 | + echo "Starting Android emulator in background..." |
| 34 | + # ARM64 macOS runners don't support HVF. Use -engine classic to force QEMU TCG software emulation |
| 35 | + $ANDROID_HOME/emulator/emulator -engine classic -avd ${{ inputs.avd_name }} -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim & |
| 36 | + shell: bash |
| 37 | + |
| 38 | + - name: Wait for emulator to boot |
| 39 | + run: | |
| 40 | + echo "Waiting for Android emulator to boot..." |
| 41 | + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' |
| 42 | + echo "Emulator is ready" |
| 43 | + adb devices |
| 44 | + shell: bash |
0 commit comments