Skip to content

Commit c25390a

Browse files
committed
Introduce action for setting up running Android emulator
1 parent ba128d5 commit c25390a

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup to Run Android Emulator
2+
description: Configures Linux to run the emulator and returns Briefcase args to run emulator.
3+
4+
inputs:
5+
emulator-config:
6+
description: 'Configuration definition of emulator; defaults to {"avd":"beePhone"}.'
7+
required: false
8+
default: '{"avd":"beePhone"}'
9+
10+
outputs:
11+
briefcase-run-args:
12+
value: ${{ steps.briefcase-run-args.outputs.run-args }}
13+
description: "The version or branch of Briefcase that was installed."
14+
15+
runs:
16+
using: composite
17+
steps:
18+
19+
- name: Enable KVM Access
20+
shell: bash
21+
run: |
22+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
23+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
24+
sudo udevadm control --reload-rules
25+
sudo udevadm trigger --name-match=kvm
26+
27+
- name: Briefcase Run Arguments for Emulator
28+
id: briefcase-run-args
29+
env:
30+
RUN_ARGS: >
31+
--Xemulator=-no-window
32+
--Xemulator=-no-snapshot
33+
--Xemulator=-no-audio
34+
--Xemulator=-no-boot-anim
35+
--shutdown-on-exit
36+
shell: bash
37+
run: |
38+
echo "run-args=$(printf -- "--device %q %s" '${{ inputs.emulator-config }}' "${RUN_ARGS}")" | tee -a ${GITHUB_OUTPUT}

.github/workflows/app-build-verify.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ jobs:
437437
xvfb-run briefcase run linux flatpak
438438
briefcase package linux flatpak --adhoc-sign
439439
440+
- name: Setup Android Emulator
441+
id: emulator-setup
442+
if: startsWith(inputs.runner-os, 'ubuntu')
443+
uses: ./beeware-.github/.github/actions/setup-android
444+
440445
- name: Build Android App
441446
if: >
442447
contains(fromJSON('["", "Android"]'), inputs.target-platform)
@@ -452,19 +457,7 @@ jobs:
452457
453458
# Only run Android app on Linux since it's duplicative (and slow) on other platforms
454459
if [ "${{ startsWith(inputs.runner-os, 'ubuntu') }}" = "true" ]; then
455-
# allow access to KVM to run the emulator
456-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
457-
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
458-
sudo udevadm control --reload-rules
459-
sudo udevadm trigger --name-match=kvm
460-
461-
briefcase run android gradle \
462-
--device '{"avd":"beePhone"}' \
463-
--shutdown-on-exit \
464-
--Xemulator=-no-window \
465-
--Xemulator=-no-snapshot \
466-
--Xemulator=-no-audio \
467-
--Xemulator=-no-boot-anim
460+
briefcase run android gradle ${{ steps.emulator-setup.outputs.briefcase-run-args }}
468461
fi
469462
470463
briefcase package android gradle --adhoc-sign

0 commit comments

Comments
 (0)