feat(tests): add api e2e tests (#3617)

* feat(tests): add api e2e tests

* lockfile

* mobile

* try linux fix [skip ci]

* ios fix

* fix test on windows

* improve cache

* fix pnpm audit [skip ci]
This commit is contained in:
Lucas Fernandes Nogueira
2026-09-22 18:58:14 -03:00
committed by GitHub
parent 7f87091288
commit 684feb2510
47 changed files with 10292 additions and 107 deletions
+8
View File
@@ -12,6 +12,7 @@ on:
paths:
- '.github/workflows/lint-javascript.yml'
- 'plugins/*/guest-js/**'
- 'packages/**'
- '.eslintignore'
- '.eslintrc.json'
- '.prettierignore'
@@ -23,6 +24,7 @@ on:
paths:
- '.github/workflows/lint-javascript.yml'
- 'plugins/*/guest-js/**'
- 'packages/**'
- '.eslintignore'
- '.eslintrc.json'
- '.prettierignore'
@@ -47,5 +49,11 @@ jobs:
with:
run_install: true
cache: true # the pnpm store, keyed by OS and lockfile hash and shared by every workflow
# the type-checked lint rules (and packages/api-e2e) resolve the plugins'
# types from their dist-js build output
- name: build
run: pnpm build
- name: eslint
run: pnpm lint
- name: ts:check
run: pnpm ts:check
+232
View File
@@ -0,0 +1,232 @@
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
name: test plugins e2e (mobile)
on:
workflow_dispatch:
push:
branches:
- v2
paths:
- '.github/workflows/test-api-e2e-mobile.yml'
- 'packages/api-e2e/**'
- 'examples/api/**'
- 'plugins/*/guest-js/**'
- 'plugins/*/src/**'
- 'plugins/*/android/**'
- 'plugins/*/ios/**'
- 'plugins/*/permissions/**'
- 'plugins/*/build.rs'
pull_request:
branches:
- v2
paths:
- '.github/workflows/test-api-e2e-mobile.yml'
- 'packages/api-e2e/**'
- 'examples/api/**'
- 'plugins/*/guest-js/**'
- 'plugins/*/src/**'
- 'plugins/*/android/**'
- 'plugins/*/ios/**'
- 'plugins/*/permissions/**'
- 'plugins/*/build.rs'
env:
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0 # keeps the target folder small for better cache efficiency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
android:
runs-on: ubuntu-latest
env:
# The emulator runs the host architecture, so only that target is built.
E2E_ANDROID_TARGET: x86_64
steps:
- uses: actions/checkout@v7
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-linux-android
- name: setup node
uses: actions/setup-node@v7
with:
node-version: 'lts/*'
- uses: pnpm/action-setup@v6
with:
cache: true # the pnpm store, keyed by OS and lockfile hash and shared by every workflow
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
# Same rule as the rust-cache step below: every run restores the Gradle cache and only
# `v2`/`v3` save it. setup-java's own `cache: gradle` has no such switch, so the restore
# and save steps are spelled out here (same paths and key inputs as setup-java uses).
- name: restore gradle cache
id: gradle-cache
uses: actions/cache/restore@v6
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}-
- name: Setup NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25
local-cache: true
# TODO check after https://github.com/nttld/setup-ndk/issues/518 is fixed
- name: Restore Android Symlinks
run: |
directory="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
find "$directory" -type l | while read link; do
current_target=$(readlink "$link")
new_target="$directory/$(basename "$current_target")"
ln -sf "$new_target" "$link"
echo "Changed $(basename "$link") from $current_target to $new_target"
done
# Hardware acceleration for the emulator.
- 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
- uses: Swatinem/rust-cache@v2
with:
key: android
# Only `v2`/`v3` write to the cache: an entry saved from a pull request lives on its
# merge ref, where nothing else can restore it, and every write evicts an entry
# that other runs would have hit (10 GB repository limit, LRU eviction).
save-if: ${{ github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3' }}
- name: install dependencies
run: pnpm i --frozen-lockfile
- name: build plugins
run: pnpm build
# Built before the emulator is up so it does not sit idle (and time out)
# during the Rust and Gradle builds; the suite then reuses the APK.
- name: build the APK
working-directory: ./examples/api
env:
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: pnpm tauri android build --debug --apk --target $E2E_ANDROID_TARGET
- name: save gradle cache
if: ${{ (github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3') && steps.gradle-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v6
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ steps.gradle-cache.outputs.cache-primary-key }}
- name: run e2e tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 60
with:
api-level: 35
arch: x86_64
# google_apis images ship an up-to-date Android System WebView.
target: google_apis
profile: pixel_6
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: E2E_SKIP_BUILD=1 E2E_SPEC_RETRIES=1 pnpm test:api-e2e:android
- name: upload appium logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: android-appium-logs
path: packages/api-e2e/logs
if-no-files-found: ignore
ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios-sim
- name: setup node
uses: actions/setup-node@v7
with:
node-version: 'lts/*'
- uses: pnpm/action-setup@v6
with:
cache: true # the pnpm store, keyed by OS and lockfile hash and shared by every workflow
- uses: Swatinem/rust-cache@v2
with:
key: ios
# Only `v2`/`v3` write to the cache: an entry saved from a pull request lives on its
# merge ref, where nothing else can restore it, and every write evicts an entry
# that other runs would have hit (10 GB repository limit, LRU eviction).
save-if: ${{ github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3' }}
- name: install dependencies
run: pnpm i --frozen-lockfile
- name: build plugins
run: pnpm build
# Simulator build (`aarch64-sim` on the Apple Silicon runners), unsigned.
# Built ahead of the suite for symmetry with the Android job.
- name: build the simulator app
working-directory: ./examples/api
run: pnpm tauri ios build --debug --target aarch64-sim --no-sign
# wdio.ios.conf picks the iPhone simulator on the newest installed runtime
# (no device name is hardcoded) and Appium boots it; the XCUITest driver
# compiles WebDriverAgent on the first session.
- name: run e2e tests
timeout-minutes: 60
env:
E2E_SKIP_BUILD: '1'
E2E_SPEC_RETRIES: '1'
run: pnpm test:api-e2e:ios
- name: upload appium logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: ios-appium-logs
path: packages/api-e2e/logs
if-no-files-found: ignore
- name: collect app crash reports
if: failure()
run: .scripts/ci/collect-macos-crash-reports.sh "$RUNNER_TEMP/crash-reports"
- name: upload app crash reports
if: failure()
uses: actions/upload-artifact@v7
with:
name: ios-crash-reports
path: ${{ runner.temp }}/crash-reports
if-no-files-found: ignore
+174
View File
@@ -0,0 +1,174 @@
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
name: test plugins e2e
on:
workflow_dispatch:
push:
branches:
- v2
paths:
- '.github/workflows/test-api-e2e.yml'
- 'packages/api-e2e/**'
- 'examples/api/**'
- 'plugins/*/guest-js/**'
- 'plugins/*/src/**'
- 'plugins/*/permissions/**'
- 'plugins/*/build.rs'
pull_request:
branches:
- v2
paths:
- '.github/workflows/test-api-e2e.yml'
- 'packages/api-e2e/**'
- 'examples/api/**'
- 'plugins/*/guest-js/**'
- 'plugins/*/src/**'
- 'plugins/*/permissions/**'
- 'plugins/*/build.rs'
env:
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0 # keeps the target folder small for better cache efficiency
MSEDGEDRIVER_TOOL_REV: 8c4b34f51b45f5cf08013366d703de464ab871d1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Linux, os: ubuntu-latest }
- { name: Windows, os: windows-latest }
- { name: macOS, os: macos-latest }
steps:
- uses: actions/checkout@v7
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: setup node
uses: actions/setup-node@v7
with:
node-version: 'lts/*'
- uses: pnpm/action-setup@v6
with:
cache: true # the pnpm store, keyed by OS and lockfile hash and shared by every workflow
- name: install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
webkit2gtk-driver \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
dbus \
xvfb \
fluxbox
# msedgedriver has to match the installed WebView2 runtime, so msedgedriver-tool
# downloads the right version at run time. The tool itself is built from a pinned git
# revision and kept in its own small cache entry (accessed by every Windows run, so it
# stays hot) instead of being rebuilt from source on every run.
- name: restore msedgedriver-tool (Windows)
if: runner.os == 'Windows'
id: msedgedriver-tool-cache
uses: actions/cache@v6
with:
path: ${{ runner.tool_cache }}/msedgedriver-tool
key: msedgedriver-tool-${{ runner.os }}-${{ env.MSEDGEDRIVER_TOOL_REV }}
- name: install msedgedriver-tool (Windows)
if: runner.os == 'Windows' && steps.msedgedriver-tool-cache.outputs.cache-hit != 'true'
run: cargo install --git https://github.com/chippers/msedgedriver-tool --rev ${{ env.MSEDGEDRIVER_TOOL_REV }} --locked --root ${{ runner.tool_cache }}/msedgedriver-tool
- name: install msedgedriver (Windows)
if: runner.os == 'Windows'
run: |
& "${{ runner.tool_cache }}/msedgedriver-tool/bin/msedgedriver-tool.exe"
$PWD.Path >> $env:GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.os }}
# Only `v2`/`v3` write to the cache: an entry saved from a pull request lives on its
# merge ref, where nothing else can restore it, and every write evicts an entry
# that other runs would have hit (10 GB repository limit, LRU eviction).
save-if: ${{ github.ref == 'refs/heads/v2' || github.ref == 'refs/heads/v3' }}
- name: install dependencies
run: pnpm i --frozen-lockfile
- name: build plugins
run: pnpm build
- name: run e2e tests (Linux)
if: runner.os == 'Linux'
timeout-minutes: 45
# A real window manager (fluxbox) is started so that window-state tests
# (size restore) behave, and a session D-Bus so the notification and
# clipboard plugins can reach their desktop services.
env:
E2E_SPEC_RETRIES: '1'
run: |
xvfb-run --auto-servernum -- dbus-run-session -- bash -c '
fluxbox >/dev/null 2>&1 &
sleep 1
pnpm test:api-e2e
'
- name: run e2e tests (Windows)
if: runner.os == 'Windows'
timeout-minutes: 45
shell: pwsh
# msedgedriver hands the app the `--remote-debugging-port` it attaches to through
# `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS`, and WebView2 ignores that variable in an
# elevated process, which is what the runner gives us. gsudo runs the suite at medium
# integrity instead, and the workspace is opened up so the de-elevated process can use it.
# See https://github.com/tauri-apps/wry/issues/1782 and
# https://github.com/MicrosoftEdge/WebView2Feedback/issues/5645.
env:
E2E_SPEC_RETRIES: '1'
run: |
winget install gerardog.gsudo --accept-source-agreements --accept-package-agreements
icacls "$env:GITHUB_WORKSPACE" /grant "Everyone:(OI)(CI)F"
sudo --integrity Medium pnpm test:api-e2e
- name: run e2e tests (macOS)
if: runner.os == 'macOS' && env.CN_API_KEY != ''
timeout-minutes: 45
env:
CN_API_KEY: ${{ secrets.TAURI_E2E_CN_API_KEY }}
E2E_SPEC_RETRIES: '1'
# macOS has no native WebDriver for WKWebView, so the app is driven through the
# CrabNebula Webdriver (tauri-plugin-automation + test-runner-backend), which
# authenticates with CN_API_KEY. wdio.conf enables it automatically on darwin and
# builds the `.app` bundle it needs.
run: pnpm test:api-e2e
- name: collect app crash reports (macOS)
if: runner.os == 'macOS' && failure()
run: .scripts/ci/collect-macos-crash-reports.sh "$RUNNER_TEMP/crash-reports"
- name: upload app crash reports (macOS)
if: runner.os == 'macOS' && failure()
uses: actions/upload-artifact@v7
with:
name: macos-crash-reports
path: ${{ runner.temp }}/crash-reports
if-no-files-found: ignore