Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .argent/flows/simple-long-press-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
steps:
- echo: Launching Expo Example
- launch: com.example.ExpoExample
- await: { visible: { text: "Empty Example" }, timeout: 15000 }
- echo: "On the Home list, search for long press example"
- type: { text: "long", into: { id: "search-examples" }, submit: false }
- echo: "Tap the example to open it"
- tap: "Basic LongPress"
- echo: "Clear console"
- await: { visible: "open-console-button" }
- wait: 1000 # TODO: replace with wait: idle once released
- tap: "open-console-button"
- await: { visible: "clear-console-button" }
- tap: "clear-console-button"
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- echo: "Long press the box and check if long press count is updated"
- await: { visible: "Long press count: 0" }
- assert: { visible: "long-press-box" }
- long-press: "long-press-box"
- assert: { visible: "Long press count: 1" }
- echo: "Check if console logs are printed in order"
- tap: "open-console-button"
- await: { visible: "close-console-button" }
- assert: { visible: "1. onBegin" }
- assert: { visible: "2. onActivate" }
- assert: { visible: "3. onDeactivate" }
- assert: { visible: "4. onFinalize" }
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- await: { visible: "Long press count: 1" }
- echo: "Long press the box again and check if long press count is updated"
- long-press: "long-press-box"
- assert: { visible: "Long press count: 2" }
- echo: "Clear console"
- await: { visible: "open-console-button" }
- tap: "open-console-button"
- await: { visible: "clear-console-button" }
- tap: "clear-console-button"
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- echo: "Tap the box and check if long press count is not updated"
- tap: "long-press-box"
- assert: { visible: "Long press count: 2" }
- echo: "Check if console logs are printed in order"
- tap: "open-console-button"
- await: { visible: "close-console-button" }
- assert: { visible: "9. onBegin" }
- assert: { visible: "10. onFinalize" }
49 changes: 49 additions & 0 deletions .argent/flows/simple-tap-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
steps:
- echo: Launching Expo Example
- launch: com.example.ExpoExample
- await: { visible: { text: "Empty Example" }, timeout: 15000 }
- echo: "On the Home list, search for tap example"
- type: { text: "tap", into: { id: "search-examples" }, submit: false }
- echo: "Tap the example to open it"
- tap: "Basic Tap"
- echo: "Clear console"
- await: { visible: "open-console-button" }
- wait: 1000 # TODO: replace with wait: idle once released
- tap: "open-console-button"
- await: { visible: "clear-console-button" }
- tap: "clear-console-button"
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- echo: "Tap the box and check if tap count is updated"
- await: { visible: "Tap count: 0" }
- assert: { visible: "tap-box" }
- tap: "tap-box"
- assert: { visible: "Tap count: 1" }
- echo: "Check if console logs are printed in order"
- tap: "open-console-button"
- await: { visible: "close-console-button" }
- assert: { visible: "1. onBegin" }
- assert: { visible: "2. onActivate" }
- assert: { visible: "3. onDeactivate" }
- assert: { visible: "4. onFinalize" }
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- await: { visible: "Tap count: 1" }
- echo: "Tap the box again and check if tap count is updated"
- tap: "tap-box"
- assert: { visible: "Tap count: 2" }
- echo: "Clear console"
- await: { visible: "open-console-button" }
- tap: "open-console-button"
- await: { visible: "clear-console-button" }
- tap: "clear-console-button"
- tap: "close-console-button"
- wait: 1000 # TODO: replace with wait: idle once released
- echo: "Long press the box and check if tap count is not updated"
- long-press: "tap-box"
- assert: { visible: "Tap count: 2" }
- echo: "Check if console logs are printed in order"
- tap: "open-console-button"
- await: { visible: "close-console-button" }
- assert: { visible: "9. onBegin" }
- assert: { visible: "10. onFinalize" }
68 changes: 68 additions & 0 deletions .github/actions/argent-server/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Start Argent tool-server
description: >-
Installs the Argent CLI and starts a tool-server for later steps and
ARGENT_SERVER_LOG for the caller to print on failure.

inputs:
port:
description: Port to serve the tool-server on.
required: false
default: '3001'
simulator-server-log:
description: >-
SIMSERVER_LOG level for the simulator-server backend the tool-server
spawns, e.g. `debug`. Left unset when empty.
required: false
default: ''

