Skip to content
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: "CodeQL"
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
- cron: "16 16 * * 0"

Expand Down
32 changes: 18 additions & 14 deletions appium/scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Local Test Runner

`run-local.sh` builds the app, boots a simulator/emulator, starts Appium, resets app state, and runs the E2E test suite.
`run-local.sh` builds the app, boots a simulator/emulator, starts Appium, resets app state, and runs the E2E test suite. With `--install-only` it stops after installing the app.

## Setup

Expand Down Expand Up @@ -75,19 +75,21 @@ If `--platform` or `--sdk` are not provided, the script prompts interactively.

### Options

| Flag | Description |
| --------------- | ---------------------------------------------------------------------------------------------- |
| `--platform=P` | `ios` or `android` |
| `--sdk=S` | `flutter`, `react-native`, `cordova`, `capacitor`, `expo`, `dotnet`, `unity`, `android`, `ios` |
| `--spec=GLOB` | Spec file glob (default: `tests/specs/**/*.spec.ts`) |
| `--skip` | Skip build, device launch, and app reset (rerun tests only) |
| `--skip-build` | Skip app build (reuse existing `.app`/`.apk`) |
| `--skip-device` | Skip simulator/emulator launch |
| `--skip-reset` | Keep existing app data between runs |
| `--pods` | Use `examples/demo-pods` for Flutter, Cordova, and Capacitor |
| `--release` | Check out the latest release point in each SDK repo first |
| `--main` | Check out the latest `main` in each SDK repo first |
| `-h, --help` | Show help |
| Flag | Description |
| ---------------- | ---------------------------------------------------------------------------------------------- |
| `--platform=P` | `ios` or `android` |
| `--sdk=S` | `flutter`, `react-native`, `cordova`, `capacitor`, `expo`, `dotnet`, `unity`, `android`, `ios` |
| `--spec=GLOB` | Spec file glob (default: `tests/specs/**/*.spec.ts`) |
| `--skip` | Skip build, device launch, and app reset (rerun tests only) |
| `--skip-build` | Skip app build (reuse existing `.app`/`.apk`) |
| `--skip-device` | Skip simulator/emulator launch |
| `--skip-reset` | Keep existing app data between runs |
| `--install-only` | Build, launch the device, reset, and install the app; skip Appium and tests |
| `--pick-device` | Prompt for which iOS simulator or Android emulator to use |
| `--pods` | Use `examples/demo-pods` for Flutter, Cordova, and Capacitor |
| `--release` | Check out the latest release point in each SDK repo first |
| `--main` | Check out the latest `main` in each SDK repo first |
| `-h, --help` | Show help |

### Examples

