Skip to content

tests/emulator, .github/workflows/emulator: add #44

tests/emulator, .github/workflows/emulator: add

tests/emulator, .github/workflows/emulator: add #44

Workflow file for this run

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, 34] # lowest working ATM, highest working ATM
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: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Configure AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: 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
script: >
adb shell 'rm -rf /data/local/tmp/n-o-d' &&
adb push n-o-d /data/local/tmp/ &&
adb shell 'cd /data/local/tmp/n-o-d && tar xzof archive.tar.gz && mv n-o-d unpacked' &&
cd tests/emulator &&
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService &&
nix run 'github:t184256/droidctl' -- run ${{ matrix.way }}.py
- 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
# TODO: push to cachix from device
# - name: Push to cachix
# if: always() && github.event_name != 'pull_request'
# run: ...