Skip to content

Commit

Permalink
Introduce action for setting up running Android emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed May 20, 2024
1 parent ba128d5 commit 971c9b8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
38 changes: 38 additions & 0 deletions .github/actions/setup-android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Setup to Run Android Emulator
description: Configures Linux to run the emulator and returns Briefcase args to run emulator.

inputs:
emulator-config:
description: 'Configuration definition of emulator; defaults to {"avd":"beePhone"}.'
required: false
default: '{"avd":"beePhone"}'

outputs:
briefcase-run-args:
value: ${{ steps.briefcase-run-args.outputs.run-args }}
description: "The version or branch of Briefcase that was installed."

runs:
using: composite
steps:

- name: Enable KVM Access
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Briefcase Run Arguemnts for Emulator
id: briefcase-run-args
env:
RUN_ARGS: >
--Xemulator=-no-window
--Xemulator=-no-snapshot
--Xemulator=-no-audio
--Xemulator=-no-boot-anim
--shutdown-on-exit
shell: bash
run: |
echo "run-args=$(printf -- "--device %q %s" '${{ inputs.emulator-config }}' "${RUN_ARGS}")" | tee -a ${GITHUB_OUTPUT}
19 changes: 6 additions & 13 deletions .github/workflows/app-build-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ jobs:
xvfb-run briefcase run linux flatpak
briefcase package linux flatpak --adhoc-sign
- name: Setup Android Emulator
id: emulator-setup
if: startsWith(inputs.runner-os, 'ubuntu')
uses: ./beeware-.github/.github/actions/setup-android

- name: Build Android App
if: >
contains(fromJSON('["", "Android"]'), inputs.target-platform)
Expand All @@ -452,19 +457,7 @@ jobs:
# Only run Android app on Linux since it's duplicative (and slow) on other platforms
if [ "${{ startsWith(inputs.runner-os, 'ubuntu') }}" = "true" ]; then
# allow access to KVM to run the emulator
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
briefcase run android gradle \
--device '{"avd":"beePhone"}' \
--shutdown-on-exit \
--Xemulator=-no-window \
--Xemulator=-no-snapshot \
--Xemulator=-no-audio \
--Xemulator=-no-boot-anim
briefcase run android gradle ${{ steps.emulator-setup.outputs.briefcase-run-args }}
fi
briefcase package android gradle --adhoc-sign
Expand Down

0 comments on commit 971c9b8

Please sign in to comment.