koopa-admin-log/scripts/taler-monitoring/android-test/run-android-variant-matrix.sh
Hernâni Marques 2a2e478725
android-test: SMOKE_STRICT hard-fail on ANR / missing withdraw core
Matrix gates set SMOKE_STRICT=1 so stable-self and published cannot pass
on install-only when System UI ANRs or wallet-core never sees the URI.
2026-07-17 21:53:04 +02:00

170 lines
5.7 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Run Android wallet smoke against **several build variants** so a single
# "weird" developer tree or a bad local build cannot be the only sample.
#
# Default matrix (gate order — fail → hard stop when FAIL_FAST=1):
# 1) **stable-self** — rebuild release **tag** (same source as published)
# 2) **published** — F-Droid stable APK (what users install)
# 3) **master** — rebuild origin/master (only if 12 pass with FAIL_FAST)
#
# Why stable-self in addition to published?
# Rare, but a published APK *or* a one-off developer build can be odd
# (wrong flags, dirty tree, wrong ABI). Rebuilding the release tag on *this*
# machine with the same script path as master isolates "our toolchain" vs
# "F-Droid binary" vs "current master source".
#
# Usage:
# ./run-android-variant-matrix.sh
# STACK=goa ./run-android-variant-matrix.sh
# VARIANTS=master,stable-self ./run-android-variant-matrix.sh
# VARIANTS=published,stable-self,master,fix GUI=1 ./run-android-variant-matrix.sh
# STABLE_TAG=wallet-1.6.1 MASTER_BRANCH=master ./run-android-variant-matrix.sh
#
# Env:
# STABLE_TAG default wallet-1.6.1 (must match published F-Droid release)
# STABLE_APK_URL published APK (same as pay-smoke default)
# MASTER_BRANCH default master
# FIX_BRANCH inference fix branch (variant "fix")
# VARIANTS comma list: published,stable-self,master,fix
# GUI=1 use gui-smoke instead of pay-smoke after each build
# FAIL_FAST=1 stop on first non-zero smoke (default 0 = run all)
# MATRIX_OUT summary dir (default out-matrix-<timestamp>)
#
set -euo pipefail
ROOT=$(cd "$(dirname "$0")" && pwd)
# shellcheck source=lib_android_env.sh
. "$ROOT/lib_android_env.sh"
: "${STABLE_TAG:=wallet-1.6.1}"
: "${STABLE_APK_URL:=https://f-droid.org/repo/net.taler.wallet.fdroid_854.apk}"
: "${STABLE_APK_NAME:=net.taler.wallet.fdroid_854.apk}"
: "${MASTER_BRANCH:=master}"
: "${FIX_BRANCH:=dev/hernani-inference/fix-bank-withdraw-auto-exchange}"
# Gate: stable self-build → published F-Droid; then master. FAIL_FAST default on.
: "${VARIANTS:=stable-self,published,master}"
: "${FAIL_FAST:=1}"
: "${GUI:=0}"
: "${STACK:=auto}"
TS=$(date +%Y%m%d-%H%M%S)
MATRIX_OUT="${MATRIX_OUT:-$ROOT/out-matrix-$TS}"
mkdir -p "$MATRIX_OUT"
SUMMARY="$MATRIX_OUT/SUMMARY.txt"
: >"$SUMMARY"
echo "=== Android variant matrix ===" | tee -a "$SUMMARY"
echo "STACK=$STACK GUI=$GUI headless=${EMULATOR_HEADLESS} variants=$VARIANTS" | tee -a "$SUMMARY"
echo "STABLE_TAG=$STABLE_TAG MASTER_BRANCH=$MASTER_BRANCH" | tee -a "$SUMMARY"
echo "out: $MATRIX_OUT" | tee -a "$SUMMARY"
# Ensure device once (headless AVD by default)
android_ensure_device || {
echo "no adb device — start ./start-android-emulator.sh --wait" >&2
exit 3
}
export SERIAL ANDROID_SERIAL
echo "device: $SERIAL" | tee -a "$SUMMARY"
IFS=',' read -r -a VLIST <<<"$VARIANTS"
declare -a RESULTS=()
overall=0
run_published() {
local out="$MATRIX_OUT/published"
mkdir -p "$out"
echo "" | tee -a "$SUMMARY"
echo "-------- variant: published (F-Droid stable binary) --------" | tee -a "$SUMMARY"
local smoke="$ROOT/run-android-pay-smoke.sh"
[ "$GUI" = "1" ] && smoke="$ROOT/run-android-gui-smoke.sh"
set +e
env STACK="$STACK" \
APK_URL="$STABLE_APK_URL" \
APK_NAME="$STABLE_APK_NAME" \
APK_PATH="" \
PKG=net.taler.wallet.fdroid \
OUT_DIR="$out" \
SERIAL="$SERIAL" \
AUTO_START_EMULATOR=0 \
SMOKE_STRICT="${SMOKE_STRICT:-1}" \
"$smoke"
local rc=$?
set -e
echo "published exit=$rc" | tee -a "$SUMMARY"
echo "published $rc" >>"$MATRIX_OUT/results.tsv"
return "$rc"
}
run_selfbuild() {
local label="$1"
local ref="$2"
local out="$MATRIX_OUT/$label"
mkdir -p "$out"
echo "" | tee -a "$SUMMARY"
echo "-------- variant: $label (self-build ref=$ref) --------" | tee -a "$SUMMARY"
set +e
env STACK="$STACK" \
BRANCH="$ref" \
LABEL="$label" \
GUI="$GUI" \
OUT_DIR="$out" \
SERIAL="$SERIAL" \
ANDROID_SERIAL="$SERIAL" \
AUTO_START_EMULATOR=0 \
PKG=net.taler.wallet.fdroid.debug \
SMOKE_STRICT="${SMOKE_STRICT:-1}" \
"$ROOT/run-android-build-and-smoke.sh"
local rc=$?
set -e
echo "$label (ref=$ref) exit=$rc" | tee -a "$SUMMARY"
echo "$label $rc $ref" >>"$MATRIX_OUT/results.tsv"
if [ -f "$out/build-meta.txt" ]; then
echo "build-meta:" | tee -a "$SUMMARY"
cat "$out/build-meta.txt" | tee -a "$SUMMARY"
fi
return "$rc"
}
for raw in "${VLIST[@]}"; do
v=$(echo "$raw" | tr -d '[:space:]')
[ -n "$v" ] || continue
rc=0
case "$v" in
published|fdroid|stable-published)
run_published || rc=$?
;;
stable-self|stable|self-stable|release-self)
run_selfbuild "stable-self" "$STABLE_TAG" || rc=$?
;;
master|main)
run_selfbuild "master" "$MASTER_BRANCH" || rc=$?
;;
fix|fix-branch|inference)
run_selfbuild "fix" "$FIX_BRANCH" || rc=$?
;;
*)
# treat as raw git ref / label
run_selfbuild "ref-${v//\//-}" "$v" || rc=$?
;;
esac
RESULTS+=("$v:$rc")
if [ "$rc" -ne 0 ]; then
overall=1
if [ "$FAIL_FAST" = "1" ]; then
echo "FAIL_FAST: stopping after $v rc=$rc" | tee -a "$SUMMARY"
break
fi
fi
done
echo "" | tee -a "$SUMMARY"
echo "=== matrix done (overall=$overall) ===" | tee -a "$SUMMARY"
for r in "${RESULTS[@]}"; do
echo " $r" | tee -a "$SUMMARY"
done
echo ""
echo "Compare OUT_DIR trees under $MATRIX_OUT"
echo "Intent: published vs stable-self should behave similarly;"
echo " master may diverge (new features / fixes)."
echo "A odd stable-self vs published suggests toolchain or unsigned-debug differences;"
echo "a odd master-only failure suggests tip breakage, not F-Droid stable."
exit "$overall"