agentic-mobile-kit 0.7.13 → 0.7.15
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/lib/doctor.js +3 -2
- package/lib/init.js +24 -2
- package/package.json +1 -1
- package/stacks/react-native/expo/AGENTS.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 +2 -2
- package/stacks/react-native/template/.rulesync/hooks.jsonc +6 -3
- package/stacks/react-native/template/.rulesync/subagents/m-device-checker.md +2 -2
- package/stacks/react-native/template/AGENTS.md +1 -1
- package/stacks/react-native/template/scripts/amk/guard.js +4 -1
- package/stacks/react-native/template/scripts/amk/handoff-check.js +6 -3
- package/stacks/react-native/template/scripts/amk/verify.sh +219 -27
package/lib/doctor.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const { spawnSync } = require('child_process');
|
|
7
|
-
const { tool, hookManager, hooksWired, kitRun, checkProject, emptyFolder } = require('./init');
|
|
7
|
+
const { tool, hookManager, hooksWired, kitRun, ignoredByGit, checkProject, emptyFolder } = require('./init');
|
|
8
8
|
const screens = require('../stacks/react-native/template/scripts/amk/screens.js');
|
|
9
9
|
|
|
10
10
|
const RULESYNC = 'rulesync@27.0.0';
|
|
@@ -55,7 +55,8 @@ function projectChecks(cwd, opts) {
|
|
|
55
55
|
const hooksPath = run('git', ['config', 'core.hooksPath'], { cwd });
|
|
56
56
|
out.push(hooksPath === '.githooks'
|
|
57
57
|
? ok('Git hooks active')
|
|
58
|
-
|
|
58
|
+
// with .githooks kept out of git, install doesn't turn them on: sync does, as it puts the folder back
|
|
59
|
+
: fail('Git hooks not active on this clone', ignoredByGit(cwd, '.githooks/pre-commit') ? 'run: npx agentic-mobile-kit sync' : 'run: git config core.hooksPath .githooks (your package manager\'s install does this too)'));
|
|
59
60
|
} else if (manager.manual) {
|
|
60
61
|
out.push(warn(`Git hooks run from ${manager.name}, without the kit's checks`, `add "${kitRun('pre-commit')}" and "${kitRun('pre-push')}" to those hooks`));
|
|
61
62
|
} else if (!hooksWired(cwd, manager)) {
|
package/lib/init.js
CHANGED
|
@@ -653,13 +653,19 @@ function finish(cwd, { pkg, deps, tools, files, stack, skipGenerate }) {
|
|
|
653
653
|
// only TypeScript projects get typecheck: tsc fails ("no inputs") in JavaScript apps that merely have typescript installed
|
|
654
654
|
if (!scripts.typecheck && deps.typescript && usesTs(cwd)) { scripts.typecheck = 'tsc --noEmit'; pkgChanged = true; }
|
|
655
655
|
const manager = hookManager(cwd, pkg);
|
|
656
|
+
// a team may keep .githooks out of git: a fresh clone has none until it runs sync, which also turns the hooks on
|
|
657
|
+
const keptOut = ignoredByGit(cwd, '.githooks/pre-commit');
|
|
656
658
|
if (manager) {
|
|
657
659
|
// the project's hook manager runs the kit's hooks; drop the postinstall earlier kit versions added, which fought it
|
|
658
660
|
if (dropHooksCmd(scripts)) pkgChanged = true;
|
|
659
661
|
if (wireHooks(cwd, manager, done)) pkgChanged = true;
|
|
660
|
-
if (!manager.manual &&
|
|
662
|
+
if (!manager.manual && keptOut) {
|
|
661
663
|
done.warnings.push(`.githooks is kept out of git here, so a fresh clone has none until it runs npx agentic-mobile-kit sync. Until then, ${manager.name} skips the kit's checks and says so`);
|
|
662
664
|
}
|
|
665
|
+
} else if (keptOut) {
|
|
666
|
+
// pointing git at a folder a fresh clone doesn't have would switch off every hook there, other tools' too
|
|
667
|
+
if (dropHooksCmd(scripts)) pkgChanged = true;
|
|
668
|
+
done.warnings.push('.githooks is kept out of git here, so a fresh clone has none until it runs npx agentic-mobile-kit sync, which turns the kit\'s hooks on. Until then, git runs only the hooks in .git/hooks there');
|
|
663
669
|
} else if (!(scripts.postinstall || '').includes('core.hooksPath')) {
|
|
664
670
|
// parentheses keep the existing script's failure behavior: `a && b || true` would hide a failing `a`
|
|
665
671
|
scripts.postinstall = scripts.postinstall ? `${scripts.postinstall} && (${HOOKS_CMD})` : HOOKS_CMD;
|
|
@@ -712,11 +718,27 @@ function finish(cwd, { pkg, deps, tools, files, stack, skipGenerate }) {
|
|
|
712
718
|
if (!skipGenerate) {
|
|
713
719
|
const r = tool('npx', ['-y', RULESYNC, 'generate'], { cwd, env: cleanEnv(), encoding: 'utf8' });
|
|
714
720
|
generated = r.status === 0;
|
|
721
|
+
if (generated) flattenAntigravityStop(cwd);
|
|
715
722
|
if (!generated) generateError = `${r.stderr || ''}${r.stdout || ''}`.trim().split('\n').slice(-12).join('\n');
|
|
716
723
|
}
|
|
717
724
|
return { done, generated, generateError };
|
|
718
725
|
}
|
|
719
726
|
|
|
727
|
+
// rulesync before 40 writes Antigravity's Stop hooks in the matcher shape ([{ hooks: [...] }]). Antigravity takes them
|
|
728
|
+
// as a plain list of handlers and rejects the rest, which drops the whole hook set, guard included
|
|
729
|
+
function flattenAntigravityStop(cwd) {
|
|
730
|
+
const file = path.join(cwd, '.agents/hooks.json');
|
|
731
|
+
let hooks;
|
|
732
|
+
try { hooks = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return; }
|
|
733
|
+
let changed = false;
|
|
734
|
+
for (const set of Object.values(hooks)) {
|
|
735
|
+
if (!set || !Array.isArray(set.Stop) || !set.Stop.some(e => e && Array.isArray(e.hooks) && !e.command)) continue;
|
|
736
|
+
set.Stop = set.Stop.flatMap(e => (e && Array.isArray(e.hooks) && !e.command ? e.hooks : [e]));
|
|
737
|
+
changed = true;
|
|
738
|
+
}
|
|
739
|
+
if (changed) fs.writeFileSync(file, `${JSON.stringify(hooks, null, 2)}\n`);
|
|
740
|
+
}
|
|
741
|
+
|
|
720
742
|
function init(cwd, opts = {}) {
|
|
721
743
|
const { pkg, deps, stack } = checkProject(cwd);
|
|
722
744
|
// monorepos: git runs hooks from the repository root, and GitHub reads workflows only there
|
|
@@ -960,5 +982,5 @@ function printUninstall({ report }, log = console.log) {
|
|
|
960
982
|
|
|
961
983
|
module.exports = {
|
|
962
984
|
init, sync, uninstall, printSummary, printSync, printUninstall, InitError, TOOLS, TESTED, CI, KIT_VERSION, tool, cleanEnv,
|
|
963
|
-
hookManager, hooksWired, kitRun, checkProject, recorded, installedCi, emptyFolder, createApp,
|
|
985
|
+
hookManager, hooksWired, kitRun, ignoredByGit, flattenAntigravityStop, checkProject, recorded, installedCi, emptyFolder, createApp,
|
|
964
986
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-mobile-kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.15",
|
|
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",
|
|
@@ -21,7 +21,7 @@ This project may also use other AI workflow frameworks (for example Superpowers,
|
|
|
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
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`, …); on a real iPhone or iPad the user names: `AMK_IOS_DEVICE=<its UDID>` (the flows clear the app's data on it) |
|
|
24
|
-
| Check
|
|
24
|
+
| Check devices at the same time | `sh scripts/amk/verify.sh plan --spec <id>` says how many this machine's memory fits, and prints the commands: one per device (in rounds when they don't all fit; a device's flows in parts when there's room), each for an `m-device-checker` subagent |
|
|
25
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>` |
|
|
26
26
|
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/amk/release-check.js` |
|
|
27
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` |
|
|
@@ -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. Check it on the devices as `sh scripts/amk/verify.sh plan --spec <id>` says (one command, or each
|
|
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 devices in rounds, each in its own `m-device-checker` subagent, 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
|
|
|
@@ -55,9 +55,9 @@ 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 plan --spec <id>`. It says
|
|
58
|
+
1. Run `sh scripts/amk/verify.sh plan --spec <id>`. It says how many devices this machine's memory can check at the same time, and prints the commands.
|
|
59
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.
|
|
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, round by round, start one `m-device-checker` subagent per device command of the round, all at once, and wait for their reports before the next round; each runs its device (or its part of the flows), 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, or in each `part-k/` folder when its flows ran in parts (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
61
|
|
|
62
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.
|
|
63
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.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
3
|
"hooks": {
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// Each command finds the project through git, so it runs from wherever the tool starts it: Claude Code keeps the
|
|
5
|
+
// agent's cd between commands, Antigravity runs hooks from .agents/, Codex from the project. A relative path
|
|
6
|
+
// isn't found there, which turns the guard off (or, in Antigravity, blocks every command). No shell variables,
|
|
7
|
+
// so it also runs in PowerShell. No matcher: runs for every tool call; guard.js decides from the payload
|
|
8
|
+
"preToolUse": [{ "command": "node -e \"require(require('child_process').execSync('git rev-parse --show-toplevel').toString().trim() + '/scripts/amk/guard.js')\"" }],
|
|
9
|
+
"stop": [{ "command": "node -e \"require(require('child_process').execSync('git rev-parse --show-toplevel').toString().trim() + '/scripts/amk/handoff-check.js')\"" }]
|
|
7
10
|
}
|
|
8
11
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: m-device-checker
|
|
3
3
|
targets: ["*"]
|
|
4
|
-
description: Checks the app on one device and reports the evidence. Use when `verify.sh plan` says to check
|
|
4
|
+
description: Checks the app on one device and reports the evidence. Use when `verify.sh plan` says to check devices at the same time, one m-device-checker per device command of a round, all started together.
|
|
5
5
|
claudecode:
|
|
6
6
|
tools: ["Read", "Grep", "Glob", "Bash"]
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
You check the app on one device with fresh eyes, and hand the evidence back. You never edit files.
|
|
10
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.
|
|
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>/`. A command with `--part k/n` runs only its share of the flows, on a device of its own (a temporary copy for the parts after the first, deleted afterwards), and saves them in `.amk/evidence/<id>/<screen>/part-k/`. Don't build, and don't run anything else on a device: other checkers are using the other devices. A check takes several minutes, up to about 15 when a flow has to run again: give the command a timeout that long, or run it in the background and wait for it to end, never stopping it early.
|
|
12
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
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
14
|
4. Report, and say only what you saw in this run:
|
|
@@ -21,7 +21,7 @@ This project may also use other AI workflow frameworks (for example Superpowers,
|
|
|
21
21
|
| iOS build (simulator, no signing) | `sh scripts/amk/ios-build.sh` |
|
|
22
22
|
| Android build | `cd android && ./gradlew assembleDebug` |
|
|
23
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`, …); on a real iPhone or iPad the user names: `AMK_IOS_DEVICE=<its UDID>` (the flows clear the app's data on it) |
|
|
24
|
-
| Check
|
|
24
|
+
| Check devices at the same time | `sh scripts/amk/verify.sh plan --spec <id>` says how many this machine's memory fits, and prints the commands: one per device (in rounds when they don't all fit; a device's flows in parts when there's room), each for an `m-device-checker` subagent |
|
|
25
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>` |
|
|
26
26
|
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/amk/release-check.js` |
|
|
27
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]` |
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Agent guard hook (preToolUse). Blocks destructive shell commands and access to secret files.
|
|
3
3
|
// Each AI tool sends a differently shaped JSON payload, so look for command and path fields anywhere in it.
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
// the project this script is in (scripts/amk/): the agent may have moved into a subfolder
|
|
7
|
+
const root = path.join(__dirname, '..', '..');
|
|
5
8
|
|
|
6
9
|
let payload;
|
|
7
10
|
const raw = fs.readFileSync(0, 'utf8');
|
|
@@ -28,7 +31,7 @@ const destructive = /\brm(?=[^;&|\n]*\s(-[a-zA-Z]*[rR][a-zA-Z]*|--recursive)\b)(
|
|
|
28
31
|
const secretFile = /(^|[\s/'"=])\.env(?![\w.-]*\.(?:example|sample|template)(?=$|[\s'";|&)]))(\.[\w.-]+)?(?=$|[\s'";|&)])|\.(keystore|jks|p8|p12|mobileprovision)\b/;
|
|
29
32
|
// the project's own secret files: .amk-secrets lists them, one path from the project root per line (a folder ends in /)
|
|
30
33
|
let listed = [];
|
|
31
|
-
try { listed = fs.readFileSync('.amk-secrets', 'utf8').split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#')); } catch {}
|
|
34
|
+
try { listed = fs.readFileSync(path.join(root, '.amk-secrets'), 'utf8').split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#')); } catch {}
|
|
32
35
|
const secret = s => secretFile.test(s) || listed.some(p => s.includes(p));
|
|
33
36
|
|
|
34
37
|
const block = reason => { process.stderr.write(`Blocked by scripts/amk/guard.js: ${reason}\n`); process.exit(2); };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Agent stop hook. If code changed but the active spec's handoff block wasn't updated, ask the agent to update it.
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
const { execSync } = require('child_process');
|
|
6
|
+
// the project this script is in (scripts/amk/): the agent may have moved into a subfolder
|
|
7
|
+
const root = path.join(__dirname, '..', '..');
|
|
5
8
|
|
|
6
9
|
let payload = {};
|
|
7
10
|
try { payload = JSON.parse(fs.readFileSync(0, 'utf8')); } catch {}
|
|
@@ -9,13 +12,13 @@ if (payload.stop_hook_active) process.exit(0); // already reminded once; don't l
|
|
|
9
12
|
|
|
10
13
|
// a spec counts only when its handoff says "Status: in progress" (not done, not an untouched template copy)
|
|
11
14
|
const inProgress = d => {
|
|
12
|
-
const f =
|
|
15
|
+
const f = path.join(root, 'specs', d, 'progress.md');
|
|
13
16
|
return d !== '_templates' && fs.existsSync(f) && /^Status:\s*in progress/im.test(fs.readFileSync(f, 'utf8'));
|
|
14
17
|
};
|
|
15
|
-
const specs = fs.existsSync('specs') ? fs.readdirSync('specs').filter(inProgress) : [];
|
|
18
|
+
const specs = fs.existsSync(path.join(root, 'specs')) ? fs.readdirSync(path.join(root, 'specs')).filter(inProgress) : [];
|
|
16
19
|
if (specs.length === 0) process.exit(0); // no spec in progress (quick change, bug fix, or finished work)
|
|
17
20
|
|
|
18
|
-
const changed = execSync('git status --porcelain --untracked-files=all', { encoding: 'utf8' }) // every new file, not just its new folder
|
|
21
|
+
const changed = execSync('git status --porcelain --untracked-files=all', { cwd: root, encoding: 'utf8' }) // every new file, not just its new folder
|
|
19
22
|
.split('\n').filter(Boolean).map(l => l.slice(3));
|
|
20
23
|
const codeChanged = changed.some(f => !f.startsWith('specs/') && !f.startsWith('.amk/'));
|
|
21
24
|
const handoffUpdated = changed.some(f => /^specs\/[^/]+\/progress\.md$/.test(f));
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
# ios|android release build, install, run flows, screenshots
|
|
10
10
|
# all everything (default)
|
|
11
11
|
# build the release builds only, iOS and Android at the same time, for --no-build checks after it
|
|
12
|
-
# plan
|
|
12
|
+
# plan how many devices this machine's memory can check at the same time, and the commands to run:
|
|
13
|
+
# one per device, in rounds when they don't all fit, the flows split into parts when there's room
|
|
13
14
|
# --spec <id> run .maestro/<id>*.yaml and save evidence in .amk/evidence/<id>/
|
|
14
15
|
# --label <n> evidence folder name (default: the spec id, or no-spec)
|
|
15
16
|
# --flavor <name> Android product flavor to check (default: the first one in build.gradle)
|
|
@@ -17,6 +18,9 @@
|
|
|
17
18
|
# --screens <l> only these of the screens the app supports, comma-separated: phone, tablet, portrait,
|
|
18
19
|
# landscape, or one such as tablet-landscape
|
|
19
20
|
# --no-build check the last build instead of building again (after `build`)
|
|
21
|
+
# --part <k/n> only part k of the flows split in n (every n-th, from the k-th), with its evidence in
|
|
22
|
+
# <screen>/part-k/: part 1 on the usual device, the others on a temporary copy of it (the same kind of
|
|
23
|
+
# simulator, or an emulator with the same settings), deleted afterwards. plan prints these
|
|
20
24
|
# (no flows found: a smoke check that launches the app and takes a screenshot)
|
|
21
25
|
# Evidence per screen: ios/ and android/ (phone, portrait), then -landscape/, -tablet/ and -tablet-landscape/, each
|
|
22
26
|
# with its latest run only (the device's own log only for a flow that failed); the newest 5 evidence folders stay,
|
|
@@ -27,7 +31,9 @@
|
|
|
27
31
|
# AMK_ANDROID_AVD (the emulator to use, started if it isn't running; other devices are left alone),
|
|
28
32
|
# AMK_IOS_TABLET (iPad simulator, or a connected iPad: name or UDID), AMK_ANDROID_TABLET_AVD (tablet emulator),
|
|
29
33
|
# AMK_ANDROID_TABLET (serial), AMK_IOS_TEAM (the Apple team ID that signs builds for real iPhones and iPads;
|
|
30
|
-
# default: the project's), AMK_PARALLEL (1 or 0: overrides plan's choice),
|
|
34
|
+
# default: the project's), AMK_PARALLEL (1 or 0: overrides plan's choice), AMK_MEMORY_GB (the memory plan
|
|
35
|
+
# counts on: this machine's; less when other emulators stay open), AMK_DEVICES (how many devices plan checks at
|
|
36
|
+
# once: one per 6 GB beyond 4), AMK_DEVICE_WAIT (minutes to wait for a
|
|
31
37
|
# device in use, 30), AMK_LOCK_DIR (where runs on this machine claim devices; /tmp/agentic-mobile-kit-<user id>),
|
|
32
38
|
# AMK_EVIDENCE_KEEP (how many evidence folders stay, newest first: 5; 0 keeps them all)
|
|
33
39
|
# A device in use by another run (any project on this machine) is skipped for a free one of the same kind, or waited
|
|
@@ -47,6 +53,7 @@ flavor=${AMK_ANDROID_FLAVOR:-}
|
|
|
47
53
|
only=${AMK_SCREENS:-}
|
|
48
54
|
no_build=0
|
|
49
55
|
build_only=0
|
|
56
|
+
part=""
|
|
50
57
|
while [ $# -gt 0 ]; do
|
|
51
58
|
case $1 in
|
|
52
59
|
--spec) spec=$2; shift 2 ;;
|
|
@@ -56,9 +63,17 @@ while [ $# -gt 0 ]; do
|
|
|
56
63
|
--scheme) AMK_IOS_SCHEME=$2; export AMK_IOS_SCHEME; shift 2 ;;
|
|
57
64
|
--screens) only=$2; shift 2 ;;
|
|
58
65
|
--no-build) no_build=1; shift ;;
|
|
66
|
+
--part) part=$2; shift 2 ;;
|
|
59
67
|
*) echo "verify: unknown option $1"; exit 2 ;;
|
|
60
68
|
esac
|
|
61
69
|
done
|
|
70
|
+
part_k=1 part_n=1
|
|
71
|
+
if [ -n "$part" ]; then
|
|
72
|
+
part_k=${part%/*} part_n=${part#*/}
|
|
73
|
+
case $part in */*) ;; *) part_k=x ;; esac
|
|
74
|
+
case "$part_k$part_n" in '' | *[!0-9]*) echo "verify: --part takes k/n, such as 2/3"; exit 2 ;; esac
|
|
75
|
+
[ "$part_k" -ge 1 ] && [ "$part_k" -le "$part_n" ] || { echo "verify: --part takes k/n, such as 2/3"; exit 2; }
|
|
76
|
+
fi
|
|
62
77
|
|
|
63
78
|
root=$(pwd)
|
|
64
79
|
. scripts/amk/maestro-env.sh
|
|
@@ -73,17 +88,20 @@ keep=${AMK_EVIDENCE_KEEP:-5}
|
|
|
73
88
|
if [ "$keep" -gt 0 ] 2> /dev/null; then
|
|
74
89
|
old=$(ls -dt "$root"/.amk/evidence/*/ 2> /dev/null | grep -v -- '-prototype/$' | tail -n +$((keep + 1)))
|
|
75
90
|
if [ -n "$old" ]; then
|
|
76
|
-
|
|
91
|
+
# another run on this machine (a part, a round) may have just removed the same folder
|
|
92
|
+
echo "$old" | while IFS= read -r d; do rm -r "${d:?}" 2> /dev/null || true; done
|
|
77
93
|
echo "evidence: removed $(echo "$old" | wc -l | tr -d ' ') older folders from .amk/evidence, keeping the newest $keep (AMK_EVIDENCE_KEEP sets how many; 0 keeps them all)"
|
|
78
94
|
fi
|
|
79
95
|
fi
|
|
80
96
|
status=0
|
|
81
97
|
|
|
82
98
|
flow_files() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
{
|
|
100
|
+
if [ -n "$flow" ]; then echo "$root/$flow"
|
|
101
|
+
elif [ -n "$spec" ]; then find "$root/.maestro" -maxdepth 1 -iname "$spec*.yaml" 2>/dev/null | sort
|
|
102
|
+
else find "$root/.maestro" -maxdepth 1 -name '*.yaml' 2>/dev/null | sort
|
|
103
|
+
fi
|
|
104
|
+
} | awk -v k="$part_k" -v n="$part_n" '(NR - 1) % n == k - 1'
|
|
87
105
|
}
|
|
88
106
|
|
|
89
107
|
# the screens to check on a platform: the ones the app supports, narrowed by --screens
|
|
@@ -130,7 +148,8 @@ claim() {
|
|
|
130
148
|
}
|
|
131
149
|
unclaim() { l=$(lock_path "$1"); rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; held=$(echo "$held" | sed "s| $l||"); }
|
|
132
150
|
release() { for l in $held; do rm -f "$l/owner"; rmdir "$l" 2> /dev/null || true; done; held=""; }
|
|
133
|
-
|
|
151
|
+
temps="" # the temporary devices this run made for a part of the flows (--part), deleted at its end
|
|
152
|
+
trap 'release; drop_temps' EXIT
|
|
134
153
|
trap 'exit 130' INT TERM
|
|
135
154
|
holder() {
|
|
136
155
|
l=$(lock_path "$1")
|
|
@@ -200,8 +219,35 @@ run_flow() { # screen device app_id file name orientation
|
|
|
200
219
|
return $rc
|
|
201
220
|
}
|
|
202
221
|
|
|
222
|
+
# whether a flow failed because the Android device dropped out: Maestro says so in its own log or the flow's ($1)
|
|
223
|
+
lost_device() {
|
|
224
|
+
grep -qs -E 'device offline|DeviceServerDiedException|Device server died' "$debug/maestro.log" ||
|
|
225
|
+
grep -qs -E 'was requested, but it is not connected|Device server died' "$1"
|
|
226
|
+
}
|
|
227
|
+
# waits until the Android device $1 answers three times in a row, 10 seconds apart (3 minutes at most)
|
|
228
|
+
steady() {
|
|
229
|
+
"$adb" reconnect offline > /dev/null 2>&1 || true
|
|
230
|
+
in_row=0 tries=0
|
|
231
|
+
while [ "$in_row" -lt 3 ] && [ "$tries" -lt 18 ]; do
|
|
232
|
+
tries=$((tries + 1))
|
|
233
|
+
if [ "$("$adb" -s "$1" shell getprop sys.boot_completed 2> /dev/null | tr -d '\r')" = 1 ]; then in_row=$((in_row + 1)); else in_row=0; "$adb" reconnect offline > /dev/null 2>&1 || true; fi
|
|
234
|
+
[ "$in_row" -ge 3 ] || sleep 10
|
|
235
|
+
done
|
|
236
|
+
}
|
|
203
237
|
run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to turn it) [again]
|
|
204
238
|
out="$evidence/$1"
|
|
239
|
+
# a part of the flows has a folder of its own in the screen's, as the parts run at the same time: part 1 clears what
|
|
240
|
+
# an earlier run left beside them
|
|
241
|
+
if [ -n "$part" ]; then
|
|
242
|
+
if [ "$part_k" = 1 ] && [ -z "${5:-}" ] && [ -d "$out" ]; then
|
|
243
|
+
for e in "$out"/* "$out"/.[!.]*; do
|
|
244
|
+
[ -e "$e" ] || continue
|
|
245
|
+
case ${e##*/} in part-*) [ "${e##*/part-}" -le "$part_n" ] 2> /dev/null && continue ;; esac
|
|
246
|
+
rm -r "$e"
|
|
247
|
+
done
|
|
248
|
+
fi
|
|
249
|
+
out="$out/part-$part_k"
|
|
250
|
+
fi
|
|
205
251
|
# the screen's latest run only: an earlier run's screenshots aren't this run's evidence
|
|
206
252
|
[ -n "${5:-}" ] || [ ! -d "$out" ] || rm -r "$out"
|
|
207
253
|
mkdir -p "$out"
|
|
@@ -228,12 +274,17 @@ run_flows() { # screen device app_id orientation (PORTRAIT, or LANDSCAPE_LEFT to
|
|
|
228
274
|
echo " $1: Maestro stopped before flow $name started; running it once more"
|
|
229
275
|
ok=0
|
|
230
276
|
run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
ok
|
|
236
|
-
|
|
277
|
+
# (or missed it as it started, or Maestro's server on it died: an emulator under load, with other devices starting
|
|
278
|
+
# or running on this machine, can drop it for a few minutes). Once it answers steadily, run it again, twice at most
|
|
279
|
+
elif [ "$ok" != 0 ] && [ "${1%%-*}" = android ] && lost_device "$out/$name.log"; then
|
|
280
|
+
again=0
|
|
281
|
+
while [ "$ok" != 0 ] && [ "$again" -lt 2 ] && lost_device "$out/$name.log"; do
|
|
282
|
+
again=$((again + 1))
|
|
283
|
+
echo " $1: the device went offline during flow $name; running it once more when it answers steadily"
|
|
284
|
+
steady "$2"
|
|
285
|
+
ok=0
|
|
286
|
+
run_flow "$1" "$2" "$3" "$f" "$name" "$4" || ok=$?
|
|
287
|
+
done
|
|
237
288
|
elif [ "$ok" != 0 ] && is_real "$2" && grep -qs 'explicitly trusted' "$out/$name.log"; then
|
|
238
289
|
# as launch_check found it does: here after clearState installed the app again, which it opened a moment later
|
|
239
290
|
echo " $1: the device didn't open the app it had just installed again; running flow $name once more"
|
|
@@ -329,6 +380,7 @@ check_screens() { # platform phone tablet app_id screens…
|
|
|
329
380
|
run_flows "$where" "$on" "$id" "$turn"
|
|
330
381
|
done
|
|
331
382
|
release # this platform's devices, and Maestro's turn, for other runs
|
|
383
|
+
drop_temps
|
|
332
384
|
}
|
|
333
385
|
|
|
334
386
|
quick() {
|
|
@@ -459,6 +511,17 @@ simulators() {
|
|
|
459
511
|
# device's
|
|
460
512
|
take_simulator() {
|
|
461
513
|
taken=""
|
|
514
|
+
if [ "$part_k" -gt 1 ]; then
|
|
515
|
+
first=$(simulators "$1" "$2" | head -n 1)
|
|
516
|
+
if [ -z "$first" ]; then
|
|
517
|
+
[ -z "$2" ] || { echo "ios: part $part of the flows runs on a copy of the device, which works only for a simulator, not $2"; return 1; }
|
|
518
|
+
return 0
|
|
519
|
+
fi
|
|
520
|
+
temp_simulator "$first" || { echo "ios: couldn't make a simulator for part $part of the flows"; return 1; }
|
|
521
|
+
claim "ios-$taken" "$taken" || true
|
|
522
|
+
echo "ios: part $part of the flows runs on a temporary $1 simulator like $first, deleted afterwards"
|
|
523
|
+
return 0
|
|
524
|
+
fi
|
|
462
525
|
candidates=$(simulators "$1" "$2")
|
|
463
526
|
if [ -z "$candidates" ] && [ -n "$2" ]; then
|
|
464
527
|
candidates=$(real_ios "$2")
|
|
@@ -557,11 +620,54 @@ device_width() {
|
|
|
557
620
|
/Physical size/ { split($2, s, "x"); w = s[1] + 0 < s[2] + 0 ? s[1] : s[2] } /Physical density/ { d = $2 }
|
|
558
621
|
END { if (d) print int(w * 160 / d) }'
|
|
559
622
|
}
|
|
623
|
+
avd_home=${ANDROID_AVD_HOME:-${ANDROID_USER_HOME:-$HOME/.android}/avd}
|
|
624
|
+
# an AVD's folder: its .ini names it (an AVD can be renamed, and keep its folder), else <name>.avd
|
|
625
|
+
avd_dir() { d=$(sed -n 's/^path=//p' "$avd_home/$1.ini" 2> /dev/null | head -n 1); echo "${d:-$avd_home/$1.avd}"; }
|
|
626
|
+
# a temporary AVD with the settings of AVD $1 (not its data), in $tavd, for a part of the flows after the first
|
|
627
|
+
temp_avd() {
|
|
628
|
+
tavd="amk_part_${part_k}_$$_$(printf %s "$1" | tr -c 'A-Za-z0-9._-' _)"
|
|
629
|
+
[ -f "$(avd_dir "$1")/config.ini" ] && mkdir -p "$avd_home/$tavd.avd" || return 1
|
|
630
|
+
temps="$temps avd:$tavd"
|
|
631
|
+
grep -v -E '^(avd\.ini\.displayname|AvdId|avd\.id|fastboot\.)' "$(avd_dir "$1")/config.ini" > "$avd_home/$tavd.avd/config.ini"
|
|
632
|
+
printf 'avd.ini.displayname=%s\nAvdId=%s\n' "$tavd" "$tavd" >> "$avd_home/$tavd.avd/config.ini"
|
|
633
|
+
printf 'avd.ini.encoding=UTF-8\npath=%s\npath.rel=avd/%s.avd\ntarget=%s\n' "$avd_home/$tavd.avd" "$tavd" \
|
|
634
|
+
"$(sed -n 's/^target=//p' "$avd_home/$1.ini" 2> /dev/null | head -n 1)" > "$avd_home/$tavd.ini"
|
|
635
|
+
}
|
|
636
|
+
# a temporary simulator of the same type and iOS version as simulator $1, in $taken, for a part after the first
|
|
637
|
+
temp_simulator() {
|
|
638
|
+
like=$(xcrun simctl list devices available -j | UDID=$1 node -e '
|
|
639
|
+
for (const [rt, ds] of Object.entries(JSON.parse(require("fs").readFileSync(0, "utf8")).devices))
|
|
640
|
+
for (const d of ds) if (d.udid === process.env.UDID) console.log(d.deviceTypeIdentifier, rt);')
|
|
641
|
+
[ -n "$like" ] || return 1
|
|
642
|
+
taken=$(xcrun simctl create "amk part $part_k of $part_n ($$)" $like) && [ -n "$taken" ] || return 1
|
|
643
|
+
temps="$temps ios:$taken"
|
|
644
|
+
}
|
|
645
|
+
# waits until adb no longer lists the emulator $1 (up to $2 seconds): it has stopped, or is about to
|
|
646
|
+
gone() { tries=0; while [ -n "$(running_emulator "$1" 2> /dev/null || true)" ] && [ "$tries" -lt "$2" ]; do tries=$((tries + 1)); sleep 1; done; }
|
|
647
|
+
# deletes the temporary devices this run made: their data goes with them
|
|
648
|
+
drop_temps() {
|
|
649
|
+
for t in $temps; do
|
|
650
|
+
case $t in
|
|
651
|
+
ios:*) xcrun simctl shutdown "${t#ios:}" > /dev/null 2>&1 || true; xcrun simctl delete "${t#ios:}" > /dev/null 2>&1 || true ;;
|
|
652
|
+
avd:*)
|
|
653
|
+
n=${t#avd:}
|
|
654
|
+
s=$(running_emulator "$n" 2> /dev/null || true)
|
|
655
|
+
[ -z "$s" ] || "$adb" -s "$s" emu kill > /dev/null 2>&1 || true
|
|
656
|
+
gone "$n" 30
|
|
657
|
+
# an emulator can hold its files for a moment after adb lets it go (on Windows, a file in use can't be deleted)
|
|
658
|
+
tries=0
|
|
659
|
+
until rm -rf "${avd_home:?}/$n.avd" "$avd_home/$n.ini" 2> /dev/null && [ ! -e "$avd_home/$n.avd" ] || [ "$tries" -ge 5 ]; do
|
|
660
|
+
tries=$((tries + 1)); sleep 2
|
|
661
|
+
done ;;
|
|
662
|
+
esac
|
|
663
|
+
done
|
|
664
|
+
temps=""
|
|
665
|
+
}
|
|
560
666
|
# the same for an emulator that isn't running, from its config.ini
|
|
561
667
|
avd_width() {
|
|
562
668
|
awk -F' *= *' '$1 == "hw.lcd.width" { w = $2 } $1 == "hw.lcd.height" { h = $2 } $1 == "hw.lcd.density" { d = $2 }
|
|
563
669
|
END { if (d) print int((w + 0 < h + 0 ? w : h) * 160 / d) }' \
|
|
564
|
-
"$
|
|
670
|
+
"$(avd_dir "$1")/config.ini" 2> /dev/null || true
|
|
565
671
|
}
|
|
566
672
|
# the emulators of the kind $1 (phone or tablet), best first: the running ones, then the others
|
|
567
673
|
emulators() {
|
|
@@ -577,6 +683,29 @@ emulators() {
|
|
|
577
683
|
# best one, once it's free. Empty when there's none of that kind. An emulator is claimed by its name, however named
|
|
578
684
|
take_android() {
|
|
579
685
|
taken="" pick=""
|
|
686
|
+
if [ "$part_k" -gt 1 ]; then
|
|
687
|
+
src=$3
|
|
688
|
+
if [ -n "$2" ]; then
|
|
689
|
+
case $2 in
|
|
690
|
+
emulator-*) src=$("$adb" -s "$2" emu avd name 2> /dev/null | head -n 1 | tr -d '\r') ;;
|
|
691
|
+
*) echo "android: part $part of the flows runs on a copy of the device, which works only for an emulator, not $2"; return 1 ;;
|
|
692
|
+
esac
|
|
693
|
+
fi
|
|
694
|
+
[ -n "$src" ] || src=$(emulators "$1" | head -n 1)
|
|
695
|
+
[ -n "$src" ] || return 0
|
|
696
|
+
temp_avd "$src" || { echo "android: couldn't copy emulator $src for part $part of the flows"; return 1; }
|
|
697
|
+
taken=$(start_emulator "$tavd") || { echo "android: the copy of emulator $src for part $part of the flows didn't start"; return 1; }
|
|
698
|
+
# a new emulator's first boot drops its adb connection during flows ("device offline"), however long it's left;
|
|
699
|
+
# started again, it doesn't (measured: 5 of 6 runs failed on first boots, 6 of 6 passed after a restart). It's
|
|
700
|
+
# stopped through its console, as adb itself can be offline then, and started again
|
|
701
|
+
android_ready "$taken" || { echo "android: the copy of emulator $src for part $part of the flows didn't start"; return 1; }
|
|
702
|
+
"$adb" -s "$taken" emu kill > /dev/null 2>&1 || true
|
|
703
|
+
gone "$tavd" 60
|
|
704
|
+
taken=$(start_emulator "$tavd") || { echo "android: the copy of emulator $src for part $part of the flows didn't start again"; return 1; }
|
|
705
|
+
claim "android-avd-$tavd" "$taken" || true
|
|
706
|
+
echo "android: part $part of the flows runs on a temporary copy of emulator $src, deleted afterwards"
|
|
707
|
+
return 0
|
|
708
|
+
fi
|
|
580
709
|
if [ -n "$2" ]; then
|
|
581
710
|
key=android-$2
|
|
582
711
|
case $2 in emulator-*) key=android-avd-$("$adb" -s "$2" emu avd name 2> /dev/null | head -n 1 | tr -d '\r') ;; esac
|
|
@@ -630,6 +759,8 @@ android() {
|
|
|
630
759
|
*) default_sdk=$HOME/Android/Sdk ;;
|
|
631
760
|
esac
|
|
632
761
|
sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$default_sdk}}
|
|
762
|
+
# Gradle finds the SDK through it too: an AI tool started from the Dock or a menu doesn't load the shell's profile
|
|
763
|
+
[ -n "${ANDROID_HOME:-}" ] || export ANDROID_HOME="$sdk"
|
|
633
764
|
adb="$sdk/platform-tools/adb"
|
|
634
765
|
# Expo apps without native folders in git: generate android/ first
|
|
635
766
|
if [ "$no_build" = 0 ] && ! sh scripts/amk/prebuild.sh android > "$evidence/prebuild-android.log" 2>&1; then
|
|
@@ -763,36 +894,97 @@ build() {
|
|
|
763
894
|
plan() {
|
|
764
895
|
set -- $(node -e 'const os = require("os"), fs = require("fs"), s = fs.statfsSync(".");
|
|
765
896
|
console.log(Math.round(os.totalmem() / 2 ** 30), Math.round(s.bavail * s.bsize / 2 ** 30))')
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
897
|
+
mem=$1
|
|
898
|
+
case ${AMK_MEMORY_GB:-x} in *[!0-9]*) ;; *) mem=$AMK_MEMORY_GB ;; esac
|
|
899
|
+
have="$mem GB of memory, $2 GB free disk, Maestro $(maestro_version)"
|
|
900
|
+
# the devices to check, phones first and the platforms mixed, so a round of two has one of each
|
|
901
|
+
# (each platform's screens are read first: grep -q stops reading at its first match, and a writer still going then
|
|
902
|
+
# says "Broken pipe")
|
|
903
|
+
checks="" ios_screens="" android_screens=$(screens_for android)
|
|
904
|
+
[ "$(uname -s)" != Darwin ] || ios_screens=$(screens_for ios)
|
|
905
|
+
for kind in phone tablet; do
|
|
906
|
+
if echo "$ios_screens" | grep -q "^$kind-"; then checks="$checks ios:$kind"; fi
|
|
907
|
+
if echo "$android_screens" | grep -q "^$kind-"; then checks="$checks android:$kind"; fi
|
|
908
|
+
done
|
|
772
909
|
n=$(echo $checks | wc -w | tr -d ' ')
|
|
910
|
+
# a device under test takes about 6 GB (a simulator or an emulator with Maestro: an iPhone simulator and a phone
|
|
911
|
+
# emulator at once measured 11 GB), and macOS and the rest about 4 GB: 2 devices at once from 16 GB, 4 from 28 GB
|
|
912
|
+
slots=$(( (mem - 4) / 6 ))
|
|
913
|
+
case ${AMK_DEVICES:-x} in *[!0-9]*) ;; *) slots=$AMK_DEVICES ;; esac
|
|
773
914
|
why=""
|
|
774
915
|
case ${AMK_PARALLEL:-} in
|
|
775
916
|
0) why="AMK_PARALLEL=0" ;;
|
|
776
|
-
1) ;;
|
|
917
|
+
1) [ "$slots" -ge "$n" ] || slots=$n ;;
|
|
777
918
|
*)
|
|
778
|
-
[ "$
|
|
919
|
+
if [ "$slots" -lt 2 ]; then why=${AMK_DEVICES:+AMK_DEVICES=$AMK_DEVICES}; why=${why:-it needs 16 GB of memory}; fi
|
|
779
920
|
[ "$2" -ge 20 ] || why="${why:+$why and }it needs 20 GB free disk"
|
|
780
921
|
maestro_at_least 2.6.0 || why="${why:+$why and }it needs Maestro 2.6 or later" ;;
|
|
781
922
|
esac
|
|
782
|
-
|
|
923
|
+
# room for more devices than kinds: each kind's flows split into parts, each part on a device of its own
|
|
924
|
+
# A part's device is one more: about 6 GB for a simulator, 8 GB for an emulator (measured with 4 GB of guest memory),
|
|
925
|
+
# so parts need room for every kind's devices at once; AMK_DEVICES says how many outright
|
|
926
|
+
flows=$(flow_files | grep -c . || true)
|
|
927
|
+
parts=1
|
|
928
|
+
if [ "$slots" -gt "$n" ] && [ "$flows" -ge 2 ]; then
|
|
929
|
+
parts=$((slots / n))
|
|
930
|
+
case ${AMK_DEVICES:-x} in
|
|
931
|
+
*[!0-9]*)
|
|
932
|
+
per=0
|
|
933
|
+
for c in $checks; do case $c in ios:*) per=$((per + 6)) ;; *) per=$((per + 8)) ;; esac; done
|
|
934
|
+
[ "$parts" -le $(( (mem - 4) / per )) ] || parts=$(( (mem - 4) / per )) ;;
|
|
935
|
+
esac
|
|
936
|
+
[ "$parts" -le "$flows" ] || parts=$flows
|
|
937
|
+
[ "$parts" -ge 1 ] || parts=1
|
|
938
|
+
fi
|
|
939
|
+
[ "$n" -ge 2 ] || [ "$parts" -ge 2 ] || why="there's one device to check"
|
|
783
940
|
if [ -n "$why" ]; then
|
|
784
941
|
echo "plan: $have: one device at a time ($why; AMK_PARALLEL=1 overrides)"
|
|
785
942
|
echo " sh scripts/amk/verify.sh all${args:+ $args}"
|
|
786
943
|
return
|
|
787
944
|
fi
|
|
788
|
-
|
|
945
|
+
# one command per device, a kind's parts next to each other. A real iPhone, iPad or phone can't be copied for a
|
|
946
|
+
# part, so it runs all its flows
|
|
947
|
+
jobs=""
|
|
948
|
+
for c in $checks; do
|
|
949
|
+
p=$parts
|
|
950
|
+
case $c in
|
|
951
|
+
ios:phone) [ -z "${AMK_IOS_DEVICE:-}" ] || [ -n "$(simulators iPhone "$AMK_IOS_DEVICE")" ] || p=1 ;;
|
|
952
|
+
ios:tablet) [ -z "${AMK_IOS_TABLET:-}" ] || [ -n "$(simulators iPad "$AMK_IOS_TABLET")" ] || p=1 ;;
|
|
953
|
+
android:phone) case ${AMK_ANDROID_DEVICE:-emulator-} in emulator-*) ;; *) p=1 ;; esac ;;
|
|
954
|
+
android:tablet) case ${AMK_ANDROID_TABLET:-emulator-} in emulator-*) ;; *) p=1 ;; esac ;;
|
|
955
|
+
esac
|
|
956
|
+
i=1
|
|
957
|
+
while [ "$i" -le "$p" ]; do
|
|
958
|
+
cmd="sh scripts/amk/verify.sh ${c%:*} --no-build --screens ${c#*:}"
|
|
959
|
+
[ "$p" = 1 ] || cmd="$cmd --part $i/$p"
|
|
960
|
+
jobs="$jobs$cmd${args:+ $args}
|
|
961
|
+
"
|
|
962
|
+
i=$((i + 1))
|
|
963
|
+
done
|
|
964
|
+
done
|
|
965
|
+
total=$(printf %s "$jobs" | grep -c .)
|
|
966
|
+
rounds=$(( (total + slots - 1) / slots ))
|
|
967
|
+
if [ "$rounds" -gt 1 ]; then echo "plan: $have: $slots devices at a time, in $rounds rounds"
|
|
968
|
+
elif [ "$parts" -gt 1 ]; then echo "plan: $have: check on $total devices at the same time, each kind's flows in parts"
|
|
969
|
+
else echo "plan: $have: check the $n devices at the same time"; fi
|
|
789
970
|
echo " 1. sh scripts/amk/verify.sh quick${args:+ $args}"
|
|
790
971
|
echo " 2. sh scripts/amk/verify.sh build${args:+ $args}"
|
|
791
|
-
|
|
792
|
-
|
|
972
|
+
r=1
|
|
973
|
+
while [ "$r" -le "$rounds" ]; do
|
|
974
|
+
if [ "$rounds" = 1 ]; then echo " 3. at the same time, each in its own subagent (m-device-checker), which checks its screenshots and reports:"
|
|
975
|
+
elif [ "$r" = 1 ]; then echo " 3. round 1 of $rounds, at the same time, each in its own subagent (m-device-checker), which checks its screenshots and reports:"
|
|
976
|
+
else echo " $((r + 2)). round $r of $rounds, once round $((r - 1)) has reported, the same way:"; fi
|
|
977
|
+
printf %s "$jobs" | sed -n "$(( (r - 1) * slots + 1 )),$(( r * slots ))p" | sed 's/^/ /'
|
|
978
|
+
r=$((r + 1))
|
|
979
|
+
done
|
|
793
980
|
[ "$(uname -s)" = Darwin ] || echo " iOS isn't checked here: it needs a Mac with Xcode"
|
|
794
981
|
}
|
|
795
982
|
|
|
983
|
+
# a part beyond the flows (more parts than flows) has nothing to check: no build, and no device made for it
|
|
984
|
+
if [ -n "$part" ] && [ -z "$(flow_files)" ]; then
|
|
985
|
+
case $mode in ios | android | all) echo "verify: part $part has no flows: there are fewer flows than parts"; exit 0 ;; esac
|
|
986
|
+
fi
|
|
987
|
+
|
|
796
988
|
case $mode in
|
|
797
989
|
quick) quick ;;
|
|
798
990
|
ios) ios ;;
|