Expand Down Expand Up @@ -144,6 +146,8 @@ Skip only the build (simulator + reset still happen):
./run-all.sh --release # check out the latest release point per repo first
./run-all.sh --main # check out the latest main per repo first
./run-all.sh --bail # stop after the first failing combo
./run-all.sh --pick-device # prompt for a simulator and/or emulator up front
./run-all.sh --sdks=flutter --install-only # build and install on both platforms, no tests
```

`--release` is available on both `run-all.sh` and `run-local.sh`. It runs `checkout-releases.sh`, which checks out the newest stable `rel/X.Y.Z` branch (for expo/ios, the newest semver tag unless a newer stable `rel/X.Y.Z` branch exists for a pending release) in each SDK repo, honoring the `*_DIR` overrides from `.env`. Uncommitted changes, including untracked files, are stashed before checkout and can be restored later with `git stash pop`.
Expand Down
74 changes: 60 additions & 14 deletions appium/scripts/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if [[ -f "$SCRIPT_DIR/.env" ]]; then
fi

source "$SCRIPT_DIR/run-local/repo-dir.sh"
source "$SCRIPT_DIR/run-local/device-picker.sh"

# ── Colors / logging ─────────────────────────────────────────────────────────
RED='\033[0;31m'
Expand All @@ -34,10 +35,15 @@ PODS_REQUESTED=0
RELEASE=0
MAIN=0
WIPE_EMULATOR=0
PICK_DEVICE=0
INSTALL_ONLY=0
for arg in "$@"; do
case "$arg" in
--skip-build|--skip-device|--skip-reset|--skip|--quiet|-q)
EXTRA_ARGS+=("$arg") ;;
--install-only)
INSTALL_ONLY=1
EXTRA_ARGS+=("$arg") ;;
--wipe-emulator)
WIPE_EMULATOR=1 ;;
--pods)
Expand All @@ -57,6 +63,8 @@ for arg in "$@"; do
SDKS_FILTER="${arg#*=}" ;;
--bail)
BAIL=1 ;;
--pick-device)
PICK_DEVICE=1 ;;
Comment thread
fadi-george marked this conversation as resolved.
Resolved
--help|-h)
cat <<USAGE
Usage: $0 [OPTIONS]
Expand All @@ -74,6 +82,8 @@ Options:
Note: 'android' (native) skips --platform=ios and
'ios' (native) skips --platform=android.
--bail Stop after the first failing combo
--pick-device Prompt up front for which iOS simulator and/or
Android emulator to use (one per platform run)
--release Check out the latest release point for the selected
SDK repos first (honors *_DIR from .env). Stashes
uncommitted changes, including untracked files.
Expand All @@ -86,6 +96,8 @@ Options forwarded to run-local.sh:
--skip-device Skip simulator/emulator launch
--skip-reset Keep existing app data
--skip Shortcut for --skip-build --skip-device --skip-reset
--install-only Build and install without running tests. Allows one SDK
per platform, since every demo shares one bundle id.
--wipe-emulator Wipe the Android AVD before the first Android combo
--pods Use examples/demo-pods for flutter, cordova, capacitor
(ignored for other SDKs)
Expand Down Expand Up @@ -142,18 +154,37 @@ if (( PODS_REQUESTED )); then
fi
fi

# Native SDKs only run on their own platform; drop them up front so
# --release/--main don't touch or prompt for repos that won't run.
# Native SDKs only run on their own platform.
combo_runs() {
local sdk="$1" platform="$2"
[[ ! ( "$sdk" == android && "$platform" == ios ) \
&& ! ( "$sdk" == ios && "$platform" == android ) ]]
}

# Drop native SDKs up front so --release/--main don't touch or prompt for
# repos that won't run.
if [[ -n "$PLATFORM_FILTER" ]]; then
RUN_SDKS=()
for sdk in "${SDKS[@]}"; do
[[ ( "$sdk" == android && "$PLATFORM_FILTER" == ios ) \
|| ( "$sdk" == ios && "$PLATFORM_FILTER" == android ) ]] || RUN_SDKS+=("$sdk")
combo_runs "$sdk" "$PLATFORM_FILTER" && RUN_SDKS+=("$sdk")
done
else
RUN_SDKS=("${SDKS[@]}")
fi

if (( INSTALL_ONLY )); then
for platform in "${PLATFORMS[@]}"; do
platform_sdks=()
for sdk in ${RUN_SDKS[@]+"${RUN_SDKS[@]}"}; do
combo_runs "$sdk" "$platform" && platform_sdks+=("$sdk")
done
if (( ${#platform_sdks[@]} > 1 )); then
error "--install-only would install ${platform_sdks[*]} on $platform, but every demo shares one bundle id so only the last would remain. Narrow with --sdks= or --platform=."
exit 2
fi
done
fi

# --release/--main switch the default checkout to a fixed ref, so there is no
# worktree to choose.
if (( RELEASE || MAIN )); then
Expand All @@ -166,6 +197,24 @@ for sdk in ${RUN_SDKS[@]+"${RUN_SDKS[@]}"}; do
resolve_sdk_dir "$sdk"
done

IOS_DEVICE_ARGS=()
ANDROID_DEVICE_ARGS=()
if (( PICK_DEVICE )); then
for platform in "${PLATFORMS[@]}"; do
has_combo=0
for sdk in ${RUN_SDKS[@]+"${RUN_SDKS[@]}"}; do
combo_runs "$sdk" "$platform" && { has_combo=1; break; }
done
(( has_combo )) || continue
pick_device "$platform" || exit 2
if [[ "$platform" == "ios" ]]; then
IOS_DEVICE_ARGS=(--device="$PICKED_DEVICE" --udid="$PICKED_UDID")
else
ANDROID_DEVICE_ARGS=(--device="$PICKED_DEVICE")
fi
done
fi

if (( RELEASE && ${#RUN_SDKS[@]} > 0 )); then
echo -e "${BOLD}━━━ Checking out latest releases ━━━${NC}"
if ! "$SCRIPT_DIR/checkout-releases.sh" "${RUN_SDKS[@]}"; then
Expand Down Expand Up @@ -201,17 +250,9 @@ for platform in "${PLATFORMS[@]}"; do
else
label="${sdk} / ${platform}"
fi
if [[ "$sdk" == "android" && "$platform" == "ios" ]]; then
if ! combo_runs "$sdk" "$platform"; then
if [[ -n "$PLATFORM_FILTER" ]]; then
warn "--sdk=android only runs on --platform=android; skipping --platform=ios"
RESULTS+=("SKIP ${label}")
SKIPPED=$((SKIPPED + 1))
fi
continue
fi
if [[ "$sdk" == "ios" && "$platform" == "android" ]]; then
if [[ -n "$PLATFORM_FILTER" ]]; then
warn "--sdk=ios only runs on --platform=ios; skipping --platform=android"
warn "--sdk=$sdk only runs on --platform=$sdk; skipping --platform=$platform"
RESULTS+=("SKIP ${label}")
SKIPPED=$((SKIPPED + 1))
fi
Expand All @@ -229,6 +270,11 @@ for platform in "${PLATFORMS[@]}"; do
flutter|cordova|capacitor) combo_args+=(--pods) ;;
esac
fi
if [[ "$platform" == "ios" ]]; then
combo_args+=(${IOS_DEVICE_ARGS[@]+"${IOS_DEVICE_ARGS[@]}"})
else
combo_args+=(${ANDROID_DEVICE_ARGS[@]+"${ANDROID_DEVICE_ARGS[@]}"})
fi
if [[ "$platform" == "android" ]] && (( WIPE_EMULATOR )) && (( ! ANDROID_EMULATOR_WIPED )); then
combo_args+=(--wipe-emulator)
ANDROID_EMULATOR_WIPED=1
Expand Down
8 changes: 8 additions & 0 deletions appium/scripts/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN_LOCAL_LIB_DIR="$SCRIPT_DIR/run-local"
source "$RUN_LOCAL_LIB_DIR/common.sh"
source "$RUN_LOCAL_LIB_DIR/repo-dir.sh"
source "$RUN_LOCAL_LIB_DIR/config.sh"
source "$RUN_LOCAL_LIB_DIR/device-picker.sh"
source "$RUN_LOCAL_LIB_DIR/sdk-artifacts.sh"
source "$RUN_LOCAL_LIB_DIR/build.sh"
source "$RUN_LOCAL_LIB_DIR/runtime.sh"
Expand Down Expand Up @@ -84,6 +85,13 @@ main() {

begin_quiet_setup
build_app
if [[ "$INSTALL_ONLY" == true ]]; then
prepare_install_only
end_quiet_setup
echo ""
info "=== Installed (--install-only, tests skipped) ==="
return
fi
prepare_runtime
install_test_deps
end_quiet_setup
Expand Down
54 changes: 44 additions & 10 deletions appium/scripts/run-local/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ configure_runner() {
SKIP_BUILD=false
SKIP_DEVICE=false
SKIP_RESET=false
INSTALL_ONLY=false
PICK_DEVICE=false
DEVICE_FLAG=false
UDID_FLAG=false
SPEC=""
QUIET=false
PODS_DEMO=false
Expand All @@ -23,16 +27,18 @@ configure_runner() {
case "$arg" in
--platform=*) PLATFORM="${arg#--platform=}" ;;
--sdk=*) SDK_TYPE="${arg#--sdk=}" ;;
--device=*) DEVICE="${arg#--device=}" ;;
--device=*) DEVICE="${arg#--device=}"; DEVICE_FLAG=true ;;
--pick-device) PICK_DEVICE=true ;;
--device-real) IOS_REAL_DEVICE=true; SKIP_DEVICE=true ;;
--udid=*) UDID="${arg#--udid=}" ;;
--udid=*) UDID="${arg#--udid=}"; UDID_FLAG=true ;;
--appium-port=*) APPIUM_PORT="${arg#--appium-port=}" ;;
--wda-local-port=*) WDA_LOCAL_PORT="${arg#--wda-local-port=}" ;;
--system-port=*) SYSTEM_PORT="${arg#--system-port=}" ;;
--skip) SKIP_BUILD=true; SKIP_DEVICE=true; SKIP_RESET=true ;;
--skip-build) SKIP_BUILD=true ;;
--skip-device) SKIP_DEVICE=true ;;
--skip-reset) SKIP_RESET=true ;;
--install-only) INSTALL_ONLY=true ;;
--wipe-emulator) WIPE_EMULATOR=true ;;
--pods) PODS_DEMO=true ;;
--release) RELEASE=true ;;
Expand All @@ -57,6 +63,7 @@ Options:
ios = native iOS (OneSignal-iOS-SDK/examples/demo);
skips with exit 0 when --platform=android.
--device=NAME Device/simulator/AVD name (default: iPhone 17 / Android 17)
--pick-device Prompt for which iOS simulator or Android emulator to use
--appium-port=N Appium server port (default: 4723). Use unique values when
running multiple sessions in parallel on the same host.
--system-port=N UiAutomator2 systemPort (Android only). Required when
Expand All @@ -66,6 +73,8 @@ Options:
--skip-build Skip app build (reuse existing)
--skip-device Skip simulator/emulator launch
--skip-reset Keep existing app data
--install-only Build, launch the device, reset, and install the app,
then exit without starting Appium or running tests
--wipe-emulator Wipe the Android AVD before launch. Deletes all emulator
apps and data; incompatible with --skip-device.
--pods Use examples/demo-pods instead of examples/demo for
Expand Down Expand Up @@ -128,6 +137,16 @@ USAGE
esac
done

# A CLI device beats device settings from .env/env. Without a pinned runtime,
# start_ios_simulator matches the name on the newest runtime that has it.
if [[ "$DEVICE_FLAG" == true ]]; then
AVD_NAME=""
IOS_SIMULATOR=""
IOS_RUNTIME=""
IOS_RUNTIME_ANY=true
[[ "$UDID_FLAG" == true ]] || UDID=""
fi

# Ensure values set via CLI flags propagate to wdio (which reads them as env).
export APPIUM_PORT
[[ -n "$WDA_LOCAL_PORT" ]] && export WDA_LOCAL_PORT
Expand Down Expand Up @@ -176,6 +195,15 @@ USAGE
error "--release and --main are mutually exclusive"
fi

if [[ "$PICK_DEVICE" == true ]]; then
[[ "$IOS_REAL_DEVICE" == false ]] || error "--pick-device cannot be combined with --device-real"
pick_device "$PLATFORM" || exit 1
DEVICE="$PICKED_DEVICE"
AVD_NAME=""
IOS_SIMULATOR=""
[[ "$PLATFORM" == "ios" ]] && UDID="$PICKED_UDID"
fi

resolve_sdk_dir "$SDK_TYPE"

if [[ "$RELEASE" == true ]]; then
Expand All @@ -198,6 +226,19 @@ USAGE
# calls `vpx wdio run` directly on BrowserStack — so these checks are
# local-only by construction.
preflight() {
if [[ "$INSTALL_ONLY" != true ]]; then
preflight_test_tooling
fi

if [[ -z "${ONESIGNAL_APP_ID:-}" || -z "${ONESIGNAL_API_KEY:-}" ]]; then
error "ONESIGNAL_APP_ID / ONESIGNAL_API_KEY not set. Use the OneSignal app
dedicated to Appium tests (not a general/shared app — its live in-app
marketing campaigns can cover the UI and cause misleading 'element not
displayed' failures). Set both in $SCRIPT_DIR/.env (cp .env.example .env)."
fi
}

preflight_test_tooling() {
command -v appium >/dev/null 2>&1 \
|| error "appium not found on PATH. Install it with: npm i -g appium"

Expand Down Expand Up @@ -239,13 +280,6 @@ USAGE
export WDIO_USE_NATIVE_FETCH=1
info "Node $node_major detected — setting WDIO_USE_NATIVE_FETCH=1 (works around webdriverio's undici dispatcher being rejected by Node 26+ fetch)."
fi

if [[ -z "${ONESIGNAL_APP_ID:-}" || -z "${ONESIGNAL_API_KEY:-}" ]]; then
error "ONESIGNAL_APP_ID / ONESIGNAL_API_KEY not set. Use the OneSignal app
dedicated to Appium tests (not a general/shared app — its live in-app
marketing campaigns can cover the UI and cause misleading 'element not
displayed' failures). Set both in $SCRIPT_DIR/.env (cp .env.example .env)."
fi
}
preflight

Expand Down Expand Up @@ -423,7 +457,7 @@ USAGE
DEVICE="${DEVICE:-iPhone 17}"
OS_VERSION="${OS_VERSION:-26.5}"
IOS_SIMULATOR="${IOS_SIMULATOR:-$DEVICE}"
IOS_RUNTIME="${IOS_RUNTIME:-iOS-26-5}"
[[ "${IOS_RUNTIME_ANY:-false}" == true ]] || IOS_RUNTIME="${IOS_RUNTIME:-iOS-26-5}"
else
DEVICE="${DEVICE:-Android 17}"
OS_VERSION="${OS_VERSION:-17}"
Expand Down
Loading