Tap e2e test #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Android e2e | |
| on: | |
| pull_request: | |
| paths: | |
| - .argent/flows/* | |
| - .github/workflows/android-e2e.yml | |
| - packages/react-native-gesture-handler/android/** | |
| - apps/expo-example/android/** | |
| - apps/expo-example/package.json | |
| - rnrepo.config.json | |
| - yarn.lock | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| if: github.repository == 'software-mansion/react-native-gesture-handler' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| concurrency: | |
| group: android-e2e-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Pin the emulator "discovery directory" for BOTH the emulator (launched by | |
| # the action) and the simulator-server backend (spawned by the tool-server | |
| # inside the action's script). The Android touch/key backend finds the | |
| # running emulator's gRPC console by scanning $XDG_RUNTIME_DIR/avd/running/ | |
| # pid_*.ini for grpc.port/grpc.token. XDG_RUNTIME_DIR is unset on GitHub | |
| # runners and /run/user/$UID doesn't exist for the runner user, so the | |
| # emulator and the backend can otherwise resolve DIFFERENT fallback dirs — | |
| # the backend then logs "Failed to find any running emulator" and exits | |
| # before becoming ready. Pinning it (checked first by both) removes that | |
| # divergence. Job-level env reaches every step, including the emulator | |
| # subprocess the action spawns. | |
| env: | |
| XDG_RUNTIME_DIR: /tmp/xdg-runtime | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| - name: Use Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: oracle | |
| java-version: 17 | |
| - name: Use Node.js 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: yarn | |
| - name: Install node dependencies | |
| working-directory: apps/expo-example | |
| run: yarn install --immutable | |
| - name: Build app in Release mode | |
| working-directory: apps/expo-example/android | |
| run: ./gradlew :app:assembleRelease --console=plain -PreactNativeArchitectures=x86_64 | |
| - name: Install Argent | |
| run: npx @swmansion/argent init --yes | |
| - name: Enable KVM | |
| 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 | |
| # Must exist BEFORE the emulator boots: the emulator falls back to another | |
| # dir if XDG_RUNTIME_DIR points at a missing path. 0700 per the XDG spec. | |
| - name: Prepare shared XDG_RUNTIME_DIR | |
| run: | | |
| mkdir -p "$XDG_RUNTIME_DIR" | |
| chmod 700 "$XDG_RUNTIME_DIR" | |
| - name: Set up emulator and run tap E2E test | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 34 | |
| target: google_apis | |
| arch: x86_64 | |
| force-avd-creation: false | |
| # `-grpc 8554` guarantees grpc.port is written to the discovery ini | |
| # (token-less is fine — the backend handles a missing grpc.token). | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -grpc 8554 -camera-back none | |
| disable-animations: true | |
| # android-emulator-runner runs each line of `script` as a separate | |
| # `sh -c`, so exported vars don't persist between lines and multi-line | |
| # constructs (if/fi) break. Keep every command self-contained on one | |
| # line and pass ARGENT_TOOLS_URL inline. | |
| # | |
| # Start the tool-server HERE (not in an earlier step) so the | |
| # simulator-server it spawns inherits this action's HOME, adb, and SDK | |
| # env. That backend discovers the emulator's gRPC endpoint from | |
| # $XDG_RUNTIME_DIR/avd/running/*.ini (pinned at job level) and shells | |
| # out to adb, so it must share the emulator's exact environment. | |
| # Backgrounded with our own readiness poll to dodge flow-run's hard | |
| # ~15s in-process startup timeout; the process persists after its | |
| # launching `sh -c` exits. SIMSERVER_LOG=debug makes the backend's | |
| # discovery/connect steps visible in argent-server.log (drop once green). | |
| script: | | |
| nohup env SIMSERVER_LOG=debug argent server start --detach --no-auth --port 3001 > "$GITHUB_WORKSPACE/argent-server.log" 2>&1 & | |
| for i in $(seq 1 60); do curl -fsS http://127.0.0.1:3001/tools >/dev/null 2>&1 && break; sleep 2; done | |
| adb install -r "$(find "$GITHUB_WORKSPACE/apps/expo-example/android/app/build/outputs/apk/release" -name '*.apk' | head -1)" | |
| ARGENT_TOOLS_URL=http://127.0.0.1:3001 argent flow run simple-tap-test --device "$(adb devices | awk 'NR>1 && $2=="device"{print $1; exit}')" | |
| # The simulator-server's stderr (prefixed `[sim <udid>]`) is written to the | |
| # tool-server log — this is where a "simulator-server exited before ready" | |
| # crash reason shows up. Always print it so failures are diagnosable. | |
| - name: Print Argent tool-server log | |
| if: always() | |
| run: cat argent-server.log 2>/dev/null || echo "no argent-server.log" |