Skip to content

Commit

Permalink
feat(actions): Launch Android emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon Nys committed Aug 25, 2023
1 parent db6da71 commit 18796f4
Show file tree
Hide file tree
Showing 43 changed files with 41,590 additions and 1,714 deletions.
48 changes: 8 additions & 40 deletions .github/composite_actions/launch_android_emulator/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,17 @@ name: Launch Android emulator
description: Launches an Android emulator and caches it for further action runs
inputs:
api-level:
description: The Android API level
description: "API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10"
default: "33"
target:
description: The Android image type
description: "target of the system image - default, google_apis, google_apis_playstore, aosp_atd, google_atd, android-wear, android-wear-cn, android-tv or google-tv"
default: google_apis
arch:
description: The CPU architecture
default: x86_64
abi:
description: "ABI of the Android system image - x86, x86_64 or arm64-v8a. Defaults to the host architecture."
# TODO(dnys1): Can this be removed so we can use a separate step?
script:
description: The script to run once the emulator is booted
required: true

description: The script to run once the emulator is booted.
runs:
using: "composite"
steps:
- name: Cache AVD
id: avd-cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ inputs.api-level }}-${{ inputs.arch }}-${{ inputs.target }}

- name: Create AVD and generate snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # 2.27.0
with:
api-level: ${{ inputs.api-level }}
target: ${{ inputs.target }}
arch: ${{ inputs.arch }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -logcat '*:e *:s'
script: echo "Generated AVD snapshot for caching."

- name: Launch AVD
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # 2.27.0
with:
api-level: ${{ inputs.api-level }}
target: ${{ inputs.target }}
arch: ${{ inputs.arch }}
# -no-snapshot-save + default options: https://github.com/reactivecircus/android-emulator-runner#configurations
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -logcat '*:e *:s'
# set screen timeout to 1 hour
script: |
adb shell settings put system screen_off_timeout 3600000
${{ inputs.script }}
using: "node16"
main: "dist/index.mjs"
Loading

0 comments on commit 18796f4

Please sign in to comment.