Skip to content

Commit

Permalink
fixup emulator-based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t184256 committed Jun 15, 2024
1 parent f45947d commit 8d15ac9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ on:
- cron: 0 0 * * 1

jobs:
fakedroid-channel:
emulator:
runs-on: ubuntu-latest

strategy:
matrix:
api-level: [29]
way: [flakes, channel]

steps:
- name: Checkout repository
Expand All @@ -26,9 +27,6 @@ jobs:
name: nix-on-droid
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"

- name: Initialize fakedroid for channel setup
run: nix run --impure .#fakedroid -- echo INIT

- name: Configure AVD cache
uses: actions/cache@v4
id: avd-cache
Expand All @@ -48,13 +46,8 @@ jobs:
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run tests
run: |
nix run --impure .#fakedroid -- mkdir -p .cache/nix-on-droid-self-test
nix run --impure .#fakedroid -- touch .cache/nix-on-droid-self-test/confirmation-granted
nix run --impure .#fakedroid -- nix-on-droid on-device-test
- name: Run on-device-tests with api-level=${{ matrix.api-level }}
- name: Test using channels api-level=${{ matrix.api-level }}
if: ${{ matrix.way == 'channel' }}
uses: reactivecircus/android-emulator-runner@v2
with:
target: default
Expand All @@ -66,6 +59,18 @@ jobs:
nix run . -- run on-device-tests.py
popd
- name: Bootstrap using flakes api-level=${{ matrix.api-level }}
if: ${{ matrix.way == 'flakes' }}
uses: reactivecircus/android-emulator-runner@v2
with:
target: default
api-level: ${{ matrix.api-level }}
arch: x86_64
script: |
pushd tests/emulator
nix run . -- run bootstrap-flakes.py
popd
# TODO: push to cachix from device
# - name: Push to cachix
# if: always() && github.event_name != 'pull_request'
Expand Down
1 change: 0 additions & 1 deletion tests/emulator/bootstrap-channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def run(d):

wait_for(d, 'Welcome to Nix-on-Droid!')
wait_for(d, 'Do you want to set it up with flakes? (y/N)')
d('input text N') # remove
d.ui.press('enter')
wait_for(d, 'Setting up Nix-on-Droid with channels...')

Expand Down
28 changes: 28 additions & 0 deletions tests/emulator/bootstrap-flakes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from common import wait_for, APK, BOOTSTRAP_URL


def run(d):
nod = d.app('com.termux.nix', url=APK)
nod.permissions.allow_notifications()
nod.launch()

wait_for(d, 'Bootstrap zipball location')
d.ui(className='android.widget.EditText').set_text(BOOTSTRAP_URL)
d.ui(text='OK').click()

wait_for(d, 'Welcome to Nix-on-Droid!')
wait_for(d, 'Do you want to set it up with flakes? (y/N)')
d('input text y') # remove
d.ui.press('enter')
wait_for(d, 'Setting up Nix-on-Droid with flakes...')

...
wait_for(d, 'Installing first Nix-on-Droid generation...', timeout=180)
wait_for(d, 'Copying default Nix-on-Droid config...', timeout=180)
wait_for(d, 'Congratulations!')
wait_for(d, 'See config file for further information!')
wait_for(d, 'bash-5.25$')

d('input text "echo smoke-test | base64"') # remove
d.ui.press('enter')
wait_for(d, 'c21va2UtdGVzdAo=')

0 comments on commit 8d15ac9

Please sign in to comment.