runs:
using: composite
steps:
- name: Install Argent
shell: bash
run: npx @swmansion/argent@0.20 init --yes

# Start the server here and export its URL, so `flow run` reuses it instead
# of starting one in-process, which has to come up within a fixed window a
# cold runner can miss — the first run downloads the simulator-server binary.
#
# Not `--detach`: it gives the server a hard 15s to come up and then kills
# its whole process group, and backgrounding the CLI does not help because
# the timeout lives in the process we backgrounded. In the foreground there
# is no deadline and the server's own output lands in our log.
- name: Start tool-server
shell: bash
env:
TOOL_SERVER_PORT: ${{ inputs.port }}
SIMULATOR_SERVER_LOG: ${{ inputs.simulator-server-log }}
run: |
LOG="$RUNNER_TEMP/argent-server.log"
# Exported before anything can fail, so the caller's log-printing step
# can find it even when startup is what went wrong.
echo "ARGENT_SERVER_LOG=$LOG" >> "$GITHUB_ENV"

if [ -n "$SIMULATOR_SERVER_LOG" ]; then
export SIMSERVER_LOG="$SIMULATOR_SERVER_LOG"
fi

nohup argent server start --no-auth --port "$TOOL_SERVER_PORT" > "$LOG" 2>&1 &
SERVER_PID=$!

echo "Waiting for Argent tool-server on :$TOOL_SERVER_PORT..."
# 3 min budget. Poll liveness too, so a server that dies on startup
# fails right away with its log instead of at the end of the budget.
for _ in $(seq 1 90); do
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo "Argent tool-server exited during startup" >&2
cat "$LOG" >&2
exit 1
fi
if curl -fsS "http://127.0.0.1:$TOOL_SERVER_PORT/tools" >/dev/null 2>&1; then
echo "tool-server is ready"
exit 0
fi
sleep 2
done
echo "Argent tool-server failed to become ready in time" >&2
cat "$LOG" >&2
exit 1
161 changes: 161 additions & 0 deletions .github/workflows/android-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Run Android e2e tests

# Reusable: runs the Argent flows against a prebuilt APK. Called by `android.yml`.
on:
workflow_call:
inputs:
artifact-name:
description: Artifact holding the APK to test.
required: true
type: string
abi:
description: Emulator ABI. Must match the ABI the APK was built for.
required: true
type: string

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 60

env:
# The emulator advertises its gRPC console in
# $XDG_RUNTIME_DIR/avd/running/pid_*.ini, which is where Argent's Android
# backend looks for it. The variable is unset on runners and the two fall
# back to different dirs, so pin it to a path they both check first.
XDG_RUNTIME_DIR: /tmp/xdg-runtime
AVD_NAME: test
SYSTEM_IMAGE: system-images;android-34;google_apis;${{ inputs.abi }}

steps:
- name: checkout
uses: actions/checkout@v4
Comment thread
j-piasecki marked this conversation as resolved.

# sdkmanager and avdmanager are Java tools.
- name: Use Java 17
uses: actions/setup-java@v4
with:
distribution: oracle
java-version: 17

# Only needed to run the Argent CLI — the app is downloaded, not built.
- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version: 24

- name: Download APK built by the build workflow
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ runner.temp }}/apk

- 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

# The emulator ignores XDG_RUNTIME_DIR if it does not exist, so create it
# before booting. 0700 per the XDG spec.
- name: Prepare shared XDG_RUNTIME_DIR
run: |
mkdir -p "$XDG_RUNTIME_DIR"
chmod 700 "$XDG_RUNTIME_DIR"

# The runner's preinstalled SDK has neither the emulator nor a system
# image (asking for platform-tools on top of it is a no-op).
- name: Install Android emulator and system image
run: |
CMDLINE_BIN=$(dirname "$(command -v sdkmanager || echo "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager")")
yes | "$CMDLINE_BIN/sdkmanager" --licenses > /dev/null || true
"$CMDLINE_BIN/sdkmanager" --install "emulator" "platform-tools" "$SYSTEM_IMAGE" > /dev/null
{
echo "$CMDLINE_BIN"
echo "$ANDROID_HOME/emulator"
echo "$ANDROID_HOME/platform-tools"
} >> "$GITHUB_PATH"
# By default avdmanager writes to $ANDROID_SDK_HOME/.android/avd while
# the emulator looks in $ANDROID_SDK_HOME/avd, which fails the boot
# with "Unknown AVD name". Both check $ANDROID_AVD_HOME first.
echo "ANDROID_AVD_HOME=$HOME/.android/avd" >> "$GITHUB_ENV"

