mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
tests/emulator, .github/workflows/emulator: add
This commit is contained in:
parent
d72ab2a167
commit
291970c4c4
9 changed files with 374 additions and 0 deletions
100
.github/workflows/emulator.yml
vendored
Normal file
100
.github/workflows/emulator.yml
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
name: Test nix-on-droid in an emulator
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
schedule:
|
||||
- cron: 0 0 * * 1
|
||||
|
||||
jobs:
|
||||
emulate:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
api-level: [29]
|
||||
# below 28: didn't start, IDK why
|
||||
# 34: sometimes work, but doesn't seem stable, even w/o caching images
|
||||
way:
|
||||
- bootstrap_flakes
|
||||
- bootstrap_channels
|
||||
- poke_around
|
||||
- test_channels_uiautomator
|
||||
- test_channels_shell
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Nix / enable KVM
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: Setup cachix
|
||||
uses: cachix/cachix-action@v14
|
||||
with:
|
||||
name: nix-on-droid
|
||||
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
|
||||
|
||||
- name: Build droidctl
|
||||
run: nix build 'github:t184256/droidctl' --out-link droidctl
|
||||
|
||||
- name: Build zipball, channel tarball and flake to inject
|
||||
run: |
|
||||
rm -rf n-o-d
|
||||
mkdir -p n-o-d
|
||||
git -C . archive --format=tar.gz --prefix n-o-d/ HEAD > n-o-d/archive.tar.gz
|
||||
ARCHES=x86_64 nix run '.#deploy' -- file:///data/local/tmp/n-o-d/archive.tar.gz n-o-d/
|
||||
|
||||
- name: Configure AVD cache
|
||||
if: matrix.api-level == 29
|
||||
uses: actions/cache@v4
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}-${{ matrix.way }} # concurrent save
|
||||
|
||||
- name: Create AVD and generate snapshot for caching
|
||||
if: matrix.api-level == 29 && steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
target: default
|
||||
arch: x86_64
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: false
|
||||
script: echo "Generated AVD snapshot for caching."
|
||||
|
||||
- name: Test way=${{ matrix.way}} api-level=${{ matrix.api-level }}
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
target: default
|
||||
arch: x86_64
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: true
|
||||
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
|
||||
script: >
|
||||
trap 'pkill --exact --echo --signal SIGKILL crashpad_handle || true' EXIT &&
|
||||
adb shell 'rm -rf /data/local/tmp/n-o-d' &&
|
||||
adb push n-o-d /data/local/tmp/ &&
|
||||
echo 'pushed' &&
|
||||
adb shell 'cd /data/local/tmp/n-o-d && tar xzof archive.tar.gz && mv n-o-d unpacked' &&
|
||||
echo 'unpacked' &&
|
||||
cd tests/emulator &&
|
||||
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService &&
|
||||
echo 'ready' &&
|
||||
nix run 'github:t184256/droidctl' -- run ${{ matrix.way }}.py
|
||||
# TODO: push to cachix from within the emulator
|
||||
|
||||
- name: Upload screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: screenshots-${{ matrix.way }}-${{ matrix.api-level }}
|
||||
path: tests/emulator/screenshots
|
||||
if-no-files-found: warn # 'error' or 'ignore' are also available
|
||||
Loading…
Add table
Add a link
Reference in a new issue