agentic-mobile-kit 0.7.8 → 0.7.9
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/verify.sh +225 -105
- 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.9",
|
|
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]` |
|
|
@@ -3,30 +3,40 @@
|
|
|
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)
|
|
21
27
|
# Flows that log in read ${MAESTRO_EMAIL} and the like from a local, gitignored .maestro/.env.local (never committed).
|
|
22
28
|
set -eu
|
|
23
29
|
|
|
24
30
|
mode=${1:-all}
|
|
25
31
|
[ $# -gt 0 ] && shift
|
|
32
|
+
args=$* # for the commands plan prints
|
|
26
33
|
spec=""
|
|
27
34
|
flow=""
|
|
28
35
|
label=""
|
|
29
36
|
flavor=${AMK_ANDROID_FLAVOR:-}
|
|
37
|
+
only=${AMK_SCREENS:-}
|
|
38
|
+
no_build=0
|
|
39
|
+
build_only=0
|
|
30
40
|
while [ $# -gt 0 ]; do
|
|
31
41
|
case $1 in
|
|
32
42
|
--spec) spec=$2; shift 2 ;;
|
|
@@ -34,6 +44,8 @@ while [ $# -gt 0 ]; do
|
|
|
34
44
|
--label) label=$2; shift 2 ;;
|
|
35
45
|
--flavor) flavor=$2; shift 2 ;;
|
|
36
46
|
--scheme) AMK_IOS_SCHEME=$2; export AMK_IOS_SCHEME; shift 2 ;;
|
|
47
|
+
--screens) only=$2; shift 2 ;;
|
|
48
|
+
--no-build) no_build=1; shift ;;
|
|
37
49
|
*) echo "verify: unknown option $1"; exit 2 ;;
|
|
38
50
|
esac
|
|
39
51
|
done
|
|
@@ -51,21 +63,44 @@ flow_files() {
|
|
|
51
63
|
fi
|
|
52
64
|
}
|
|
53
65
|
|
|
66
|
+
# the screens to check on a platform: the ones the app supports, narrowed by --screens
|
|
67
|
+
screens_for() {
|
|
68
|
+
for s in $(node scripts/amk/screens.js "$1"); do
|
|
69
|
+
[ -n "$only" ] || { echo "$s"; continue; }
|
|
70
|
+
for w in $(echo "$only" | tr ',' ' '); do
|
|
71
|
+
case $s in "$w" | "$w"-* | *-"$w") echo "$s"; break ;; esac
|
|
72
|
+
done
|
|
73
|
+
done
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# Maestro's version (the first lines may be an update notice), and whether it's at least $1
|
|
77
|
+
maestro_version() { maestro --version 2> /dev/null | tail -n 1 | tr -d '\r '; }
|
|
78
|
+
maestro_at_least() { [ "$(printf '%s\n%s\n' "$1" "$(maestro_version)" | sort -V | head -n 1)" = "$1" ]; }
|
|
79
|
+
|
|
54
80
|
run_flow() { # screen device app_id file name orientation
|
|
55
81
|
# 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
82
|
debug="$evidence/maestro-logs/$1-$5"
|
|
57
|
-
mkdir -p "$debug"
|
|
83
|
+
mkdir -p "$debug" "$out/screenshots"
|
|
58
84
|
rm -f "$debug/maestro.log"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
find "$debug" -path '*/takeScreenshot/*.png' -exec rm -f {} + # an earlier run's, which aren't this run's evidence
|
|
86
|
+
target=$4
|
|
87
|
+
if [ "$6" != PORTRAIT ]; then
|
|
88
|
+
# a turned screen: the flow runs inside one that turns the device first and back to portrait after. Maestro
|
|
89
|
+
# reads the path in it itself, so it's a native path (a Windows path in Git Bash)
|
|
90
|
+
native=$(cd "$(dirname "$4")" && { pwd -W 2> /dev/null || pwd; })/$(basename "$4")
|
|
91
|
+
printf "appId: %s\nonFlowComplete:\n - setOrientation: PORTRAIT\n---\n- setOrientation: %s\n- runFlow: '%s'\n" "$3" "$6" "$native" > "$debug/screen.yaml"
|
|
92
|
+
target=$debug/screen.yaml
|
|
93
|
+
fi
|
|
94
|
+
# screenshots use relative names: older Maestro saves them in the current folder, then in --test-output-dir, and
|
|
95
|
+
# from 2.7 in the debug output under <flow>/takeScreenshot/, from where they join the screen's evidence
|
|
96
|
+
rc=0
|
|
64
97
|
(cd "$out" && maestro --device "$2" test --test-output-dir "$out" --debug-output "$debug" --flatten-debug-output \
|
|
65
|
-
-e APP_ID="$3" "$
|
|
98
|
+
-e APP_ID="$3" "$target" > "$out/$5.log" 2>&1) || rc=$?
|
|
99
|
+
find "$debug" -path '*/takeScreenshot/*.png' -exec cp {} "$out/screenshots/" \;
|
|
100
|
+
return $rc
|
|
66
101
|
}
|
|
67
102
|
|
|
68
|
-
run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
103
|
+
run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to turn it)
|
|
69
104
|
out="$evidence/$1"
|
|
70
105
|
mkdir -p "$out"
|
|
71
106
|
files=$(flow_files)
|
|
@@ -97,11 +132,12 @@ run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
|
97
132
|
status=1
|
|
98
133
|
fi
|
|
99
134
|
done
|
|
100
|
-
# iOS saves a turned screen's screenshots
|
|
135
|
+
# iOS saves a turned screen's screenshots at the device's upright size, with a tag that tells viewers to turn them,
|
|
136
|
+
# and some viewers ignore it: save them turned (through BMP, which keeps no tag), so every viewer shows the screen
|
|
101
137
|
case $1 in
|
|
102
138
|
ios*-landscape) find "$out" -name '*.png' | while read -r png; do
|
|
103
|
-
sips -
|
|
104
|
-
|
|
139
|
+
sips -s format bmp "$png" --out "$png.bmp" > /dev/null && sips -s format png "$png.bmp" --out "$png" > /dev/null
|
|
140
|
+
rm -f "$png.bmp"
|
|
105
141
|
done ;;
|
|
106
142
|
esac
|
|
107
143
|
shots=$(find "$out" -name '*.png' | wc -l | tr -d ' ')
|
|
@@ -112,7 +148,7 @@ run_flows() { # screen device app_id orientation (PORTRAIT or LANDSCAPE_LEFT)
|
|
|
112
148
|
fi
|
|
113
149
|
}
|
|
114
150
|
|
|
115
|
-
# runs the flows on each screen
|
|
151
|
+
# runs the flows on each screen given: the phone upright into <platform>/, then <platform>-landscape/,
|
|
116
152
|
# <platform>-tablet/ and <platform>-tablet-landscape/
|
|
117
153
|
check_screens() { # platform phone tablet app_id screens…
|
|
118
154
|
p=$1 phone=$2 tab=$3 id=$4
|
|
@@ -120,7 +156,7 @@ check_screens() { # platform phone tablet app_id screens…
|
|
|
120
156
|
for screen in "$@"; do
|
|
121
157
|
case $screen in
|
|
122
158
|
tablet-*) [ -n "$tab" ] || continue; on=$tab where=$p-tablet ;;
|
|
123
|
-
*) on=$phone where=$p ;;
|
|
159
|
+
*) [ -n "$phone" ] || continue; on=$phone where=$p ;;
|
|
124
160
|
esac
|
|
125
161
|
# Maestro turns an Android device from its natural orientation, which on most tablets is landscape
|
|
126
162
|
upright=PORTRAIT turned=LANDSCAPE_LEFT
|
|
@@ -128,10 +164,15 @@ check_screens() { # platform phone tablet app_id screens…
|
|
|
128
164
|
awk -F'[: x]+' '/Physical size/ { found = 1; wide = $3 + 0 > $4 + 0 } END { exit !(found && wide) }'; then
|
|
129
165
|
upright=LANDSCAPE_LEFT turned=PORTRAIT
|
|
130
166
|
fi
|
|
131
|
-
case $screen in
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
esac
|
|
167
|
+
case $screen in *-landscape) turn=$turned where=$where-landscape ;; *) turn=$upright ;; esac
|
|
168
|
+
# Maestro turns devices from 2.0 on, and taps the right place on a turned iPad from 2.3
|
|
169
|
+
need=2.0.0
|
|
170
|
+
case $where in ios-tablet*) need=2.3.0 ;; esac
|
|
171
|
+
if [ "$turn" != PORTRAIT ] && ! maestro_at_least $need; then
|
|
172
|
+
echo "$where: not checked: turning the device needs Maestro ${need%.0} or later (this is $(maestro_version))"
|
|
173
|
+
continue
|
|
174
|
+
fi
|
|
175
|
+
run_flows "$where" "$on" "$id" "$turn"
|
|
135
176
|
done
|
|
136
177
|
}
|
|
137
178
|
|
|
@@ -158,34 +199,45 @@ ios() {
|
|
|
158
199
|
[ "$mode" = ios ] && status=1
|
|
159
200
|
return
|
|
160
201
|
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
|
-
|
|
202
|
+
[ "$build_only" = 1 ] || command -v maestro > /dev/null || { echo "ios: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
203
|
+
if [ "$no_build" = 0 ]; then
|
|
204
|
+
# Expo apps without native folders in git: generate ios/ first
|
|
205
|
+
if ! sh scripts/amk/prebuild.sh ios > "$evidence/prebuild-ios.log" 2>&1; then
|
|
206
|
+
echo "ios: expo prebuild FAILED, see ${evidence#"$root"/}/prebuild-ios.log"; status=1; return
|
|
207
|
+
fi
|
|
208
|
+
# pod install also generates React Native codegen files into ios/build/generated; a newer Podfile needs it again
|
|
209
|
+
if [ ! -d ios/Pods ] || [ ! -d ios/build/generated ] || [ ios/Podfile -nt ios/Pods/Manifest.lock ]; then
|
|
210
|
+
sh scripts/amk/pod-install.sh > "$evidence/pod-install.log" 2>&1
|
|
211
|
+
fi
|
|
169
212
|
fi
|
|
170
213
|
# the simulators first, so they boot while Xcode builds
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
214
|
+
device="" tablet=""
|
|
215
|
+
if [ "$build_only" = 0 ]; then
|
|
216
|
+
screens=$(screens_for ios)
|
|
217
|
+
[ -n "$screens" ] || { echo "ios: none of the app's screens is $only"; return; }
|
|
218
|
+
if echo "$screens" | grep -q '^phone-'; then
|
|
219
|
+
device=$(simulator iPhone "${AMK_IOS_DEVICE:-}")
|
|
220
|
+
if [ -z "$device" ]; then
|
|
221
|
+
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
|
|
222
|
+
status=1; return
|
|
223
|
+
fi
|
|
224
|
+
fi
|
|
225
|
+
if echo "$screens" | grep -q '^tablet-'; then
|
|
226
|
+
tablet=$(simulator iPad "${AMK_IOS_TABLET:-}")
|
|
227
|
+
if [ -z "$tablet" ] && [ -n "${AMK_IOS_TABLET:-}" ]; then echo "ios: no simulator has the name or UDID \"$AMK_IOS_TABLET\""; status=1; return; fi
|
|
228
|
+
[ -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)"
|
|
229
|
+
fi
|
|
230
|
+
for d in $device $tablet; do xcrun simctl boot "$d" 2> /dev/null || true; done
|
|
182
231
|
fi
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
232
|
+
if [ "$no_build" = 0 ]; then
|
|
233
|
+
if ! CONFIGURATION=Release sh scripts/amk/ios-build.sh > "$evidence/ios-build.log" 2>&1; then
|
|
234
|
+
echo "ios: release build FAILED, see ${evidence#"$root"/}/ios-build.log"; status=1; return
|
|
235
|
+
fi
|
|
236
|
+
[ "$build_only" = 0 ] || { echo "ios: release build done"; return; }
|
|
186
237
|
fi
|
|
187
238
|
# 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)
|
|
239
|
+
app=$(ls -dt ios/DerivedData/Build/Products/*-iphonesimulator/*.app 2> /dev/null | head -n 1)
|
|
240
|
+
[ -n "$app" ] || { echo "ios: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
|
|
189
241
|
app_id=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$app/Info.plist")
|
|
190
242
|
for d in $device $tablet; do
|
|
191
243
|
xcrun simctl bootstatus "$d" -b > /dev/null
|
|
@@ -262,7 +314,7 @@ android_ready() {
|
|
|
262
314
|
}
|
|
263
315
|
|
|
264
316
|
android() {
|
|
265
|
-
command -v maestro > /dev/null || { echo "android: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
317
|
+
[ "$build_only" = 1 ] || command -v maestro > /dev/null || { echo "android: Maestro isn't installed (https://maestro.dev)"; status=1; return; }
|
|
266
318
|
case $(uname -s) in # where Android Studio puts the SDK by default
|
|
267
319
|
Darwin) default_sdk=$HOME/Library/Android/sdk ;;
|
|
268
320
|
MINGW* | MSYS* | CYGWIN*) default_sdk=${LOCALAPPDATA:-$HOME/AppData/Local}/Android/Sdk ;;
|
|
@@ -271,7 +323,7 @@ android() {
|
|
|
271
323
|
sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$default_sdk}}
|
|
272
324
|
adb="$sdk/platform-tools/adb"
|
|
273
325
|
# 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
|
|
326
|
+
if [ "$no_build" = 0 ] && ! sh scripts/amk/prebuild.sh android > "$evidence/prebuild-android.log" 2>&1; then
|
|
275
327
|
echo "android: expo prebuild FAILED, see ${evidence#"$root"/}/prebuild-android.log"; status=1; return
|
|
276
328
|
fi
|
|
277
329
|
# apps with product flavors: check one, the first in build.gradle unless --flavor names another
|
|
@@ -287,68 +339,82 @@ android() {
|
|
|
287
339
|
[ -z "$flavor" ] || echo "android: checking the \"$flavor\" flavor (the app has: $(echo $flavors)); --flavor <name> checks another"
|
|
288
340
|
fi
|
|
289
341
|
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
|
-
|
|
342
|
+
device="" tablet=""
|
|
343
|
+
if [ "$build_only" = 1 ]; then
|
|
344
|
+
# no device to ask: emulators run this machine's CPU type
|
|
345
|
+
case $(uname -m) in arm64 | aarch64) abi=arm64-v8a ;; *) abi=x86_64 ;; esac
|
|
346
|
+
else
|
|
347
|
+
# the devices first: the build only needs the CPU type, and emulators boot while Gradle builds.
|
|
348
|
+
# The flows clear the app's data, so a phone plugged in over USB is used only when AMK_ANDROID_DEVICE names it
|
|
349
|
+
screens=$(screens_for android)
|
|
350
|
+
[ -n "$screens" ] || { echo "android: none of the app's screens is $only"; return; }
|
|
351
|
+
avds=$("$sdk/emulator/emulator" -list-avds 2> /dev/null || true)
|
|
352
|
+
if echo "$screens" | grep -q '^phone-'; then
|
|
353
|
+
device=${AMK_ANDROID_DEVICE:-$(running_emulator "${AMK_ANDROID_AVD:-}" phone)}
|
|
354
|
+
if [ -z "$device" ]; then
|
|
355
|
+
avd=${AMK_ANDROID_AVD:-$(first_avd phone)}
|
|
356
|
+
[ -n "$avd" ] || avd=$(echo "$avds" | head -n 1) # only tablet emulators: one of them
|
|
357
|
+
if [ -n "$avd" ]; then
|
|
358
|
+
echo "$avds" | grep -qxF "$avd" || { echo "android: there's no emulator named $avd (see: emulator -list-avds)"; status=1; return; }
|
|
359
|
+
device=$(start_emulator "$avd") || { echo "android: emulator $avd didn't start"; status=1; return; }
|
|
360
|
+
else
|
|
361
|
+
phone=$("$adb" devices | awk 'NR > 1 && $2 == "device" { print $1; exit }')
|
|
362
|
+
echo "android: no emulator found (create one in Android Studio)"
|
|
363
|
+
[ -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"
|
|
364
|
+
status=1; return
|
|
365
|
+
fi
|
|
366
|
+
fi
|
|
367
|
+
case $device in
|
|
368
|
+
emulator-*) echo "android: checking on $device" ;;
|
|
369
|
+
*) echo "android: checking on the phone $device; the flows clear the app's data on it" ;;
|
|
370
|
+
esac
|
|
306
371
|
fi
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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=""; }
|
|
372
|
+
if echo "$screens" | grep -q '^tablet-'; then
|
|
373
|
+
tablet=${AMK_ANDROID_TABLET:-$(running_emulator "${AMK_ANDROID_TABLET_AVD:-}" tablet)}
|
|
374
|
+
if [ -z "$tablet" ]; then
|
|
375
|
+
tablet_avd=${AMK_ANDROID_TABLET_AVD:-$(first_avd tablet)}
|
|
376
|
+
if [ -z "$tablet_avd" ]; then
|
|
377
|
+
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)"
|
|
378
|
+
elif ! echo "$avds" | grep -qxF "$tablet_avd"; then
|
|
379
|
+
echo "android: there's no emulator named $tablet_avd (see: emulator -list-avds)"; status=1; return
|
|
380
|
+
else
|
|
381
|
+
tablet=$(start_emulator "$tablet_avd") || { echo "android: emulator $tablet_avd didn't start, so tablets aren't checked"; tablet=""; }
|
|
382
|
+
fi
|
|
323
383
|
fi
|
|
384
|
+
[ "$tablet" != "$device" ] || tablet="" # only tablet emulators: the one in use is checked as the phone
|
|
385
|
+
case $tablet in
|
|
386
|
+
"") ;;
|
|
387
|
+
emulator-*) echo "android: tablets on $tablet" ;;
|
|
388
|
+
*) echo "android: tablets on $tablet; the flows clear the app's data on it" ;;
|
|
389
|
+
esac
|
|
324
390
|
fi
|
|
325
|
-
[
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
until abi=$("$adb" -s "$device" shell getprop ro.product.cpu.abi 2> /dev/null | tr -d '\r') && [ -n "$abi" ]; do
|
|
335
|
-
tries=$((tries + 1))
|
|
336
|
-
[ "$tries" -le 30 ] || { echo "android: device $device isn't connected (see: adb devices)"; status=1; return; }
|
|
337
|
-
sleep 2
|
|
338
|
-
done
|
|
339
|
-
# native code for that CPU type only, as run-android --active-arch-only does: much faster than all four
|
|
340
|
-
set -- -PreactNativeArchitectures="$abi"
|
|
341
|
-
# signed with the project's debug key, so the check build installs whatever key its real release needs
|
|
342
|
-
if [ -f android/app/debug.keystore ]; then
|
|
343
|
-
keystore=$(cd android/app && { pwd -W 2> /dev/null || pwd; })/debug.keystore # pwd -W: a Windows path in Git Bash
|
|
344
|
-
set -- "$@" -Pandroid.injected.signing.store.file="$keystore" -Pandroid.injected.signing.store.password=android \
|
|
345
|
-
-Pandroid.injected.signing.key.alias=androiddebugkey -Pandroid.injected.signing.key.password=android
|
|
391
|
+
[ -n "$device$tablet" ] || return
|
|
392
|
+
# an emulator that has just started (another one starting too) may not answer for a moment
|
|
393
|
+
first=${device:-$tablet}
|
|
394
|
+
tries=0
|
|
395
|
+
until abi=$("$adb" -s "$first" shell getprop ro.product.cpu.abi 2> /dev/null | tr -d '\r') && [ -n "$abi" ]; do
|
|
396
|
+
tries=$((tries + 1))
|
|
397
|
+
[ "$tries" -le 30 ] || { echo "android: device $first isn't connected (see: adb devices)"; status=1; return; }
|
|
398
|
+
sleep 2
|
|
399
|
+
done
|
|
346
400
|
fi
|
|
347
|
-
if
|
|
348
|
-
|
|
401
|
+
if [ "$no_build" = 0 ]; then
|
|
402
|
+
# native code for that CPU type only, as run-android --active-arch-only does: much faster than all four
|
|
403
|
+
set -- -PreactNativeArchitectures="$abi"
|
|
404
|
+
# signed with the project's debug key, so the check build installs whatever key its real release needs
|
|
405
|
+
if [ -f android/app/debug.keystore ]; then
|
|
406
|
+
keystore=$(cd android/app && { pwd -W 2> /dev/null || pwd; })/debug.keystore # pwd -W: a Windows path in Git Bash
|
|
407
|
+
set -- "$@" -Pandroid.injected.signing.store.file="$keystore" -Pandroid.injected.signing.store.password=android \
|
|
408
|
+
-Pandroid.injected.signing.key.alias=androiddebugkey -Pandroid.injected.signing.key.password=android
|
|
409
|
+
fi
|
|
410
|
+
if ! (cd android && ./gradlew "assemble${variant}Release" --no-daemon -q "$@") > "$evidence/android-build.log" 2>&1; then
|
|
411
|
+
echo "android: release build FAILED, see ${evidence#"$root"/}/android-build.log"; status=1; return
|
|
412
|
+
fi
|
|
413
|
+
[ "$build_only" = 0 ] || { echo "android: release build done"; return; }
|
|
349
414
|
fi
|
|
350
415
|
# 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)
|
|
416
|
+
apks=$(ls android/app/build/outputs/apk/${flavor:+$flavor/}release/*.apk 2> /dev/null || true)
|
|
417
|
+
[ -n "$apks" ] || { echo "android: there's no build to check yet: run sh scripts/amk/verify.sh build first"; status=1; return; }
|
|
352
418
|
apk=$(echo "$apks" | grep -e "-$abi-" | head -n 1)
|
|
353
419
|
[ -n "$apk" ] || apk=$(echo "$apks" | grep universal | head -n 1)
|
|
354
420
|
[ -n "$apk" ] || apk=$(echo "$apks" | head -n 1)
|
|
@@ -356,8 +422,10 @@ android() {
|
|
|
356
422
|
aapt2="$(ls -d "$sdk"/build-tools/*/ 2> /dev/null | sort -V | tail -n 1)aapt2"
|
|
357
423
|
app_id=$("$aapt2" dump badging "$apk" 2> /dev/null | sed -n "s/^package: name='\([^']*\)'.*/\1/p")
|
|
358
424
|
[ -n "$app_id" ] || app_id=$(sed -n 's/.*applicationId *=\{0,1\} *"\([^"]*\)".*/\1/p' android/app/build.gradle* | head -n 1)
|
|
359
|
-
|
|
360
|
-
|
|
425
|
+
if [ -n "$device" ]; then
|
|
426
|
+
android_ready "$device" || { echo "android: $device didn't finish starting (see: adb devices)"; status=1; return; }
|
|
427
|
+
"$adb" -s "$device" install -r "$apk" > /dev/null
|
|
428
|
+
fi
|
|
361
429
|
if [ -n "$tablet" ]; then
|
|
362
430
|
if ! android_ready "$tablet"; then echo "android: $tablet didn't finish starting, so tablets aren't checked"; tablet=""
|
|
363
431
|
elif ! "$adb" -s "$tablet" install -r "$apk" > /dev/null 2>&1; then
|
|
@@ -373,12 +441,64 @@ android() {
|
|
|
373
441
|
check_screens android "$device" "$tablet" "$app_id" $screens
|
|
374
442
|
}
|
|
375
443
|
|
|
444
|
+
# both release builds at the same time, each in its own log; the --no-build checks on each device come after
|
|
445
|
+
build() {
|
|
446
|
+
build_only=1
|
|
447
|
+
ios_pid=""
|
|
448
|
+
if [ "$(uname -s)" = Darwin ]; then
|
|
449
|
+
(ios; exit $status) > "$evidence/build-ios.out" 2>&1 &
|
|
450
|
+
ios_pid=$!
|
|
451
|
+
fi
|
|
452
|
+
(android; exit $status) > "$evidence/build-android.out" 2>&1 &
|
|
453
|
+
android_pid=$!
|
|
454
|
+
[ -z "$ios_pid" ] || wait "$ios_pid" || status=1
|
|
455
|
+
wait "$android_pid" || status=1
|
|
456
|
+
cat "$evidence"/build-*.out
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
# Checking every device at the same time, one subagent each, is faster where the machine has room: about 20 GB of
|
|
460
|
+
# memory for four devices and both builds, and Maestro 2.6 or later, which runs several devices at once
|
|
461
|
+
plan() {
|
|
462
|
+
set -- $(node -e 'const os = require("os"), fs = require("fs"), s = fs.statfsSync(".");
|
|
463
|
+
console.log(Math.round(os.totalmem() / 2 ** 30), Math.round(s.bavail * s.bsize / 2 ** 30))')
|
|
464
|
+
have="$1 GB of memory, $2 GB free disk, Maestro $(maestro_version)"
|
|
465
|
+
checks=""
|
|
466
|
+
if [ "$(uname -s)" = Darwin ]; then
|
|
467
|
+
for kind in phone tablet; do screens_for ios | grep -q "^$kind-" && checks="$checks ios:$kind"; done
|
|
468
|
+
fi
|
|
469
|
+
for kind in phone tablet; do screens_for android | grep -q "^$kind-" && checks="$checks android:$kind"; done
|
|
470
|
+
n=$(echo $checks | wc -w | tr -d ' ')
|
|
471
|
+
why=""
|
|
472
|
+
case ${AMK_PARALLEL:-} in
|
|
473
|
+
0) why="AMK_PARALLEL=0" ;;
|
|
474
|
+
1) ;;
|
|
475
|
+
*)
|
|
476
|
+
[ "$1" -ge 32 ] || why="it needs 32 GB of memory"
|
|
477
|
+
[ "$2" -ge 20 ] || why="${why:+$why and }it needs 20 GB free disk"
|
|
478
|
+
maestro_at_least 2.6.0 || why="${why:+$why and }it needs Maestro 2.6 or later" ;;
|
|
479
|
+
esac
|
|
480
|
+
[ "$n" -ge 2 ] || why="there's one device to check"
|
|
481
|
+
if [ -n "$why" ]; then
|
|
482
|
+
echo "plan: $have: one device at a time ($why; AMK_PARALLEL=1 overrides)"
|
|
483
|
+
echo " sh scripts/amk/verify.sh all${args:+ $args}"
|
|
484
|
+
return
|
|
485
|
+
fi
|
|
486
|
+
echo "plan: $have: check the $n devices at the same time"
|
|
487
|
+
echo " 1. sh scripts/amk/verify.sh quick${args:+ $args}"
|
|
488
|
+
echo " 2. sh scripts/amk/verify.sh build${args:+ $args}"
|
|
489
|
+
echo " 3. at the same time, each in its own subagent (m-device-checker), which checks its screenshots and reports:"
|
|
490
|
+
for c in $checks; do echo " sh scripts/amk/verify.sh ${c%:*} --no-build --screens ${c#*:}${args:+ $args}"; done
|
|
491
|
+
[ "$(uname -s)" = Darwin ] || echo " iOS isn't checked here: it needs a Mac with Xcode"
|
|
492
|
+
}
|
|
493
|
+
|
|
376
494
|
case $mode in
|
|
377
495
|
quick) quick ;;
|
|
378
496
|
ios) ios ;;
|
|
379
497
|
android) android ;;
|
|
380
498
|
all) quick; ios; android ;;
|
|
381
|
-
|
|
499
|
+
build) build ;;
|
|
500
|
+
plan) plan; exit 0 ;;
|
|
501
|
+
*) echo "verify: unknown mode $mode (quick, ios, android, all, build or plan)"; exit 2 ;;
|
|
382
502
|
esac
|
|
383
503
|
|
|
384
504
|
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
|