# Git / automation notes (taler-monitoring + mobile)

Notes for **automated checks** around the Taler stacks (GOA, stage
TESTPAYSAN, …). CLI monitoring lives in this directory; **Android wallet
UI automation is separate tooling** and is **not** installed on the
default ops laptop yet.

---

## Git commit / push cadence (existing model)

Observed in `koopa-admin-log` / `francpaysan-admin-log` histories, plus ops preference:

| Rule | Practice |
|------|----------|
| **Commits** | **Prefer frequent** small commits over rare large ones |
| **Interval** | Soft range **7–13 minutes** while a topic is open — **not** a fixed 9‑minute metronome; denser 0–2 min bursts for tiny follow-ups are fine |
| **Message** | `area: short description` — e.g. `monitoring: …`, `landings: …`, `docs: …` |
| **Push** | **Only at the end of a work session** (`CADENCE_PUSH=1` or manual `git push`) — not after every commit |

### Agent / human workflow

1. Finish a small slice → commit (`area: …`). Repeat often.  
2. Do **not** push after each commit.  
3. When the topic/session is done → one `git push` (or `CADENCE_PUSH=1`).  
4. Soft next-commit window: about **7–13 min** (jitter), sooner if the next slice is ready.

### Helper script

```bash
# dry-run
CADENCE_DRY=1 ./scripts/git-cadence-commit-push.sh

# commit only if dirty (default: no push; skips secrets)
./scripts/git-cadence-commit-push.sh
./scripts/git-cadence-commit-push.sh ~/taler/src/francpaysan-admin-log

# end of session — push commits that are already local
CADENCE_PUSH=1 ./scripts/git-cadence-commit-push.sh

# soft timer: only commit if last commit age ≥ random target in 7–13 min
CADENCE_JITTER=1 ./scripts/git-cadence-commit-push.sh
```

Optional user cron (check every 7 min; **jitter** keeps effective gaps in **7–13 min**):

```bash
*/7 * * * * CADENCE_JITTER=1 $HOME/src/koopa/koopa-admin-log/scripts/git-cadence-commit-push.sh >>$HOME/.cache/git-cadence-koopa.log 2>&1
```

**Auth note:** `francpaysan-admin-log` (gnunet SSH) pushes OK.  
`koopa-admin-log` (hacktivism HTTPS) needs credentials/SSH key before end-of-session push works from this host.

## What runs without Android

| Phase | Needs |
|-------|--------|
| `urls` / `sanity` | public HTTPS only |
| `inside` / `versions` | SSH (`koopa` or `francpaysan-stage-user`) |
| `e2e` / `ladder` | `taler-wallet-cli` + bank/merchant secrets |

```bash
./taler-monitoring.sh -d stage.lefrancpaysan.ch urls
./taler-monitoring.sh -d stage.lefrancpaysan.ch e2e   # after secrets.env
```

Mobile app checks (manual withdraw/pay, then automation) are **out of
band** until the software below is present.

---

## Android automation software — **required** (not installed yet)

To automate **GNU Taler Wallet** on Android (stable + master builds;
manual then auto withdraw; fixed + variable pay) against stage
TESTPAYSAN, the following must be available on the runner host.

### Status on this host (2026-07-17)

| Component | Status |
|-----------|--------|
| Java (OpenJDK 21) | present (`/usr/bin/java`) |
| `aapt` / `aapt2` | present |
| **`adb`** (platform-tools) | **missing** (package was removed: `android-tools-adb` rc) |
| **Android SDK** (`ANDROID_HOME` / `ANDROID_SDK_ROOT`) | **missing** / empty |
| **Emulator + AVD** | **missing** |
| Appium / Maestro / `uiautomator2` | **missing** |
| scrcpy | missing (optional) |

### Must install before mobile automation

1. **Android platform-tools** — at least `adb`  
   - Debian: `android-tools-adb` (and preferably full SDK platform-tools)
2. **Android SDK command-line tools** — `sdkmanager`, platforms, build-tools  
   - set `ANDROID_HOME` (or `ANDROID_SDK_ROOT`) permanently
3. **System image + AVD** — for emulator runs (x86_64 or host-matching ABI)  
   - `emulator`, `avdmanager`, KVM/acceleration if available
4. **UI automation stack** (pick one, prefer the leaner path for wallet flows):  
   - **Maestro**, or  
   - **Appium** + **UiAutomator2** (+ Node/Python bindings as needed)
