-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[CI] Add basic Argent end-to-end tests #4318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
j-piasecki
wants to merge
9
commits into
main
Choose a base branch
from
@jpiasecki/tap-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bdb63be
Add test ids, rename examples
j-piasecki 054c162
Tap e2e test
j-piasecki 0afffe8
Long press e2e test
j-piasecki 4f80277
Run e2e tests on CI
j-piasecki f66bf1f
Use functional state update in tap and long press examples
j-piasecki 4a95ec4
Memoize loggers
j-piasecki 4109b7e
Fix echo step
j-piasecki 5d0dfbb
Fail when no excode version available
j-piasecki 31bf731
temp: try to figure out failure
j-piasecki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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" } |
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
| 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" } |
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
| 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 |
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
| 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 | ||
|
|
||
| # 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" | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.