Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce action for setting up running Android emulator #133

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/actions/setup-android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Setup to Run Android Emulator
description: Configures Linux for KVM access and returns Briefcase args to run the Android 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 briefcase arguments to use with `briefcase run android`."

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 Arguments 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: |
DEVICE_CONFIG=$(printf -- "--device %q" '${{ inputs.emulator-config }}')
echo "run-args=${DEVICE_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
Loading