- name: Create AVD
run: |
mkdir -p "$ANDROID_AVD_HOME"
echo no | avdmanager create avd --name "$AVD_NAME" --package "$SYSTEM_IMAGE" --force
test -f "$ANDROID_AVD_HOME/$AVD_NAME.ini" || {
echo "avdmanager did not create $AVD_NAME.ini in $ANDROID_AVD_HOME; found instead:" >&2
find "$HOME" "$ANDROID_HOME" -name "$AVD_NAME.ini" 2>/dev/null >&2
exit 1
}

# `-grpc` makes the emulator write grpc.port to the discovery ini Argent
# reads. `-accel on` fails the boot when KVM didn't take, instead of
# falling back to a software boot slow enough to hit the job timeout.
- name: Boot emulator
run: |
nohup emulator -avd "$AVD_NAME" -no-snapshot -accel on \
-no-window -gpu swiftshader_indirect -noaudio -no-boot-anim \
-grpc 8554 -camera-back none > emulator.log 2>&1 &
EMULATOR_PID=$!
adb start-server
# Poll boot state and process liveness (10 min budget): a backgrounded
# emulator that dies cannot fail the step on its own, and
# `adb wait-for-device` would just hang without saying why.
for _ in $(seq 1 120); do
if ! kill -0 "$EMULATOR_PID" 2>/dev/null; then
echo "Emulator process exited during boot:" >&2
cat emulator.log >&2
exit 1
fi
if [ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" = 1 ]; then
BOOTED=1
break
fi
sleep 5
done
if [ -z "${BOOTED:-}" ]; then
echo "Emulator did not finish booting within 10 minutes" >&2
adb devices >&2
cat emulator.log >&2
exit 1
fi
adb shell input keyevent 82
adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0
SERIAL=$(adb devices | awk 'NR>1 && $2=="device"{print $1; exit}')
echo "Emulator ready: $SERIAL"
echo "ANDROID_SERIAL=$SERIAL" >> "$GITHUB_ENV"

- name: Install app on emulator
run: |
APK=$(find "$RUNNER_TEMP/apk" -name '*.apk' | head -1)
if [ -z "$APK" ]; then
echo "Downloaded artifact does not contain an APK" >&2
ls -la "$RUNNER_TEMP/apk" >&2
exit 1
fi
echo "Installing $APK on $ANDROID_SERIAL"
adb install -r "$APK"

- name: Install Argent and start the tool-server
uses: ./.github/actions/argent-server
with:
# Logs how the backend discovers the emulator; drop once this is green.
simulator-server-log: debug

- name: Run E2E tests
run: argent flow run ./.argent/flows --device "$ANDROID_SERIAL"

- name: Print emulator log
if: ${{ !success() }}
run: cat emulator.log 2>/dev/null || echo "no emulator.log"

# The tool-server log also carries the device backend's stderr
# (`[sim <serial>]` lines), where a failed connection to the emulator is
# explained.
- name: Print Argent tool-server log
if: ${{ !success() }}
run: cat "$ARGENT_SERVER_LOG" 2>/dev/null || echo "no Argent tool-server log"
12 changes: 12 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: Build Android (expo-example)
on:
pull_request:
paths:
- .argent/flows/*
- .github/actions/argent-server/action.yml
- .github/workflows/android.yml
- .github/workflows/android-build.yml
- .github/workflows/android-e2e.yml
- packages/react-native-gesture-handler/package.json
- packages/react-native-gesture-handler/android/**
- packages/react-native-gesture-handler/shared/**
Expand All @@ -31,3 +34,12 @@ jobs:
app: expo-example
artifact-name: android-apk-expo-example
abi: x86_64

e2e:
if: github.repository == 'software-mansion/react-native-gesture-handler'
needs: expo-example

uses: ./.github/workflows/android-e2e.yml
with:
artifact-name: android-apk-expo-example
abi: x86_64
Loading
Loading