|
| 1 | +name: Emulator tests |
| 2 | + |
| 3 | +# The OS-emulator layer of the device suite (tests/device/): real Chrome and |
| 4 | +# real Gboard on an Android emulator, and real iOS Safari on a simulator via |
| 5 | +# Appium/XCUITest — driving flows no browser emulation can, including pressing |
| 6 | +# the on-screen keyboard's IME action key. Free minutes, no credentials, so it |
| 7 | +# runs as normal CI. See tests/device/README.md. |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + pull_request: |
| 13 | + types: [opened, synchronize, reopened] |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: emulator-tests-${{ github.ref }} |
| 18 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +env: |
| 24 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + android-emulator: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 45 |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 32 | + with: |
| 33 | + persist-credentials: false |
| 34 | + |
| 35 | + - uses: voidzero-dev/setup-vp@313600b80b104eadebb9111787d37a2e83e014ca # v1.17.0 |
| 36 | + with: |
| 37 | + node-version-file: ".node-version" |
| 38 | + cache: true |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: vp install |
| 42 | + |
| 43 | + - name: Enable KVM group perms |
| 44 | + run: | |
| 45 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 46 | + sudo udevadm control --reload-rules |
| 47 | + sudo udevadm trigger --name-match=kvm |
| 48 | +
|
| 49 | + - name: Start playground dev server |
| 50 | + run: | |
| 51 | + vp run dev & |
| 52 | + for _ in $(seq 1 120); do |
| 53 | + if curl -sf http://127.0.0.1:5173/ > /dev/null; then exit 0; fi |
| 54 | + sleep 2 |
| 55 | + done |
| 56 | + echo "playground dev server never came up" >&2 |
| 57 | + exit 1 |
| 58 | +
|
| 59 | + - name: Run device suite on the emulator |
| 60 | + uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 |
| 61 | + with: |
| 62 | + api-level: 35 |
| 63 | + arch: x86_64 |
| 64 | + target: google_apis |
| 65 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -no-audio -no-boot-anim |
| 66 | + disable-animations: true |
| 67 | + script: DEVICE_FILTER=local-android vp run test:device |
| 68 | + |
| 69 | + - name: Upload screenshots |
| 70 | + if: always() |
| 71 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 72 | + with: |
| 73 | + name: emulator-test-screenshots |
| 74 | + path: tests/device/.artifacts/ |
| 75 | + if-no-files-found: ignore |
| 76 | + |
| 77 | + ios-simulator: |
| 78 | + runs-on: macos-15 |
| 79 | + timeout-minutes: 45 |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 82 | + with: |
| 83 | + persist-credentials: false |
| 84 | + |
| 85 | + - uses: voidzero-dev/setup-vp@313600b80b104eadebb9111787d37a2e83e014ca # v1.17.0 |
| 86 | + with: |
| 87 | + node-version-file: ".node-version" |
| 88 | + cache: true |
| 89 | + |
| 90 | + - name: Install dependencies |
| 91 | + run: vp install |
| 92 | + |
| 93 | + - name: Start playground dev server |
| 94 | + run: | |
| 95 | + vp run dev & |
| 96 | + for _ in $(seq 1 120); do |
| 97 | + if curl -sf http://127.0.0.1:5173/ > /dev/null; then exit 0; fi |
| 98 | + sleep 2 |
| 99 | + done |
| 100 | + echo "playground dev server never came up" >&2 |
| 101 | + exit 1 |
| 102 | +
|
| 103 | + # A cold xcrun on a fresh runner can take long enough to trip the |
| 104 | + # suite's availability probe; the first invocation pays the |
| 105 | + # initialization cost here, visibly. |
| 106 | + - name: Warm the simulator toolchain |
| 107 | + run: xcrun simctl list devices available |
| 108 | + |
| 109 | + - name: Run device suite on the simulator |
| 110 | + run: DEVICE_FILTER=local-ios vp run test:device |
| 111 | + |
| 112 | + - name: Upload screenshots |
| 113 | + if: always() |
| 114 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 115 | + with: |
| 116 | + name: simulator-test-screenshots |
| 117 | + path: tests/device/.artifacts/ |
| 118 | + if-no-files-found: ignore |
0 commit comments