5. **Optional:** `scrcpy` for live view during manual debugging

### Explicitly out of scope until freigabe

- Installing production wallet APKs and driving real stage withdraw/pay  
  without a human go-ahead  
- Committing secrets, device serials, or APK binaries into git

### Operator still needs to supply

- Stable / master **APK** (or store/build URLs) for the wallet  
- USB debugging consent on a physical device, **or** agreement to use AVD only  
- Which flows are in-scope first (withdraw communal QR → shop pay, …)

### Suggested freigabe prompt (for an agent)

See session notes: full copy-paste block under “Android-Automatisierung
vollständig einrichten” — install tooling, verify `adb devices` + emulator,
document paths; **no** real wallet payments until approved.

---

## Related docs

| Doc | Role |
|-----|------|
| [README.md](./README.md) | how to run `taler-monitoring.sh` |
| [TESTS.md](./TESTS.md) | grouped check IDs |
| [secrets.env.example](./secrets.env.example) | e2e secrets layout |
| `francpaysan-admin-log/TODO.md` | stage wallet mobile test backlog |

When Android tooling is installed, append a short “installed on …”
section here (date, `adb version`, AVD name, `ANDROID_HOME`).

---

## Android pay smoke (published APK, no root preferred)

Script: [`android-test/run-android-pay-smoke.sh`](./android-test/run-android-pay-smoke.sh)

| Step | Detail |
|------|--------|
| APK | F-Droid **Taler Wallet 1.6.1** (`net.taler.wallet.fdroid_854.apk`) |
| Install | `adb install -r` (no root) |
| Withdraw | `taler://withdraw/…` from `…/intro/demo-withdraw.json` (GOA or stage) |
| Pay | stage: shop template order → `taler://pay/…`; GOA: `taler://pay-template/…/goa-shop/paivana` |
| Evidence | screenshots + logcat under `android-test/out/` |

```bash
# device or emulator already booted
./android-test/run-android-pay-smoke.sh
STACK=goa ./android-test/run-android-pay-smoke.sh
STACK=stage ./android-test/run-android-pay-smoke.sh
```

**User-local emulator (no apt root if SDK already under `$HOME/Android/Sdk`):**

```bash
# Default = headless (no host window); guest GLES via SwiftShader.
# Prefer the helper — same flags smokes use:
./android-test/start-android-emulator.sh --wait
./android-test/run-android-pay-smoke.sh
# Or let smoke auto-start the AVD (AUTO_START_EMULATOR=1).
# Windowed laptop: WINDOWED=1 ./android-test/start-android-emulator.sh --wait
```

**Limits (clementine 2026-07-17):** host RAM ~3.7 GiB → emulator often ANRs System UI;
wallet-core still receives withdraw intents (`prepareBankIntegratedWithdrawal` in logcat).
For reliable full UI confirm/pay use a physical phone or a host with **≥6–8 GiB** free RAM.

### Status snapshot (2026-07-17)

| Item | Status |
|------|--------|
| `adb` | present (`android-sdk-platform-tools`) |
| F-Droid APK | downloaded under `android-test/apks/` |
| User SDK + emulator + AVD `TalerWallet34` | installed under `$HOME/Android/Sdk` (~5 GiB) |
| `adb install` wallet | **Success** on emulator-5554 |
| Deep-link withdraw | **delivered**; wallet-core started `prepareBankIntegratedWithdrawal` for GOA |
| Unattended UI confirm | flaky (ANR) on this host’s RAM |
| Source build `assembleFdroidDebug` | **OK** (2026-07-17, `taler-android@f65a976c0d4a`, ~12 min, APK ~59 MiB) |

### From-source smoke (same tests as F-Droid)

```bash
# single ref (default: inference fix branch)
./android-test/run-android-build-and-smoke.sh
BRANCH=master ./android-test/run-android-build-and-smoke.sh
# self-build published stable tag (parity with F-Droid 1.6.1 source)
BRANCH=wallet-1.6.1 LABEL=stable-self ./android-test/run-android-build-and-smoke.sh
# matrix: published APK + stable self-build + master (anti–weird-build)
./android-test/run-android-variant-matrix.sh
STACK=goa ./android-test/run-android-build-and-smoke.sh
# already built:
APK_PATH=$HOME/taler/taler-android/wallet/build/outputs/apk/fdroid/debug/wallet-fdroid-debug.apk \
  PKG=net.taler.wallet.fdroid.debug \
  ./android-test/run-android-pay-smoke.sh
```
