agentic-mobile-kit 0.7.8 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/stacks/react-native/expo/AGENTS.md +2 -1
- package/stacks/react-native/template/.agents/skills/m-bugfix/SKILL.md +1 -1
- package/stacks/react-native/template/.agents/skills/m-change/SKILL.md +1 -1
- package/stacks/react-native/template/.agents/skills/m-feature/SKILL.md +6 -2
- package/stacks/react-native/template/.rulesync/subagents/m-device-checker.md +18 -0
- package/stacks/react-native/template/AGENTS.md +2 -1
- package/stacks/react-native/template/scripts/amk/handoff-check.js +1 -1
- package/stacks/react-native/template/scripts/amk/verify.sh +365 -119
- package/stacks/react-native/template/specs/_templates/flow.yaml +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-mobile-kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "One setup for AI-assisted development of React Native apps, bare or Expo: shared rules and workflows for Claude Code, Codex and Antigravity, git hooks, device checks with screenshots, and release tooling for the App Store and Google Play.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "prakashpro1",
|
|
@@ -20,7 +20,8 @@ This project may also use other AI workflow frameworks (for example Superpowers,
|
|
|
20
20
|
| Add a library (ask first) | `npx expo install <package>`: the version that matches the SDK |
|
|
21
21
|
| Lint, typecheck, test (each skips what the app doesn't have yet) | `sh scripts/amk/pm-run.sh lint`, `sh scripts/amk/pm-run.sh typecheck`, `sh scripts/amk/pm-run.sh test` |
|
|
22
22
|
| Check dependency versions and the app config | `npx expo install --check`, `npx expo-doctor` |
|
|
23
|
-
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/amk/verify.sh all --spec <id>`; another iOS scheme: `--scheme <name
|
|
23
|
+
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/amk/verify.sh all --spec <id>`; another iOS scheme: `--scheme <name>`; only some screens: `--screens phone` (or `tablet`, `landscape`, …) |
|
|
24
|
+
| Check every device at the same time, on a machine with room for it | `sh scripts/amk/verify.sh plan --spec <id>` says whether, and prints the commands: one per device, each for an `m-device-checker` subagent |
|
|
24
25
|
| Specs: progress, format check, fold a finished feature into the living spec | `node scripts/amk/specs.js status`, `node scripts/amk/specs.js check`, `node scripts/amk/specs.js merge <id>` |
|
|
25
26
|
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/amk/release-check.js` |
|
|
26
27
|
| Signed release builds (a person runs them: they use the signing keys) | `sh scripts/amk/release-build.sh android`, `sh scripts/amk/release-build.sh ios` |
|
|
@@ -19,7 +19,7 @@ Input: $ARGUMENTS (what's wrong, steps to reproduce, error text, screenshots, ta
|
|
|
19
19
|
- Form one hypothesis, test it, and confirm or reject it. One at a time.
|
|
20
20
|
- Fix the cause, not the symptom: no try/catch that hides the error, no special case for the failing input.
|
|
21
21
|
5. **Make the smallest fix.** Don't refactor or touch unrelated code.
|
|
22
|
-
6. **Verify.** The new test passes, and lint, typecheck and all tests pass. Paste the output. For UI or native bugs, run `sh scripts/amk/verify.sh ios` and/or `android` and look at the screenshots.
|
|
22
|
+
6. **Verify.** The new test passes, and lint, typecheck and all tests pass. Paste the output. For UI or native bugs, run `sh scripts/amk/verify.sh ios` and/or `android` and look at the screenshots; `--screens` limits it to the screens the bug is on (for example `--screens tablet-landscape`).
|
|
23
23
|
7. **Two attempts at most.** If two fixes didn't work, stop. Report what you tried, what you learned and what you suspect next.
|
|
24
24
|
8. **Record it.** If this kind of error could come back, add an entry to `docs/amk/known-issues.md` (error, cause, fix, prevention). If the fix changes what the app is meant to do, not just makes it work as specified, update that requirement in `specs/current/<area>.md` in the same format, and run `node scripts/amk/specs.js check`.
|
|
25
25
|
9. **Commit** with a clear message. Ask the user before pushing, then open a PR with the evidence.
|
|
@@ -37,7 +37,7 @@ If no requirement changes, as with a pure style change, skip the spec files (ste
|
|
|
37
37
|
1. Pick an ID: the task's ID if it has one, otherwise `YYYYMMDD-<slug>`. Write `specs/<id>/requirements.md` with a title, a one-line goal and only the requirements that change, under `## MODIFIED Requirements: <area>` (or ADDED or REMOVED; the format is in `specs/current/README.md`). Run `node scripts/amk/specs.js check specs/<id>/requirements.md`.
|
|
38
38
|
2. Change the code, and add or update a test where logic changed.
|
|
39
39
|
3. Run `sh scripts/amk/verify.sh quick` and show its output.
|
|
40
|
-
4. For a visible change, write `.maestro/<id>.yaml` from `specs/_templates/flow.yaml`: open the changed screen and take a screenshot.
|
|
40
|
+
4. For a visible change, write `.maestro/<id>.yaml` from `specs/_templates/flow.yaml`: open the changed screen and take a screenshot. Check it on the devices as `sh scripts/amk/verify.sh plan --spec <id>` says (one command, or each device in its own `m-device-checker` subagent at the same time, as in `m-feature`'s step 5), and open the screenshots in `.amk/evidence/<id>/`. Off a Mac it checks Android only: say that iOS still needs checking on a Mac.
|
|
41
41
|
5. Run `node scripts/amk/specs.js merge <id>` to update the living spec, and change the doc lines from step 3.
|
|
42
42
|
6. Copy `specs/_templates/progress.md` to `specs/<id>/progress.md`, set `Status: done`, and write down the checks and their results.
|
|
43
43
|
|
|
@@ -37,7 +37,7 @@ If the input describes a bug rather than new behavior, suggest `m-bugfix` and st
|
|
|
37
37
|
|
|
38
38
|
1. **Search the codebase before designing.** List the components, hooks, API clients and helpers you'll reuse in `design.md` under "Existing code to reuse". Read `docs/amk/structure.md` and `docs/amk/conventions.md`.
|
|
39
39
|
2. Fill `design.md`: approach, files to change, risks (native changes, pod install, migrations).
|
|
40
|
-
3. Fill `tasks.md`: small tasks (about an hour, under ~300 changed lines each). Each task names the requirement it serves and how it's checked, and its tests are written in the same task, not left for the end. The last task writes `.maestro/<id>.yaml` (from `specs/_templates/flow.yaml`): a Maestro flow with one step and screenshot per scenario, tapping elements by `testID
|
|
40
|
+
3. Fill `tasks.md`: small tasks (about an hour, under ~300 changed lines each). Each task names the requirement it serves and how it's checked, and its tests are written in the same task, not left for the end. The last task writes `.maestro/<id>.yaml` (from `specs/_templates/flow.yaml`): a Maestro flow with one step and screenshot per scenario, tapping elements by `testID` and scrolling to the ones further down a screen first (`scrollUntilVisible`): turned screens are short.
|
|
41
41
|
4. Show design and tasks and **stop until the user approves them**. Ask them to check that every task serves an approved requirement and nothing goes beyond the agreed scope.
|
|
42
42
|
|
|
43
43
|
From here the plan lives in files, so the building can also run in a fresh session or another tool with `m-continue <id>`.
|
|
@@ -55,7 +55,11 @@ If building shows the plan is wrong: when the intent is the same, update `requir
|
|
|
55
55
|
## 5. Check against the spec
|
|
56
56
|
|
|
57
57
|
When all tasks are done:
|
|
58
|
-
1. Run `sh scripts/amk/verify.sh
|
|
58
|
+
1. Run `sh scripts/amk/verify.sh plan --spec <id>`. It says whether this machine has room to check the devices at the same time, and prints the commands.
|
|
59
|
+
- **One command** (`verify.sh all --spec <id>`): run it. Then **open the screenshots** in `.amk/evidence/<id>/` and check each one against its scenario, in every screen's folder (phone, landscape, tablet).
|
|
60
|
+
- **A plan, and your tool has subagents:** run its `quick` and `build` commands as printed (nothing added: the plain commands are the ones people allow), then start one `m-device-checker` subagent per device command, all at once; each runs its device, checks its screenshots and hands back a report. When all are back, check them yourself: every flow passed, every screen has screenshots in its folder (list them), and open every screenshot a report flags plus at least one per screen. A report alone isn't evidence. Without subagents, run `verify.sh all --spec <id>` instead.
|
|
61
|
+
|
|
62
|
+
Off a Mac it checks Android only: record in `progress.md` that iOS still needs `verify.sh ios --spec <id>` on a Mac, and say so in the PR. A turned screen's screenshots are landscape; a portrait one means the app didn't turn. Maestro can report a tap as passed when nothing happened, so the screenshots are the evidence, not the log.
|
|
59
63
|
2. Go through every scenario and note its evidence: a test name, command output, or the screen checked. Where the code and the spec disagree, fix whichever is wrong, asking first if it's the spec. The spec must describe what ships.
|
|
60
64
|
|
|
61
65
|
## 6. Update the living spec and the docs
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: m-device-checker
|
|
3
|
+
targets: ["*"]
|
|
4
|
+
description: Checks the app on one device and reports the evidence. Use when `verify.sh plan` says to check the devices at the same time, one m-device-checker per device command, all started together.
|
|
5
|
+
claudecode:
|
|
6
|
+
tools: ["Read", "Grep", "Glob", "Bash"]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You check the app on one device with fresh eyes, and hand the evidence back. You never edit files.
|
|
10
|
+
|
|
11
|
+
1. Run the one command you were given exactly as it is, for example `sh scripts/amk/verify.sh ios --no-build --screens tablet --spec <id>`: no pipes, redirects or other commands added. Its output is short, and the plain command is the one people allow, so you don't wait on a permission prompt while the other checkers run. It installs the build that's there, runs the feature's Maestro flows on that device's screens (upright and turned), and saves screenshots in `.amk/evidence/<id>/<screen>/`. Don't build, and don't run anything else on a device: other checkers are using the other devices.
|
|
12
|
+
2. If a flow failed, read its log and Maestro's own log (the output names both) and say why, and whether the app or the flow is wrong: on a turned screen, a flow often checks or taps something further down without scrolling to it first. Don't fix anything.
|
|
13
|
+
3. Open every screenshot in your screens' folders and check each against its scenario in `specs/<id>/requirements.md`, and against the screen rules in the React Native rules file that `AGENTS.md` names: the right content, nothing cut off or covered, a layout made for that screen. A turned screen's screenshots are landscape; a portrait one means the app didn't turn.
|
|
14
|
+
4. Report, and say only what you saw in this run:
|
|
15
|
+
- the command, and its last lines of output;
|
|
16
|
+
- per screen: flows passed out of total, and the evidence folder;
|
|
17
|
+
- per screenshot: its path, and "matches" or the problem;
|
|
18
|
+
- anything you couldn't check, and why.
|
|
@@ -20,7 +20,8 @@ This project may also use other AI workflow frameworks (for example Superpowers,
|
|
|
20
20
|
| iOS pods (after native dependency changes) | `sh scripts/amk/pod-install.sh` |
|
|
21
21
|
| iOS build (simulator, no signing) | `sh scripts/amk/ios-build.sh` |
|
|
22
22
|
| Android build | `cd android && ./gradlew assembleDebug` |
|
|
23
|
-
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/amk/verify.sh all --spec <id>`; with product flavors it checks the first unless `--flavor <name>`; another iOS scheme: `--scheme <name
|
|
23
|
+
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/amk/verify.sh all --spec <id>`; with product flavors it checks the first unless `--flavor <name>`; another iOS scheme: `--scheme <name>`; only some screens: `--screens phone` (or `tablet`, `landscape`, …) |
|
|
24
|
+
| Check every device at the same time, on a machine with room for it | `sh scripts/amk/verify.sh plan --spec <id>` says whether, and prints the commands: one per device, each for an `m-device-checker` subagent |
|
|
24
25
|
| Specs: progress, format check, fold a finished feature into the living spec | `node scripts/amk/specs.js status`, `node scripts/amk/specs.js check`, `node scripts/amk/specs.js merge <id>` |
|
|
25
26
|
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/amk/release-check.js` |
|
|
26
27
|
| Signed release builds (a person runs them: they use the signing keys) | `sh scripts/amk/release-build.sh android [flavor]`, `sh scripts/amk/release-build.sh ios [scheme]` |
|
|
@@ -15,7 +15,7 @@ const inProgress = d => {
|
|
|
15
15
|
const specs = fs.existsSync('specs') ? fs.readdirSync('specs').filter(inProgress) : [];
|
|
16
16
|
if (specs.length === 0) process.exit(0); // no spec in progress (quick change, bug fix, or finished work)
|
|
17
17
|
|
|
18
|
-
const changed = execSync('git status --porcelain', { encoding: 'utf8' })
|
|
18
|
+
const changed = execSync('git status --porcelain --untracked-files=all', { encoding: 'utf8' }) // every new file, not just its new folder
|
|
19
19
|
.split('\n').filter(Boolean).map(l => l.slice(3));
|
|
20
20
|
const codeChanged = changed.some(f => !f.startsWith('specs/') && !f.startsWith('.amk/'));
|
|
21
21
|
const handoffUpdated = changed.some(f => /^specs\/[^/]+\/progress\.md$/.test(f));
|
|
@@ -3,30 +3,43 @@
|
|
|
3
3
|
# and Android emulator, running Maestro flows and saving screenshots as evidence. Apps that support tablets or
|
|
4
4
|
# landscape (scripts/amk/screens.js) are checked on each: an iPad simulator and a tablet emulator, and turned.
|
|
5
5
|
#
|
|
6
|
-
# Usage: sh scripts/amk/verify.sh [quick|ios|android|all] [--spec <id>] [--flow <file>] [--label <name>]
|
|
7
|
-
# [--flavor <name>] [--scheme <name>]
|
|
6
|
+
# Usage: sh scripts/amk/verify.sh [quick|ios|android|all|build|plan] [--spec <id>] [--flow <file>] [--label <name>]
|
|
7
|
+
# [--flavor <name>] [--scheme <name>] [--screens <list>] [--no-build]
|
|
8
8
|
# quick lint, typecheck, tests
|
|
9
9
|
# ios|android release build, install, run flows, screenshots
|
|
10
10
|
# all everything (default)
|
|
11
|
+
# build the release builds only, iOS and Android at the same time, for --no-build checks after it
|
|
12
|
+
# plan whether this machine can check the devices at the same time, and the commands to run
|
|
11
13
|
# --spec <id> run .maestro/<id>*.yaml and save evidence in .amk/evidence/<id>/
|
|
12
14
|
# --label <n> evidence folder name (default: the spec id, or a timestamp)
|
|
13
15
|
# --flavor <name> Android product flavor to check (default: the first one in build.gradle)
|
|
14
16
|
# --scheme <name> iOS scheme to check (default: the one named like the workspace)
|
|
17
|
+
# --screens <l> only these of the screens the app supports, comma-separated: phone, tablet, portrait,
|
|
18
|
+
# landscape, or one such as tablet-landscape
|
|
19
|
+
# --no-build check the last build instead of building again (after `build`)
|
|
15
20
|
# (no flows found: a smoke check that launches the app and takes a screenshot)
|
|
16
21
|
# Evidence per screen: ios/ and android/ (phone, portrait), then -landscape/, -tablet/ and -tablet-landscape/
|
|
17
|
-
# Env: AMK_ANDROID_FLAVOR, AMK_IOS_SCHEME (defaults for the
|
|
22
|
+
# Env: AMK_ANDROID_FLAVOR, AMK_IOS_SCHEME, AMK_SCREENS (defaults for the options), AMK_IOS_DEVICE (simulator name
|
|
18
23
|
# or UDID), AMK_ANDROID_DEVICE (adb serial: the only way to check on a phone, whose app data the flows clear),
|
|
19
24
|
# AMK_ANDROID_AVD (the emulator to use, started if it isn't running; other devices are left alone),
|
|
20
|
-
# AMK_IOS_TABLET (iPad simulator name or UDID), AMK_ANDROID_TABLET_AVD (tablet emulator), AMK_ANDROID_TABLET (serial)
|
|
25
|
+
# AMK_IOS_TABLET (iPad simulator name or UDID), AMK_ANDROID_TABLET_AVD (tablet emulator), AMK_ANDROID_TABLET (serial),
|
|
26
|
+
# AMK_PARALLEL (1 or 0: overrides plan's choice), AMK_DEVICE_WAIT (minutes to wait for a device in use, 30),
|
|
27
|
+
# AMK_LOCK_DIR (where runs on this machine claim devices; /tmp/agentic-mobile-kit-<user id>)
|
|
28
|
+
# A device in use by another run (any project on this machine) is skipped for a free one of the same kind, or waited
|
|
29
|
+
# for when it was named or none is free.
|
|
21
30
|
# Flows that log in read ${MAESTRO_EMAIL} and the like from a local, gitignored .maestro/.env.local (never committed).
|
|
22
31
|
set -eu
|
|
23
32
|
|
|
24
33
|
mode=${1:-all}
|
|
25
34
|
[ $# -gt 0 ] && shift
|
|
35
|
+
args=$* # for the commands plan prints
|
|
26
36
|
spec=""
|
|
27
37
|
flow=""
|
|
28
38
|
label=""
|
|
29
39
|
flavor=${AMK_ANDROID_FLAVOR:-}
|
|
40
|
+
only=${AMK_SCREENS:-}
|
|
41
|
+
no_build=0
|
|
42
|
+
build_only=0
|
|
30
43
|
while [ $# -gt 0 ]; do
|
|
31
44
|
case $1 in
|
|
32
45
|
--spec) spec=$2; shift 2 ;;
|
|
@@ -34,6 +47,8 @@ while [ $# -gt 0 ]; do
|
|
|
34
47
|
--label) label=$2; shift 2 ;;
|
|
35
48
|
--flavor) flavor=$2; shift 2 ;;
|
|
36
49
|
--scheme) AMK_IOS_SCHEME=$2; export AMK_IOS_SCHEME; shift 2 ;;
|
|
50
|
+
--screens) only=$2; shift 2 ;;
|
|
51
|
+
--no-build) no_build=1; shift ;;
|
|
37
52
|
*) echo "verify: unknown option $1"; exit 2 ;;
|
|
38
53
|
esac
|
|
39
54
|
done
|
|
@@ -51,23 +66,97 @@ flow_files() {
|
|
|
51
66
|
fi
|
|
52
67
|
}
|
|
53
68
|
|
|
69
|
+
# the screens to check on a platform: the ones the app supports, narrowed by --screens
|
|
70
|
+
screens_for() {
|
|
71
|
+
for s in $(node scripts/amk/screens.js "$1"); do
|
|
72
|
+
[ -n "$only" ] || { echo "$s"; continue; }
|
|
73
|
+
for w in $(echo "$only" | tr ',' ' '); do
|
|
74
|
+
case $s in "$w" | "$w"-* | *-"$w") echo "$s"; break ;; esac
|
|
75
|
+
done
|
|
76
|
+
done
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Maestro's version (the first lines may be an update notice), and whether it's at least $1
|
|
80
|
+
maestro_version() { maestro --version 2> /dev/null | tail -n 1 | tr -d '\r '; }
|
|
81
|
+
maestro_at_least() { [ "$(printf '%s\n%s\n' "$1" "$(maestro_version)" | sort -V | head -n 1)" = "$1" ]; }
|
|
82
|
+
|
|
83
|
+
# Locks shared by every project and agent on this machine, so two runs never use one device (or build one project)
|
|
84
|
+
# at once: a run claims a device by creating a folder named after it, and gives it back when it's done with it. A
|
|
85
|
+
# claim whose run ended without giving it back is taken over.
|
|
86
|
+
locks=${AMK_LOCK_DIR:-/tmp/agentic-mobile-kit-$(id -u 2> /dev/null || echo 0)}
|
|
87
|
+
mkdir -p "$locks" 2> /dev/null || true
|
|
88
|
+
project=$(printf %s "$root" | cksum | cut -d ' ' -f 1)
|
|
89
|
+
held=""
|
|
90
|
+
lock_path() { echo "$locks/$(printf %s "$1" | tr -c 'A-Za-z0-9._-' _)"; }
|
|
91
|
+
# whether a Maestro run started outside the kit is using device $1 (its command line names the device)
|
|
92
|
+
maestro_on() { ps -ax -o command 2> /dev/null | grep -E -- "--(device|udid)[ =]$1( |$)" | grep -q maestro; }
|
|
93
|
+
# claims $1 for this run; with a device ID in $2, also when no other Maestro run is using that device
|
|
94
|
+
claim() {
|
|
95
|
+
l=$(lock_path "$1")
|
|
96
|
+
if mkdir "$l" 2> /dev/null; then
|
|
97
|
+
printf '%s\n%s\n%s\n' "$$" "$(basename "$root") (${label:-${spec:-$mode}})" "$(date +%H:%M)" > "$l/owner"
|
|
98
|
+
held="$held $l"
|
|
99
|
+
if [ -n "${2:-}" ] && maestro_on "$2"; then unclaim "$1"; return 1; fi
|
|
100
|
+
return 0
|
|
101
|
+
fi
|
|
102
|
+
owner=$(sed -n 1p "$l/owner" 2> /dev/null || true)
|
|
103
|
+
[ "$owner" != "$$" ] || return 0 # this run holds it already
|
|
104
|
+
# its run ended, or was stopped before it could say who it was
|
|
105
|
+
if { [ -n "$owner" ] && ! kill -0 "$owner" 2> /dev/null; } || { [ -z "$owner" ] && [ -n "$(find "$l" -maxdepth 0 -mmin +1 2> /dev/null)" ]; }; then
|
|
106
|
+
rm -f "$l/owner"
|
|
107
|
+
rmdir "$l" 2> /dev/null && { claim "$@"; return; }
|
|
108
|
+
fi
|
|
109
|
+
return 1
|
|
110
|
+
}
|
|
111
|
+
unclaim() { l=$(lock_path "$1"); rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; held=$(echo "$held" | sed "s| $l||"); }
|
|
112
|
+
release() { for l in $held; do rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; done; held=""; }
|
|
113
|
+
trap release EXIT
|
|
114
|
+
trap 'exit 130' INT TERM
|
|
115
|
+
holder() {
|
|
116
|
+
l=$(lock_path "$1")
|
|
117
|
+
if [ -f "$l/owner" ]; then echo "$(sed -n 2p "$l/owner") since $(sed -n 3p "$l/owner")"; else echo "another Maestro run"; fi
|
|
118
|
+
}
|
|
119
|
+
# claims $1 as claim does, waiting while it's in use (AMK_DEVICE_WAIT minutes, 30 by default); $3 names it in messages
|
|
120
|
+
claim_wait() {
|
|
121
|
+
claim "$1" "${2:-}" && return 0
|
|
122
|
+
echo " waiting for $3: in use by $(holder "$1")"
|
|
123
|
+
waited=0
|
|
124
|
+
until claim "$1" "${2:-}"; do
|
|
125
|
+
[ "$waited" -lt $((${AMK_DEVICE_WAIT:-30} * 60)) ] || { echo " gave up waiting for $3 after ${AMK_DEVICE_WAIT:-30} minutes"; return 1; }
|
|
126
|
+
sleep 5
|
|
127
|
+
waited=$((waited + 5))
|
|
128
|
+
done
|
|
129
|
+
}
|
|
130
|
+
|
|
54
131
|
run_flow() { # screen device app_id file name orientation
|
|
55
132
|
# Maestro's own log, which has errors its output leaves out; it adds to the file, so one run's log at a time
|
|
56
133
|
debug="$evidence/maestro-logs/$1-$5"
|
|
57
|
-
mkdir -p "$debug"
|
|
134
|
+
mkdir -p "$debug" "$out/screenshots"
|
|
58
135
|
rm -f "$debug/maestro.log"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
136
|
+
find "$debug" -path '*/takeScreenshot/*.png' -exec rm -f {} + # an earlier run's, which aren't this run's evidence
|
|
137
|
+
target=$4
|
|
138
|
+
if [ "$6" != PORTRAIT ]; then
|
|
139
|
+
# a turned screen: the flow runs inside one that turns the device first and back to portrait after. Maestro
|
|
140
|
+
# reads the path in it itself, so it's a native path (a Windows path in Git Bash)
|
|
141
|
+
native=$(cd "$(dirname "$4")" && { pwd -W 2> /dev/null || pwd; })/$(basename "$4")
|
|
142
|
+
printf "appId: %s\nonFlowComplete:\n - setOrientation: PORTRAIT\n---\n- setOrientation: %s\n- runFlow: '%s'\n" "$3" "$6" "$native" > "$debug/screen.yaml"
|
|
143
|
+
target=$debug/screen.yaml
|
|
144
|
+
fi
|
|
145
|
+
# screenshots use relative names: older Maestro saves them in the current folder, then in --test-output-dir, and
|
|
146
|
+
# from 2.7 in the debug output under <flow>/takeScreenshot/, from where they join the screen's evidence
|
|
147
|
+
rc=0
|
|
64
148
|
(cd "$out" && maestro --device "$2" test --test-output-dir "$out" --debug-output "$debug" --flatten-debug-output \
|
|
65
|
-
-e APP_ID="$3" "$
|
|
149
|
+
-e APP_ID="$3" "$target" > "$out/$5.log" 2>&1) || rc=$?
|
|
150
|
+
find "$debug" -path '*/takeScreenshot/*.png' -exec cp {} "$out/screenshots/" \;
|
|
151
|
+
return $rc
|
|
66
152
|
}
|
|
67
153
|
|
|
68
|
-
run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
154
|
+
run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to turn it) [again]
|
|
69
155
|
out="$evidence/$1"
|
|
70
156
|
mkdir -p "$out"
|
|
157
|
+
# this run's screenshots are the ones newer than this; the status before it, for running the screen again
|
|
158
|
+
: > "$out/.started"
|
|
159
|
+
[ -n "${5:-}" ] || before=$status
|
|
71
160
|
files=$(flow_files)
|
|
72
161
|
if [ -z "$files" ]; then
|
|
73
162
|
# launchApp returns before the app has drawn, and a splash screen stays up until the JavaScript has loaded:
|
|
@@ -82,8 +171,13 @@ run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
|
82
171
|
name=$(basename "$f" .yaml)
|
|
83
172
|
ok=0
|
|
84
173
|
run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
|
|
85
|
-
#
|
|
86
|
-
|
|
174
|
+
# Maestro now and then stops before a flow starts (it printed nothing), and an emulator sometimes drops its adb
|
|
175
|
+
# connection for a moment: run the flow once more (after reconnecting)
|
|
176
|
+
if [ "$ok" != 0 ] && [ ! -s "$out/$name.log" ]; then
|
|
177
|
+
echo " $1: Maestro stopped before flow $name started; running it once more"
|
|
178
|
+
ok=0
|
|
179
|
+
run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
|
|
180
|
+
elif [ "$ok" != 0 ] && [ "${1%%-*}" = android ] && grep -qs 'device offline' "$debug/maestro.log"; then
|
|
87
181
|
echo " $1: the device went offline during flow $name; running it once more"
|
|
88
182
|
"$adb" reconnect offline > /dev/null 2>&1 || true
|
|
89
183
|
android_ready "$2" || true
|
|
@@ -97,30 +191,56 @@ run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
|
97
191
|
status=1
|
|
98
192
|
fi
|
|
99
193
|
done
|
|
100
|
-
# iOS saves a turned screen's screenshots
|
|
194
|
+
# iOS saves a turned screen's screenshots at the device's upright size, with a tag that tells viewers to turn them,
|
|
195
|
+
# and some viewers ignore it: save them turned (through BMP, which keeps no tag), so every viewer shows the screen
|
|
101
196
|
case $1 in
|
|
102
197
|
ios*-landscape) find "$out" -name '*.png' | while read -r png; do
|
|
103
|
-
sips -
|
|
104
|
-
|
|
198
|
+
sips -s format bmp "$png" --out "$png.bmp" > /dev/null && sips -s format png "$png.bmp" --out "$png" > /dev/null
|
|
199
|
+
rm -f "$png.bmp"
|
|
105
200
|
done ;;
|
|
106
201
|
esac
|
|
202
|
+
# a screen checked in the wrong orientation would pass for another screen: a turned one's screenshots are wider than
|
|
203
|
+
# tall, an upright one's taller than wide. A device that didn't turn usually does the next time
|
|
204
|
+
case $1 in *-landscape) want=wide was=upright ;; *) want=tall was=turned ;; esac
|
|
205
|
+
wrong=$(find "$out" -name '*.png' -newer "$out/.started" | WANT=$want node -e '
|
|
206
|
+
const fs = require("fs");
|
|
207
|
+
for (const f of fs.readFileSync(0, "utf8").split("\n").filter(Boolean)) {
|
|
208
|
+
const b = Buffer.alloc(24), fd = fs.openSync(f, "r");
|
|
209
|
+
fs.readSync(fd, b, 0, 24, 0);
|
|
210
|
+
fs.closeSync(fd);
|
|
211
|
+
if ((b.readUInt32BE(16) > b.readUInt32BE(20)) !== (process.env.WANT === "wide")) console.log(f);
|
|
212
|
+
}' | wc -l | tr -d ' ')
|
|
213
|
+
if [ "$wrong" != 0 ] && [ -z "${5:-}" ]; then
|
|
214
|
+
echo " $1: $wrong screenshots show the screen $was, not as this screen needs; running its flows once more"
|
|
215
|
+
find "$out" -name '*.png' -newer "$out/.started" -exec rm -f {} +
|
|
216
|
+
status=$before
|
|
217
|
+
run_flows "$1" "$2" "$3" "$4" again
|
|
218
|
+
return
|
|
219
|
+
fi
|
|
107
220
|
shots=$(find "$out" -name '*.png' | wc -l | tr -d ' ')
|
|
108
221
|
echo "$1: flows $passed/$total passed, $shots screenshots in ${out#"$root"/}"
|
|
109
222
|
if [ "$shots" = 0 ]; then
|
|
110
223
|
echo " $1: no screenshots were saved, so there's no evidence; treating this as a failure"
|
|
111
224
|
status=1
|
|
225
|
+
elif [ "$wrong" != 0 ]; then
|
|
226
|
+
echo " $1: $wrong screenshots show the screen $was: the device or the app didn't turn, so this screen isn't checked; treating this as a failure"
|
|
227
|
+
status=1
|
|
112
228
|
fi
|
|
113
229
|
}
|
|
114
230
|
|
|
115
|
-
# runs the flows on each screen
|
|
231
|
+
# runs the flows on each screen given: the phone upright into <platform>/, then <platform>-landscape/,
|
|
116
232
|
# <platform>-tablet/ and <platform>-tablet-landscape/
|
|
117
233
|
check_screens() { # platform phone tablet app_id screens…
|
|
118
234
|
p=$1 phone=$2 tab=$3 id=$4
|
|
119
235
|
shift 4
|
|
236
|
+
# before 2.6, two Maestro runs clash even on different devices (one port): checks on this machine take turns
|
|
237
|
+
if ! maestro_at_least 2.6.0; then
|
|
238
|
+
claim_wait maestro "" "Maestro (before 2.6 it runs one check at a time on this machine)" || { status=1; return; }
|
|
239
|
+
fi
|
|
120
240
|
for screen in "$@"; do
|
|
121
241
|
case $screen in
|
|
122
242
|
tablet-*) [ -n "$tab" ] || continue; on=$tab where=$p-tablet ;;
|
|
123
|
-
*) on=$phone where=$p ;;
|
|
243
|
+
*) [ -n "$phone" ] || continue; on=$phone where=$p ;;
|
|
124
244
|
esac
|
|
125
245
|
# Maestro turns an Android device from its natural orientation, which on most tablets is landscape
|
|
126
246
|
upright=PORTRAIT turned=LANDSCAPE_LEFT
|
|
@@ -128,11 +248,17 @@ check_screens() { # platform phone tablet app_id screens…
|
|
|
128
248
|
awk -F'[: x]+' '/Physical size/ { found = 1; wide = $3 + 0 > $4 + 0 } END { exit !(found && wide) }'; then
|
|
129
249
|
upright=LANDSCAPE_LEFT turned=PORTRAIT
|
|
130
250
|
fi
|
|
131
|
-
case $screen in
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
esac
|
|
251
|
+
case $screen in *-landscape) turn=$turned where=$where-landscape ;; *) turn=$upright ;; esac
|
|
252
|
+
# Maestro turns devices from 2.0 on, and taps the right place on a turned iPad from 2.3
|
|
253
|
+
need=2.0.0
|
|
254
|
+
case $where in ios-tablet*) need=2.3.0 ;; esac
|
|
255
|
+
if [ "$turn" != PORTRAIT ] && ! maestro_at_least $need; then
|
|
256
|
+
echo "$where: not checked: turning the device needs Maestro ${need%.0} or later (this is $(maestro_version))"
|
|
257
|
+
continue
|
|
258
|
+
fi
|
|
259
|
+
run_flows "$where" "$on" "$id" "$turn"
|
|
135
260
|
done
|
|
261
|
+
release # this platform's devices, and Maestro's turn, for other runs
|
|
136
262
|
}
|
|
137
263
|
|
|
138
264
|
quick() {
|
|
@@ -158,34 +284,50 @@ ios() {
|
|
|
158
284
|
[ "$mode" = ios ] && status=1
|
|
159
285
|
return
|
|
160
286
|
fi
|
|
161
|
-
command -v maestro > /dev/null || { echo "ios: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
287
|
+
[ "$build_only" = 1 ] || command -v maestro > /dev/null || { echo "ios: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
288
|
+
if [ "$no_build" = 0 ]; then
|
|
289
|
+
# Expo apps without native folders in git: generate ios/ first
|
|
290
|
+
if ! sh scripts/amk/prebuild.sh ios > "$evidence/prebuild-ios.log" 2>&1; then
|
|
291
|
+
echo "ios: expo prebuild FAILED, see ${evidence#"$root"/}/prebuild-ios.log"; status=1; return
|
|
292
|
+
fi
|
|
293
|
+
# pod install also generates React Native codegen files into ios/build/generated; a newer Podfile needs it again
|
|
294
|
+
if [ ! -d ios/Pods ] || [ ! -d ios/build/generated ] || [ ios/Podfile -nt ios/Pods/Manifest.lock ]; then
|
|
295
|
+
sh scripts/amk/pod-install.sh > "$evidence/pod-install.log" 2>&1
|
|
296
|
+
fi
|
|
169
297
|
fi
|
|
170
298
|
# the simulators first, so they boot while Xcode builds
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
299
|
+
device="" tablet=""
|
|
300
|
+
if [ "$build_only" = 0 ]; then
|
|
301
|
+
screens=$(screens_for ios)
|
|
302
|
+
[ -n "$screens" ] || { echo "ios: none of the app's screens is $only"; return; }
|
|
303
|
+
if echo "$screens" | grep -q '^phone-'; then
|
|
304
|
+
take_simulator iPhone "${AMK_IOS_DEVICE:-}" || { status=1; return; }
|
|
305
|
+
device=$taken
|
|
306
|
+
if [ -z "$device" ]; then
|
|
307
|
+
if [ -n "${AMK_IOS_DEVICE:-}" ]; then echo "ios: no simulator has the name or UDID \"$AMK_IOS_DEVICE\""; else echo "ios: no iPhone simulator found (set AMK_IOS_DEVICE)"; fi
|
|
308
|
+
status=1; return
|
|
309
|
+
fi
|
|
310
|
+
fi
|
|
311
|
+
if echo "$screens" | grep -q '^tablet-'; then
|
|
312
|
+
take_simulator iPad "${AMK_IOS_TABLET:-}" || { status=1; return; }
|
|
313
|
+
tablet=$taken
|
|
314
|
+
if [ -z "$tablet" ] && [ -n "${AMK_IOS_TABLET:-}" ]; then echo "ios: no simulator has the name or UDID \"$AMK_IOS_TABLET\""; status=1; return; fi
|
|
315
|
+
[ -n "$tablet" ] || echo "ios: the app runs on iPad, but there's no iPad simulator, so iPads aren't checked (add one in Xcode, or set AMK_IOS_TABLET)"
|
|
316
|
+
fi
|
|
317
|
+
for d in $device $tablet; do xcrun simctl boot "$d" 2> /dev/null || true; done
|
|
182
318
|
fi
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
319
|
+
# one build of this project at a time; a check without its own build waits for one that's under way
|
|
320
|
+
claim_wait "build-ios-$project" "" "the iOS build of this project" || { status=1; return; }
|
|
321
|
+
if [ "$no_build" = 0 ]; then
|
|
322
|
+
if ! CONFIGURATION=Release sh scripts/amk/ios-build.sh > "$evidence/ios-build.log" 2>&1; then
|
|
323
|
+
echo "ios: release build FAILED, see ${evidence#"$root"/}/ios-build.log"; status=1; return
|
|
324
|
+
fi
|
|
186
325
|
fi
|
|
326
|
+
unclaim "build-ios-$project"
|
|
327
|
+
[ "$build_only" = 0 ] || { echo "ios: release build done"; return; }
|
|
187
328
|
# the newest app: the scheme just built (another scheme's app may still be there from an earlier build)
|
|
188
|
-
app=$(ls -dt ios/DerivedData/Build/Products/*-iphonesimulator/*.app | head -n 1)
|
|
329
|
+
app=$(ls -dt ios/DerivedData/Build/Products/*-iphonesimulator/*.app 2> /dev/null | head -n 1)
|
|
330
|
+
[ -n "$app" ] || { echo "ios: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
|
|
189
331
|
app_id=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$app/Info.plist")
|
|
190
332
|
for d in $device $tablet; do
|
|
191
333
|
xcrun simctl bootstatus "$d" -b > /dev/null
|
|
@@ -194,18 +336,32 @@ ios() {
|
|
|
194
336
|
check_screens ios "$device" "$tablet" "$app_id" $screens
|
|
195
337
|
}
|
|
196
338
|
|
|
197
|
-
#
|
|
198
|
-
|
|
339
|
+
# the simulators for $1 (iPhone or iPad), best first: the one named in $2 (name or UDID); else the booted ones,
|
|
340
|
+
# then the others, newest iOS first
|
|
341
|
+
simulators() {
|
|
199
342
|
xcrun simctl list devices available -j | KIND=$1 WANT=$2 node -e '
|
|
200
343
|
const all = Object.entries(JSON.parse(require("fs").readFileSync(0, "utf8")).devices)
|
|
201
344
|
.flatMap(([rt, ds]) => ds.map(d => ({ ...d, v: (rt.match(/iOS-(\d+)-(\d+)/) || []).slice(1).map(Number) })))
|
|
202
345
|
.filter(d => d.v.length);
|
|
203
346
|
const want = process.env.WANT;
|
|
204
347
|
// by device type: a simulator can have any name, such as a separate one kept for tests
|
|
205
|
-
const kind = all.filter(d => (d.deviceTypeIdentifier || d.name).includes(process.env.KIND))
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
console.log(
|
|
348
|
+
const kind = all.filter(d => (d.deviceTypeIdentifier || d.name).includes(process.env.KIND))
|
|
349
|
+
.sort((a, b) => (b.state === "Booted") - (a.state === "Booted") || b.v[0] - a.v[0] || b.v[1] - a.v[1]);
|
|
350
|
+
const list = want ? all.filter(d => d.udid === want || d.name === want).slice(0, 1) : kind;
|
|
351
|
+
console.log(list.map(d => d.udid).join("\n"));'
|
|
352
|
+
}
|
|
353
|
+
# a simulator for $1 (iPhone or iPad) that this run holds, in $taken: the one named in $2, once it's free; else the
|
|
354
|
+
# first free one; else the best one, once it's free. Empty when there's none
|
|
355
|
+
take_simulator() {
|
|
356
|
+
taken=""
|
|
357
|
+
candidates=$(simulators "$1" "$2")
|
|
358
|
+
[ -n "$candidates" ] || return 0
|
|
359
|
+
first=$(echo "$candidates" | head -n 1)
|
|
360
|
+
if [ -z "$2" ]; then
|
|
361
|
+
for u in $candidates; do claim "ios-$u" "$u" && { taken=$u; break; }; done
|
|
362
|
+
[ -z "$taken" ] || [ "$taken" = "$first" ] || echo "ios: $first is in use by $(holder "ios-$first"), so checking on $taken"
|
|
363
|
+
fi
|
|
364
|
+
[ -n "$taken" ] || { claim_wait "ios-$first" "$first" "the $1 simulator $first" || return 1; taken=$first; }
|
|
209
365
|
}
|
|
210
366
|
|
|
211
367
|
# a running emulator's adb serial: of the AVD named in $1 if one is, else of the kind in $2 (phone or tablet) if given
|
|
@@ -233,11 +389,42 @@ avd_width() {
|
|
|
233
389
|
END { if (d) print int((w + 0 < h + 0 ? w : h) * 160 / d) }' \
|
|
234
390
|
"${ANDROID_AVD_HOME:-${ANDROID_USER_HOME:-$HOME/.android}/avd}/$1.avd/config.ini" 2> /dev/null || true
|
|
235
391
|
}
|
|
236
|
-
# the
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
392
|
+
# the emulators of the kind $1 (phone or tablet), best first: the running ones, then the others
|
|
393
|
+
emulators() {
|
|
394
|
+
{
|
|
395
|
+
for d in $("$adb" devices | awk 'NR > 1 && $2 == "device" && /^emulator-/ { print $1 }'); do
|
|
396
|
+
[ "$(kind_of "$(device_width "$d")")" != "$1" ] || "$adb" -s "$d" emu avd name 2> /dev/null | head -n 1 | tr -d '\r'
|
|
397
|
+
done
|
|
398
|
+
for a in $avds; do [ "$(kind_of "$(avd_width "$a")")" != "$1" ] || echo "$a"; done
|
|
399
|
+
} | awk 'NF && !seen[$0]++'
|
|
400
|
+
}
|
|
401
|
+
# an Android device of the kind $1 that this run holds, in $taken (its serial): the device ($2, an adb serial) or
|
|
402
|
+
# emulator ($3) named for it, once it's free; else the first free emulator of that kind, running or not; else the
|
|
403
|
+
# best one, once it's free. Empty when there's none of that kind. An emulator is claimed by its name, however named
|
|
404
|
+
take_android() {
|
|
405
|
+
taken="" pick=""
|
|
406
|
+
if [ -n "$2" ]; then
|
|
407
|
+
key=android-$2
|
|
408
|
+
case $2 in emulator-*) key=android-avd-$("$adb" -s "$2" emu avd name 2> /dev/null | head -n 1 | tr -d '\r') ;; esac
|
|
409
|
+
claim_wait "$key" "$2" "$2" || return 1
|
|
410
|
+
taken=$2
|
|
411
|
+
return 0
|
|
412
|
+
fi
|
|
413
|
+
if [ -n "$3" ]; then
|
|
414
|
+
echo "$avds" | grep -qxF "$3" || { echo "android: there's no emulator named $3 (see: emulator -list-avds)"; return 1; }
|
|
415
|
+
names=$3
|
|
416
|
+
else
|
|
417
|
+
names=$(emulators "$1")
|
|
418
|
+
fi
|
|
419
|
+
[ -n "$names" ] || return 0
|
|
420
|
+
first=$(echo "$names" | head -n 1)
|
|
421
|
+
if [ -z "$3" ]; then
|
|
422
|
+
for n in $names; do claim "android-avd-$n" "$(running_emulator "$n")" && { pick=$n; break; }; done
|
|
423
|
+
[ -z "$pick" ] || [ "$pick" = "$first" ] || echo "android: emulator $first is in use by $(holder "android-avd-$first"), so checking on $pick"
|
|
424
|
+
fi
|
|
425
|
+
[ -n "$pick" ] || { claim_wait "android-avd-$first" "$(running_emulator "$first")" "emulator $first" || return 1; pick=$first; }
|
|
426
|
+
taken=$(running_emulator "$pick")
|
|
427
|
+
[ -n "$taken" ] || taken=$(start_emulator "$pick") || { echo "android: emulator $pick didn't start"; return 1; }
|
|
241
428
|
}
|
|
242
429
|
# starts the AVD $1 and prints its serial once adb sees it (up to 5 minutes)
|
|
243
430
|
start_emulator() {
|
|
@@ -262,7 +449,7 @@ android_ready() {
|
|
|
262
449
|
}
|
|
263
450
|
|
|
264
451
|
android() {
|
|
265
|
-
command -v maestro > /dev/null || { echo "android: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
452
|
+
[ "$build_only" = 1 ] || command -v maestro > /dev/null || { echo "android: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
266
453
|
case $(uname -s) in # where Android Studio puts the SDK by default
|
|
267
454
|
Darwin) default_sdk=$HOME/Library/Android/sdk ;;
|
|
268
455
|
MINGW* | MSYS* | CYGWIN*) default_sdk=${LOCALAPPDATA:-$HOME/AppData/Local}/Android/Sdk ;;
|
|
@@ -271,7 +458,7 @@ android() {
|
|
|
271
458
|
sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$default_sdk}}
|
|
272
459
|
adb="$sdk/platform-tools/adb"
|
|
273
460
|
# Expo apps without native folders in git: generate android/ first
|
|
274
|
-
if ! sh scripts/amk/prebuild.sh android > "$evidence/prebuild-android.log" 2>&1; then
|
|
461
|
+
if [ "$no_build" = 0 ] && ! sh scripts/amk/prebuild.sh android > "$evidence/prebuild-android.log" 2>&1; then
|
|
275
462
|
echo "android: expo prebuild FAILED, see ${evidence#"$root"/}/prebuild-android.log"; status=1; return
|
|
276
463
|
fi
|
|
277
464
|
# apps with product flavors: check one, the first in build.gradle unless --flavor names another
|
|
@@ -287,68 +474,73 @@ android() {
|
|
|
287
474
|
[ -z "$flavor" ] || echo "android: checking the \"$flavor\" flavor (the app has: $(echo $flavors)); --flavor <name> checks another"
|
|
288
475
|
fi
|
|
289
476
|
variant=$(printf %s "$flavor" | awk '{ print toupper(substr($0, 1, 1)) substr($0, 2) }')
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
*) echo "android: checking on the phone $device; the flows clear the app's data on it" ;;
|
|
311
|
-
esac
|
|
312
|
-
tablet=""
|
|
313
|
-
if echo "$screens" | grep -q '^tablet-'; then
|
|
314
|
-
tablet=${AMK_ANDROID_TABLET:-$(running_emulator "${AMK_ANDROID_TABLET_AVD:-}" tablet)}
|
|
315
|
-
if [ -z "$tablet" ]; then
|
|
316
|
-
tablet_avd=${AMK_ANDROID_TABLET_AVD:-$(first_avd tablet)}
|
|
317
|
-
if [ -z "$tablet_avd" ]; then
|
|
318
|
-
echo "android: the app runs on tablets, but there's no tablet emulator, so tablets aren't checked (create one in Android Studio: Device Manager > Tablet, or set AMK_ANDROID_TABLET_AVD)"
|
|
319
|
-
elif ! echo "$avds" | grep -qxF "$tablet_avd"; then
|
|
320
|
-
echo "android: there's no emulator named $tablet_avd (see: emulator -list-avds)"; status=1; return
|
|
321
|
-
else
|
|
322
|
-
tablet=$(start_emulator "$tablet_avd") || { echo "android: emulator $tablet_avd didn't start, so tablets aren't checked"; tablet=""; }
|
|
477
|
+
device="" tablet=""
|
|
478
|
+
if [ "$build_only" = 1 ]; then
|
|
479
|
+
# no device to ask: emulators run this machine's CPU type
|
|
480
|
+
case $(uname -m) in arm64 | aarch64) abi=arm64-v8a ;; *) abi=x86_64 ;; esac
|
|
481
|
+
else
|
|
482
|
+
# the devices first: the build only needs the CPU type, and emulators boot while Gradle builds.
|
|
483
|
+
# The flows clear the app's data, so a phone plugged in over USB is used only when AMK_ANDROID_DEVICE names it
|
|
484
|
+
screens=$(screens_for android)
|
|
485
|
+
[ -n "$screens" ] || { echo "android: none of the app's screens is $only"; return; }
|
|
486
|
+
avds=$("$sdk/emulator/emulator" -list-avds 2> /dev/null || true)
|
|
487
|
+
if echo "$screens" | grep -q '^phone-'; then
|
|
488
|
+
take_android phone "${AMK_ANDROID_DEVICE:-}" "${AMK_ANDROID_AVD:-}" || { status=1; return; }
|
|
489
|
+
# only tablet emulators: one of them
|
|
490
|
+
[ -n "$taken" ] || take_android tablet "" "" || { status=1; return; }
|
|
491
|
+
device=$taken
|
|
492
|
+
if [ -z "$device" ]; then
|
|
493
|
+
phone=$("$adb" devices | awk 'NR > 1 && $2 == "device" { print $1; exit }')
|
|
494
|
+
echo "android: no emulator found (create one in Android Studio)"
|
|
495
|
+
[ -z "$phone" ] || echo " or check on the phone $phone, which clears the app's data on it: AMK_ANDROID_DEVICE=$phone sh scripts/amk/verify.sh android"
|
|
496
|
+
status=1; return
|
|
323
497
|
fi
|
|
498
|
+
case $device in
|
|
499
|
+
emulator-*) echo "android: checking on $device" ;;
|
|
500
|
+
*) echo "android: checking on the phone $device; the flows clear the app's data on it" ;;
|
|
501
|
+
esac
|
|
324
502
|
fi
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
[ "$
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
-Pandroid.injected.signing.key.alias=androiddebugkey -Pandroid.injected.signing.key.password=android
|
|
503
|
+
if echo "$screens" | grep -q '^tablet-'; then
|
|
504
|
+
take_android tablet "${AMK_ANDROID_TABLET:-}" "${AMK_ANDROID_TABLET_AVD:-}" || { status=1; return; }
|
|
505
|
+
tablet=$taken
|
|
506
|
+
[ -n "$tablet" ] || echo "android: the app runs on tablets, but there's no tablet emulator, so tablets aren't checked (create one in Android Studio: Device Manager > Tablet, or set AMK_ANDROID_TABLET_AVD)"
|
|
507
|
+
[ "$tablet" != "$device" ] || tablet="" # only tablet emulators: the one in use is checked as the phone
|
|
508
|
+
case $tablet in
|
|
509
|
+
"") ;;
|
|
510
|
+
emulator-*) echo "android: tablets on $tablet" ;;
|
|
511
|
+
*) echo "android: tablets on $tablet; the flows clear the app's data on it" ;;
|
|
512
|
+
esac
|
|
513
|
+
fi
|
|
514
|
+
[ -n "$device$tablet" ] || return
|
|
515
|
+
# an emulator that has just started (another one starting too) may not answer for a moment
|
|
516
|
+
first=${device:-$tablet}
|
|
517
|
+
tries=0
|
|
518
|
+
until abi=$("$adb" -s "$first" shell getprop ro.product.cpu.abi 2> /dev/null | tr -d '\r') && [ -n "$abi" ]; do
|
|
519
|
+
tries=$((tries + 1))
|
|
520
|
+
[ "$tries" -le 30 ] || { echo "android: device $first isn't connected (see: adb devices)"; status=1; return; }
|
|
521
|
+
sleep 2
|
|
522
|
+
done
|
|
346
523
|
fi
|
|
347
|
-
|
|
348
|
-
|
|
524
|
+
# one build of this project at a time; a check without its own build waits for one that's under way
|
|
525
|
+
claim_wait "build-android-$project" "" "the Android build of this project" || { status=1; return; }
|
|
526
|
+
if [ "$no_build" = 0 ]; then
|
|
527
|
+
# native code for that CPU type only, as run-android --active-arch-only does: much faster than all four
|
|
528
|
+
set -- -PreactNativeArchitectures="$abi"
|
|
529
|
+
# signed with the project's debug key, so the check build installs whatever key its real release needs
|
|
530
|
+
if [ -f android/app/debug.keystore ]; then
|
|
531
|
+
keystore=$(cd android/app && { pwd -W 2> /dev/null || pwd; })/debug.keystore # pwd -W: a Windows path in Git Bash
|
|
532
|
+
set -- "$@" -Pandroid.injected.signing.store.file="$keystore" -Pandroid.injected.signing.store.password=android \
|
|
533
|
+
-Pandroid.injected.signing.key.alias=androiddebugkey -Pandroid.injected.signing.key.password=android
|
|
534
|
+
fi
|
|
535
|
+
if ! (cd android && ./gradlew "assemble${variant}Release" --no-daemon -q "$@") > "$evidence/android-build.log" 2>&1; then
|
|
536
|
+
echo "android: release build FAILED, see ${evidence#"$root"/}/android-build.log"; status=1; return
|
|
537
|
+
fi
|
|
349
538
|
fi
|
|
539
|
+
unclaim "build-android-$project"
|
|
540
|
+
[ "$build_only" = 0 ] || { echo "android: release build done"; return; }
|
|
350
541
|
# apps that split APKs by CPU type get one per type: take this device's, else the universal one
|
|
351
|
-
apks=$(ls android/app/build/outputs/apk/${flavor:+$flavor/}release/*.apk)
|
|
542
|
+
apks=$(ls android/app/build/outputs/apk/${flavor:+$flavor/}release/*.apk 2> /dev/null || true)
|
|
543
|
+
[ -n "$apks" ] || { echo "android: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
|
|
352
544
|
apk=$(echo "$apks" | grep -e "-$abi-" | head -n 1)
|
|
353
545
|
[ -n "$apk" ] || apk=$(echo "$apks" | grep universal | head -n 1)
|
|
354
546
|
[ -n "$apk" ] || apk=$(echo "$apks" | head -n 1)
|
|
@@ -356,8 +548,10 @@ android() {
|
|
|
356
548
|
aapt2="$(ls -d "$sdk"/build-tools/*/ 2> /dev/null | sort -V | tail -n 1)aapt2"
|
|
357
549
|
app_id=$("$aapt2" dump badging "$apk" 2> /dev/null | sed -n "s/^package: name='\([^']*\)'.*/\1/p")
|
|
358
550
|
[ -n "$app_id" ] || app_id=$(sed -n 's/.*applicationId *=\{0,1\} *"\([^"]*\)".*/\1/p' android/app/build.gradle* | head -n 1)
|
|
359
|
-
|
|
360
|
-
|
|
551
|
+
if [ -n "$device" ]; then
|
|
552
|
+
android_ready "$device" || { echo "android: $device didn't finish starting (see: adb devices)"; status=1; return; }
|
|
553
|
+
"$adb" -s "$device" install -r "$apk" > /dev/null
|
|
554
|
+
fi
|
|
361
555
|
if [ -n "$tablet" ]; then
|
|
362
556
|
if ! android_ready "$tablet"; then echo "android: $tablet didn't finish starting, so tablets aren't checked"; tablet=""
|
|
363
557
|
elif ! "$adb" -s "$tablet" install -r "$apk" > /dev/null 2>&1; then
|
|
@@ -373,12 +567,64 @@ android() {
|
|
|
373
567
|
check_screens android "$device" "$tablet" "$app_id" $screens
|
|
374
568
|
}
|
|
375
569
|
|
|
570
|
+
# both release builds at the same time, each in its own log; the --no-build checks on each device come after
|
|
571
|
+
build() {
|
|
572
|
+
build_only=1
|
|
573
|
+
ios_pid=""
|
|
574
|
+
if [ "$(uname -s)" = Darwin ]; then
|
|
575
|
+
(trap release EXIT; ios; exit $status) > "$evidence/build-ios.out" 2>&1 &
|
|
576
|
+
ios_pid=$!
|
|
577
|
+
fi
|
|
578
|
+
(trap release EXIT; android; exit $status) > "$evidence/build-android.out" 2>&1 &
|
|
579
|
+
android_pid=$!
|
|
580
|
+
[ -z "$ios_pid" ] || wait "$ios_pid" || status=1
|
|
581
|
+
wait "$android_pid" || status=1
|
|
582
|
+
cat "$evidence"/build-*.out
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
# Checking every device at the same time, one subagent each, is faster where the machine has room: about 20 GB of
|
|
586
|
+
# memory for four devices and both builds, and Maestro 2.6 or later, which runs several devices at once
|
|
587
|
+
plan() {
|
|
588
|
+
set -- $(node -e 'const os = require("os"), fs = require("fs"), s = fs.statfsSync(".");
|
|
589
|
+
console.log(Math.round(os.totalmem() / 2 ** 30), Math.round(s.bavail * s.bsize / 2 ** 30))')
|
|
590
|
+
have="$1 GB of memory, $2 GB free disk, Maestro $(maestro_version)"
|
|
591
|
+
checks=""
|
|
592
|
+
if [ "$(uname -s)" = Darwin ]; then
|
|
593
|
+
for kind in phone tablet; do screens_for ios | grep -q "^$kind-" && checks="$checks ios:$kind"; done
|
|
594
|
+
fi
|
|
595
|
+
for kind in phone tablet; do screens_for android | grep -q "^$kind-" && checks="$checks android:$kind"; done
|
|
596
|
+
n=$(echo $checks | wc -w | tr -d ' ')
|
|
597
|
+
why=""
|
|
598
|
+
case ${AMK_PARALLEL:-} in
|
|
599
|
+
0) why="AMK_PARALLEL=0" ;;
|
|
600
|
+
1) ;;
|
|
601
|
+
*)
|
|
602
|
+
[ "$1" -ge 32 ] || why="it needs 32 GB of memory"
|
|
603
|
+
[ "$2" -ge 20 ] || why="${why:+$why and }it needs 20 GB free disk"
|
|
604
|
+
maestro_at_least 2.6.0 || why="${why:+$why and }it needs Maestro 2.6 or later" ;;
|
|
605
|
+
esac
|
|
606
|
+
[ "$n" -ge 2 ] || why="there's one device to check"
|
|
607
|
+
if [ -n "$why" ]; then
|
|
608
|
+
echo "plan: $have: one device at a time ($why; AMK_PARALLEL=1 overrides)"
|
|
609
|
+
echo " sh scripts/amk/verify.sh all${args:+ $args}"
|
|
610
|
+
return
|
|
611
|
+
fi
|
|
612
|
+
echo "plan: $have: check the $n devices at the same time"
|
|
613
|
+
echo " 1. sh scripts/amk/verify.sh quick${args:+ $args}"
|
|
614
|
+
echo " 2. sh scripts/amk/verify.sh build${args:+ $args}"
|
|
615
|
+
echo " 3. at the same time, each in its own subagent (m-device-checker), which checks its screenshots and reports:"
|
|
616
|
+
for c in $checks; do echo " sh scripts/amk/verify.sh ${c%:*} --no-build --screens ${c#*:}${args:+ $args}"; done
|
|
617
|
+
[ "$(uname -s)" = Darwin ] || echo " iOS isn't checked here: it needs a Mac with Xcode"
|
|
618
|
+
}
|
|
619
|
+
|
|
376
620
|
case $mode in
|
|
377
621
|
quick) quick ;;
|
|
378
622
|
ios) ios ;;
|
|
379
623
|
android) android ;;
|
|
380
624
|
all) quick; ios; android ;;
|
|
381
|
-
|
|
625
|
+
build) build ;;
|
|
626
|
+
plan) plan; exit 0 ;;
|
|
627
|
+
*) echo "verify: unknown mode $mode (quick, ios, android, all, build or plan)"; exit 2 ;;
|
|
382
628
|
esac
|
|
383
629
|
|
|
384
630
|
echo "Evidence: ${evidence#"$root"/}/ (open the screenshots: a tool saying 'passed' isn't proof)"
|
|
@@ -17,6 +17,10 @@ appId: ${APP_ID} # set by verify.sh
|
|
|
17
17
|
id: "<testID of the element>"
|
|
18
18
|
- takeScreenshot: <id>-1-<short-name>
|
|
19
19
|
# Scenario 2: …
|
|
20
|
+
# Something further down a screen can be off screen, most of all when it's turned (short): scroll to it first
|
|
21
|
+
- scrollUntilVisible:
|
|
22
|
+
element:
|
|
23
|
+
id: "<testID>"
|
|
20
24
|
- tapOn:
|
|
21
25
|
id: "<testID>"
|
|
22
26
|
- assertVisible: # what THEN expects, so the screenshot shows the result and not the screen before it
|