@yasaswy.nagavolu/agents 0.34.0 → 0.35.0
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/README.md +1 -1
- package/content/manifest.json +21 -1
- package/content/proxy/register_mem_sampler.ps1 +6 -0
- package/content/skills/README.md +4 -0
- package/content/skills/expo-release/SKILL.md +67 -0
- package/content/skills/expo-release/expo_release.py +204 -0
- package/content/skills/expo-release/templates/gitlab-ci.yml.tmpl +63 -0
- package/content/skills/expo-release/templates/release-kit.yml.tmpl +7 -0
- package/content/skills/expo-release/tests/test_expo_release.py +173 -0
- package/content/skills/gmail-reader/README.md +1 -0
- package/content/skills/gmail-reader/SKILL.md +2 -1
- package/content/skills/gmail-reader/gmail_reader/purchases/__init__.py +2 -2
- package/content/skills/gmail-reader/gmail_reader/purchases/parse.py +98 -15
- package/content/skills/gmail-reader/gmail_reader/purchases/scan.py +17 -12
- package/content/skills/gmail-reader/gmail_reader/version.py +1 -1
- package/content/skills/gmail-reader/tests/test_purchase_parsers.py +30 -0
- package/content/skills/gmail-reader/tests/test_split_orders.py +120 -0
- package/content/skills/low-ram-advisor/handlecount.py +32 -17
- package/content/skills/low-ram-advisor/tests/test_handlecount.py +16 -0
- package/content/skills/publish-article/SKILL.md +6 -1
- package/content/skills/publish-article/publish_article.py +38 -1
- package/content/skills/publish-article/released_bundles.py +56 -0
- package/content/skills/publish-article/skill_drift.py +42 -0
- package/content/skills/publish-article/tests/test_publish_article.py +212 -0
- package/content/skills/resale/CONTRACTS.md +10 -2
- package/content/skills/resale/README.md +32 -8
- package/content/skills/resale/SKILL.md +5 -4
- package/content/skills/resale/resale/comps/review_runner.py +6 -9
- package/content/skills/resale/resale/contracts/__init__.py +5 -1
- package/content/skills/resale/resale/contracts/amazon_orders.schema.json +52 -0
- package/content/skills/resale/resale/portal/bundles.py +46 -1
- package/content/skills/resale/resale/portal/layout.py +20 -5
- package/content/skills/resale/resale/portal/panel.py +10 -2
- package/content/skills/resale/resale/portal/tablesort.py +2 -2
- package/content/skills/resale/resale/portal/views_items.py +69 -70
- package/content/skills/resale/resale/portal/views_reader.py +8 -0
- package/content/skills/resale/resale/postkit/drafts.py +2 -2
- package/content/skills/resale/resale/receipts/amazon_history.py +208 -0
- package/content/skills/resale/resale/receipts/commands.py +15 -0
- package/content/skills/resale/resale/receipts/intake.py +18 -4
- package/content/skills/resale/resale/receipts/links.py +14 -3
- package/content/skills/resale/resale/receipts/reader_link.py +1 -1
- package/content/skills/resale/resale/receipts/review.py +2 -2
- package/content/skills/resale/resale/receipts/store.py +87 -32
- package/content/skills/resale/resale/service/app.py +2 -2
- package/content/skills/resale/resale/service/inventory_ops.py +9 -4
- package/content/skills/resale/resale/service/reader_state.py +2 -1
- package/content/skills/resale/resale/service/server.py +19 -3
- package/content/skills/resale/resale/settings.py +13 -0
- package/content/skills/resale/resale/sources/__init__.py +1 -0
- package/content/skills/resale/resale/sources/amazon_orders.py +260 -0
- package/content/skills/resale/resale/sources/amazon_reader.py +245 -0
- package/content/skills/resale/resale/sources/astromart.py +37 -9
- package/content/skills/resale/resale/sources/client.py +8 -0
- package/content/skills/resale/resale/sources/commands.py +54 -4
- package/content/skills/resale/resale/sources/guards.py +1 -1
- package/content/skills/resale/resale/sources/httppage.py +15 -0
- package/content/skills/resale/resale/sources/logins.py +5 -1
- package/content/skills/resale/resale/sources/readonly_lint.py +1 -1
- package/content/skills/resale/resale/sources/runner.py +33 -14
- package/content/skills/resale/settings.example.env +7 -0
- package/content/skills/resale/tasks/comps_review_task.py +3 -3
- package/content/skills/resale/tasks/task_items.json +1 -1
- package/content/skills/resale/tests/fixtures/amazon/captcha.html +2 -0
- package/content/skills/resale/tests/fixtures/amazon/history_2023.html +6 -0
- package/content/skills/resale/tests/fixtures/amazon/history_empty.html +1 -0
- package/content/skills/resale/tests/fixtures/amazon/order_cancelled_returned.html +16 -0
- package/content/skills/resale/tests/fixtures/amazon/order_discount_single.html +10 -0
- package/content/skills/resale/tests/fixtures/amazon/order_new_layout.html +38 -0
- package/content/skills/resale/tests/fixtures/amazon/order_not_found.html +1 -0
- package/content/skills/resale/tests/fixtures/amazon/order_old_layout.html +33 -0
- package/content/skills/resale/tests/fixtures/amazon/signin.html +1 -0
- package/content/skills/resale/tests/test_amazon_history.py +249 -0
- package/content/skills/resale/tests/test_amazon_orders_parse.py +76 -0
- package/content/skills/resale/tests/test_amazon_reader.py +240 -0
- package/content/skills/resale/tests/test_amazon_service_and_login.py +131 -0
- package/content/skills/resale/tests/test_candidates_review.py +11 -0
- package/content/skills/resale/tests/test_comps_review_task.py +20 -25
- package/content/skills/resale/tests/test_founder_hide.py +50 -4
- package/content/skills/resale/tests/test_portal_bundle_fold.py +51 -21
- package/content/skills/resale/tests/test_portal_bundles.py +56 -3
- package/content/skills/resale/tests/test_portal_candidates.py +4 -4
- package/content/skills/resale/tests/test_portal_inplace.py +10 -10
- package/content/skills/resale/tests/test_portal_layout.py +111 -0
- package/content/skills/resale/tests/test_portal_market.py +9 -9
- package/content/skills/resale/tests/test_portal_names.py +1 -1
- package/content/skills/resale/tests/test_portal_photos.py +3 -3
- package/content/skills/resale/tests/test_portal_sort.py +5 -4
- package/content/skills/resale/tests/test_portal_split.py +22 -6
- package/content/skills/resale/tests/test_postkit.py +10 -0
- package/content/skills/resale/tests/test_reader_live_pages.py +2 -2
- package/content/skills/resale/tests/test_reader_notify.py +1 -1
- package/content/skills/resale/tests/test_reader_parsers.py +17 -0
- package/content/skills/resale/tests/test_reader_runner.py +115 -27
- package/content/skills/resale/tests/test_reader_state_portal.py +22 -6
- package/content/skills/resale/tests/test_receipts_split_orders.py +115 -0
- package/content/skills/resale/tests/test_service_http.py +4 -4
- package/lib/bundleHeartbeat.js +1 -1
- package/lib/hiddenTask/register_hidden_task.ps1 +8 -0
- package/lib/memSafety.js +6 -3
- package/lib/taskItems.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -435,7 +435,7 @@ are declared in `manifest.json` and work for any bundle:
|
|
|
435
435
|
| Declaration | What `install` / `update` does | Uninstall | `doctor` |
|
|
436
436
|
|---|---|---|---|
|
|
437
437
|
| `kind: "container"` item, wiring `{project, containers[], envFile?, healthTimeoutS?}` | `docker compose -p <project> -f <deployed compose file> up -d --build`, then waits for the named containers to be running and healthy. The compose file must set `restart: unless-stopped` (or `always`) so Docker brings it back after a reboot. | `docker compose down` first, named volumes kept | docker engine, Docker Desktop start-at-sign-in, per container state, health and restart policy |
|
|
438
|
-
| `kind: "task"` item, wiring `{name, exe, args[], workingDirectory?, description?, logonDelay?, repeat?, keepRunning?}` | Registers a hidden Windows logon task (no elevation, `conhost --headless`, never a window) through `lib/hiddenTask/register_hidden_task.ps1`. Idempotent; windows and the default `~/.claude` install only. | task removed | task exists, enabled, same command line, running when `keepRunning` |
|
|
438
|
+
| `kind: "task"` item, wiring `{name, exe, args[], workingDirectory?, description?, logonDelay?, repeat?, keepRunning?}` | Registers a hidden Windows logon task (no elevation, `conhost --headless`, never a window) through `lib/hiddenTask/register_hidden_task.ps1`. A task with `repeat` gets a logon trigger plus a time trigger that starts at registration, so the repeat runs at once and not only after the next sign-in; `doctor` flags a task without the time trigger and `install`/`update` re-register it. Idempotent; windows and the default `~/.claude` install only. | task removed | task exists, enabled, same command line, running when `keepRunning` |
|
|
439
439
|
| bundle `settings: {example, target}` | The shipped example file (`KEY=default`, the comment above a key is its prompt, `(optional)` in it marks the key optional) is copied to `<target-dir>/<target>` once, each value is prompted in a terminal (Enter keeps), new example keys are appended on later runs, values you set are never overwritten. `--no-secrets` skips the prompts. | file kept | file exists, required keys have a value |
|
|
440
440
|
| secret `type: "file"` (plus `fileName`, `required`) | You give a path; a copy is stored owner-only in `<target-dir>/secret-files/` and its path is recorded under the secret name in `agents.env`. Non-interactive: pipe the path into `agents-cli secrets --set <NAME>`. | `secrets --remove <NAME>` also deletes the stored copy | listed in `secrets --list` and doctor, file existence checked |
|
|
441
441
|
|
package/content/manifest.json
CHANGED
|
@@ -263,6 +263,26 @@
|
|
|
263
263
|
"deps": [],
|
|
264
264
|
"secrets": []
|
|
265
265
|
},
|
|
266
|
+
{
|
|
267
|
+
"key": "expo-release",
|
|
268
|
+
"title": "Expo Release Pipeline",
|
|
269
|
+
"summary": "Adopt and audit a self-hosted Expo (React Native) Android and iOS release pipeline on your own GitLab runners with no EAS cloud build: seven fail-closed stages (validate, version, preflight, build, submit, verify, release), a scaffold for the pipeline files, an offline audit of a repo against the contract, and thin delegation to a pinned release kit",
|
|
270
|
+
"profile": "public",
|
|
271
|
+
"advanced": false,
|
|
272
|
+
"items": [
|
|
273
|
+
{
|
|
274
|
+
"path": "skills/expo-release",
|
|
275
|
+
"kind": "skill"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"path": "proxy/headless_process.py",
|
|
279
|
+
"kind": "hook",
|
|
280
|
+
"note": "Shared no-visible-window subprocess wrapper imported by expo_release.py - not wired to an event itself."
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"deps": [],
|
|
284
|
+
"secrets": []
|
|
285
|
+
},
|
|
266
286
|
{
|
|
267
287
|
"key": "heavy-gate-runner",
|
|
268
288
|
"title": "Heavy Gate Runner",
|
|
@@ -2609,7 +2629,7 @@
|
|
|
2609
2629
|
"{{TARGET}}/skills/resale/tasks/comps_review_task.py"
|
|
2610
2630
|
],
|
|
2611
2631
|
"workingDirectory": "{{TARGET}}/skills/resale",
|
|
2612
|
-
"description": "Resale comps review: headless Claude (no tools) judges new comps
|
|
2632
|
+
"description": "Resale comps review: headless Claude (no tools) judges new comps whenever comps wait and the last review is 30 minutes old (hidden)",
|
|
2613
2633
|
"logonDelay": "PT5M",
|
|
2614
2634
|
"repeat": "PT15M"
|
|
2615
2635
|
},
|
|
@@ -68,6 +68,12 @@ if ($PSCmdlet.ShouldProcess($TaskName, "Register hidden logon task running pytho
|
|
|
68
68
|
$trigger.Repetition.Interval = "PT5M"
|
|
69
69
|
$trigger.Enabled = $true
|
|
70
70
|
|
|
71
|
+
# A logon trigger arms its repeat only at the next sign-in; this time trigger starts the repeat at registration.
|
|
72
|
+
$trigger2 = $task.Triggers.Create(1)
|
|
73
|
+
$trigger2.StartBoundary = (Get-Date).AddMinutes(-1).ToString("yyyy-MM-dd'T'HH:mm:ss")
|
|
74
|
+
$trigger2.Repetition.Interval = "PT5M"
|
|
75
|
+
$trigger2.Enabled = $true
|
|
76
|
+
|
|
71
77
|
$action = $task.Actions.Create(0)
|
|
72
78
|
$action.Path = $pythonw
|
|
73
79
|
$action.Arguments = $arguments
|
package/content/skills/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Global Claude Code skills. Installed to `~/.claude/skills/` — each subdirector
|
|
|
13
13
|
| `ram` | `/ram` · "optimize RAM" · "clear RAM" · "free up memory" | Skill |
|
|
14
14
|
| `low-ram-advisor` | no slash command · started in code by any free-RAM check · "free up RAM" · "what can I close" · "what's my RAM" · "should I restart" | Skill |
|
|
15
15
|
| `android-emulator` | no slash command · "start an emulator" · "emulator on the GPU" | Skill |
|
|
16
|
+
| `expo-release` | no slash command · "Expo build pipeline" · "avoid EAS builds" · "release the mobile app from CI" · "check my release pipeline" | Skill |
|
|
16
17
|
| `make-space` | "make space" · "make-space" · "disk critically low" · "free up space" · "we are out of space" | Skill |
|
|
17
18
|
| `mattpocock-codebase-design` | `/codebase-design` · "design this module's interface" · "find a deepening opportunity" · "where should this seam go" | Skill |
|
|
18
19
|
| `mattpocock-domain-modeling` | `/domain-modeling` · "pin down this term" · "record an ADR" · "sharpen the ubiquitous language" | Skill |
|
|
@@ -42,6 +43,9 @@ Project-agnostic image generation behind one provider interface. Default provide
|
|
|
42
43
|
### android-emulator
|
|
43
44
|
Local headless emulator launcher for the Windows host. `emulator_launch.py start --avd NAME` tries `-accel on -gpu host`, then the AVD's own mode; a mode that exits or never reaches `sys.boot_completed` is stopped and the next one runs on the same port. Modes the installed emulator build rejects in a user-supplied chain (36.4.9 drops `angle_indirect`) are skipped, and a `host` request that silently lands on a software renderer is reported as `downgraded`. The result carries the emulator log line and the guest GLES renderer as proof. CI and non-Windows hosts keep the AVD default. Override with env `ANDROID_EMULATOR_GPU_CHAIN`. Stdlib only; tests in `skills/android-emulator/tests`.
|
|
44
45
|
|
|
46
|
+
### expo-release
|
|
47
|
+
Adopt and audit a self-hosted Expo (React Native) release pipeline on your own GitLab runners, with no EAS cloud build. Seven stages, each with fail-closed gates: validate, version, preflight, build, submit, verify, release. `expo_release.py stages` prints them; `check --repo DIR` audits a repo offline (pinned kit tag, include ref equals `MRK_KIT_REF`, stage order, committed `android/` with an executable `gradlew`, no placeholders, no `eas` cloud call, manual fail-closed release job) and lists the GitLab variables to confirm by hand; `init` scaffolds `release-kit.yml` and `.gitlab-ci.yml` (dry run unless `--write`, never overwrites); `kit-fetch` clones the release kit at a pinned tag; `kit-run` delegates to the kit scripts (preflight, version, 16 KB alignment, store track check). Gate logic stays in the kit; the skill is a thin wrapper. The kit covers Android; iOS stages are per project. Pairs with `ci-runner` for the runners. Stdlib only; tests in `skills/expo-release/tests`.
|
|
48
|
+
|
|
45
49
|
### low-ram-advisor
|
|
46
50
|
Suggest-only RAM triage, the memory analogue of `make-space`, run on demand. `deep_report.py start` writes a report of commit, pagefile, kernel pool leaks, WSL/Docker VM, GPU and CI findings; `advisor.py` is the ranking library that groups Claude sessions, Metro/node, Gradle/Java, Maestro, emulator, browsers, WSL/Docker, local proxies and IDEs with owner, safe-to-stop, RAM freed and a graceful pwsh stop command. The code has no kill/suspend path; tests assert it. `ramstatus.py` prints a 10-line live RAM summary and an OK / RESTART SOON / RESTART NOW verdict (thresholds in `ram_thresholds.py`); run it on demand. Alerts never enter a chat: the sampler writes a `soon` or `now` verdict to the one-line statusline file `~/.claude/state/ram-alert.txt` through `ram_notice.py`.
|
|
47
51
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expo-release
|
|
3
|
+
description: Set up and audit a self-hosted Expo (React Native) Android and iOS release pipeline on your own GitLab runners, with no EAS cloud build. Use when the user says "Expo build pipeline", "build Expo on our own runners", "avoid EAS builds", "release the mobile app from CI", "add Play and TestFlight CI", "mobile release pipeline", or "check my release pipeline". Thin wrapper over expo_release.py and a pinned release kit; all mechanics live in code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# expo-release
|
|
7
|
+
|
|
8
|
+
Goal: an Expo project builds, signs, submits, verifies and releases from CI on own runners, with fail-closed gates at every stage.
|
|
9
|
+
This skill calls `expo_release.py` and the pinned kit and reports their JSON. The kit owns the gate logic. The skill never re-implements it.
|
|
10
|
+
|
|
11
|
+
## Rules
|
|
12
|
+
|
|
13
|
+
- Never read, print or ask for a keystore, store key or token. Signing and store values are protected CI variables the user sets in GitLab.
|
|
14
|
+
- Run every command headless; never open a window.
|
|
15
|
+
- Pin the kit to a `vX.Y.Z` tag. Never use a branch.
|
|
16
|
+
- The pipeline builds the committed `android/` and `ios/` trees. It never runs `expo prebuild` and never calls `eas build`, `eas submit` or `eas update`.
|
|
17
|
+
- Report each result once. Exit codes: 0 ok, 1 a check failed (read `findings`), 2 usage error.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
`PY = python <skills>/expo-release/expo_release.py`
|
|
22
|
+
|
|
23
|
+
| Situation | Command |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Show the stages and gates | `PY stages` |
|
|
26
|
+
| New project, no pipeline files | `PY init --kit-project group/name --kit-ref vX.Y.Z --package com.example.app --offset N` (dry run), then add `--write` |
|
|
27
|
+
| Audit an existing pipeline | `PY check --repo <dir>` |
|
|
28
|
+
| Kit is not on this machine | `PY kit-fetch --url <kit git url> --ref vX.Y.Z` (url or `MRK_KIT_URL`) |
|
|
29
|
+
| Check a tag and versionCode | `PY kit-run version -- --tag v1.2.3 --offset N --channel-count 100` |
|
|
30
|
+
| Check a built bundle | `PY kit-run alignment -- --aab app-release.aab` |
|
|
31
|
+
| Run the preflight locally | `PY kit-run preflight -- --mode release --repo-root <dir> --tag <tag>` |
|
|
32
|
+
|
|
33
|
+
`init` never overwrites a file. `--offset` is the highest versionCode ever uploaded to the store; read it from the store first. `check` is offline and static; its `remote_checks_needed` list is for the user to confirm in GitLab.
|
|
34
|
+
|
|
35
|
+
## Stages (code decides; tests assert this list equals `PY stages`)
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
stages: [validate, version, preflight, build, submit, verify, release]
|
|
39
|
+
release_gates:
|
|
40
|
+
validate: [lint, typecheck, unit tests, kit ref parity]
|
|
41
|
+
version: [tag is the only version source]
|
|
42
|
+
preflight: [no placeholders, keystore opens, versionCode above floor, channel variables equal job values, no debug signing]
|
|
43
|
+
build: [16 KB page alignment, artifact identity, sha256 and mapping kept]
|
|
44
|
+
submit: [channel file matches lane, plain X.Y.Z version name]
|
|
45
|
+
verify: [versionCode on store track, iOS build valid]
|
|
46
|
+
release: [manual job, fails closed on channel and source track]
|
|
47
|
+
versioncode: "(OFFSET + MAJOR*1e6 + MINOR*1e3 + PATCH) * 100 + SLOT"
|
|
48
|
+
slots: {production_tag: 0, tester_prerelease_tag_N: N}
|
|
49
|
+
platforms:
|
|
50
|
+
android: {runner_tags: [android, release], image: pinned, caches: host volumes}
|
|
51
|
+
ios: {runner_tags: [macos], executor: shell, signing: read-only match, build_number: next store build number}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Flow
|
|
55
|
+
|
|
56
|
+
1. `PY check` on the repo. Fix every `error` first. `warn` items are advice.
|
|
57
|
+
2. No pipeline yet: `init` dry run, show the plan, then `--write`. Replace nothing by hand except the verify polling and the `validate` commands for the app.
|
|
58
|
+
3. Runners: `ci-runner` skill (`runner install`, `runner attach`). The release runner takes protected refs only.
|
|
59
|
+
4. Confirm `remote_checks_needed` with the user in the GitLab variable list.
|
|
60
|
+
5. First tester tag: build, submit, verify must all pass before a production tag.
|
|
61
|
+
|
|
62
|
+
## Notes
|
|
63
|
+
|
|
64
|
+
- iOS: the kit covers Android only. The iOS stages (`macos` shell runner, read-only code signing, store build number, processing wait) are written per project. `check` validates stage names and the release gate for both.
|
|
65
|
+
- A project that already has a project-level skill named `mobile-release` keeps it. That skill runs one project's release; this one adopts and audits the pipeline in any project. The names differ on purpose, since a global skill of the same name would shadow the project one.
|
|
66
|
+
- The kit is not bundled. Fetch it by tag from the user's git host. If it lives in a private group, the consuming project needs job-token access to it.
|
|
67
|
+
- First build after an image change is slow (the image and caches fill once); later builds reuse host cache volumes.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""expo-release: adopt and audit a self-hosted Expo (React Native) release pipeline. Stdlib only."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "proxy"))
|
|
13
|
+
from headless_process import headless_run # noqa: E402
|
|
14
|
+
|
|
15
|
+
TEMPLATES = Path(__file__).resolve().parent / "templates"
|
|
16
|
+
TAG_REF = re.compile(r"^v\d+\.\d+\.\d+$")
|
|
17
|
+
PLACEHOLDER = re.compile(r"REPLACE_WITH_[A-Z0-9_]+")
|
|
18
|
+
|
|
19
|
+
STAGES = [
|
|
20
|
+
{"stage": "validate", "gates": ["lint", "typecheck", "unit tests", "kit ref parity (include ref equals MRK_KIT_REF)"]},
|
|
21
|
+
{"stage": "version", "gates": ["tag is the only version source", "no hand-edited version files"]},
|
|
22
|
+
{"stage": "preflight", "gates": ["runner online", "no REPLACE_WITH placeholders", "committed android/ tree", "package name matches", "no debug signing", "tag shape", "signing variables set", "keystore opens", "versionCode above floor", "channel variables equal job values"]},
|
|
23
|
+
{"stage": "build", "gates": ["16 KB page alignment", "artifact identity (name, version, channel)", "sha256 and mapping kept", "no EAS cloud call"]},
|
|
24
|
+
{"stage": "submit", "gates": ["channel file matches lane", "plain X.Y.Z version name", "service account present"]},
|
|
25
|
+
{"stage": "verify", "gates": ["versionCode visible on the store track", "iOS build processed and valid"]},
|
|
26
|
+
{"stage": "release", "gates": ["manual job", "fails closed unless channel is production and versionCode is on the source track"]},
|
|
27
|
+
]
|
|
28
|
+
STAGE_NAMES = [s["stage"] for s in STAGES]
|
|
29
|
+
KIT_SCRIPTS = {
|
|
30
|
+
"preflight": "preflight.py",
|
|
31
|
+
"version": "version.py",
|
|
32
|
+
"alignment": "check_16k_alignment.py",
|
|
33
|
+
"track-code": "verify_track_version_code.py",
|
|
34
|
+
"load-config": "load_release_kit.py",
|
|
35
|
+
}
|
|
36
|
+
REMOTE_CHECKS = [
|
|
37
|
+
"MRK_KIT_REF must NOT exist as a project CI variable (it overrides the YAML pin)",
|
|
38
|
+
"MRK_VERSIONCODE_FLOOR is set (protected) from the highest versionCode ever uploaded",
|
|
39
|
+
"signing and store variables are protected: MRK_ANDROID_KEYSTORE_B64, MRK_ANDROID_KEYSTORE_PASSWORD, MRK_ANDROID_KEY_ALIAS, MRK_ANDROID_KEY_PASSWORD, MRK_PLAY_SERVICE_ACCOUNT_JSON",
|
|
40
|
+
"release runner takes protected refs only; the build image is built on the runner host",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _read(path: Path) -> str:
|
|
45
|
+
return path.read_text(encoding="utf-8") if path.is_file() else ""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _stage_list(ci: str) -> list[str]:
|
|
49
|
+
m = re.search(r"^stages:\s*\[(.*?)\]", ci, re.M)
|
|
50
|
+
if m:
|
|
51
|
+
return [x.strip().strip("'\"") for x in m.group(1).split(",") if x.strip()]
|
|
52
|
+
m = re.search(r"^stages:\s*\n((?:[ \t]*-[^\n]*\n?)+)", ci, re.M)
|
|
53
|
+
return [ln.strip()[1:].strip().strip("'\"") for ln in m.group(1).splitlines() if ln.strip()] if m else []
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _is_subsequence(want: list[str], have: list[str]) -> bool:
|
|
57
|
+
it = iter(have)
|
|
58
|
+
return all(any(w == h for h in it) for w in want)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _gradlew_mode(repo: Path) -> str | None:
|
|
62
|
+
r = headless_run(["git", "-C", str(repo), "ls-files", "-s", "android/gradlew"], capture_output=True, text=True)
|
|
63
|
+
if r.returncode != 0 or not r.stdout.strip():
|
|
64
|
+
return None
|
|
65
|
+
return r.stdout.split()[0]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def check(repo: Path) -> dict:
|
|
69
|
+
findings: list[dict] = []
|
|
70
|
+
|
|
71
|
+
def add(fid: str, severity: str, msg: str) -> None:
|
|
72
|
+
findings.append({"id": fid, "severity": severity, "msg": msg})
|
|
73
|
+
|
|
74
|
+
cfg, ci = _read(repo / "release-kit.yml"), _read(repo / ".gitlab-ci.yml")
|
|
75
|
+
if not cfg:
|
|
76
|
+
add("kit-config-missing", "error", "release-kit.yml not found at the repo root")
|
|
77
|
+
for key in ("android_package", "versioncode_offset"):
|
|
78
|
+
if cfg and not re.search(rf"^{key}:\s*\S+", cfg, re.M):
|
|
79
|
+
add("kit-config-key", "error", f"release-kit.yml has no value for {key}")
|
|
80
|
+
if not ci:
|
|
81
|
+
add("ci-missing", "error", ".gitlab-ci.yml not found at the repo root")
|
|
82
|
+
for name, text in (("release-kit.yml", cfg), (".gitlab-ci.yml", ci)):
|
|
83
|
+
for ph in sorted(set(PLACEHOLDER.findall(text))):
|
|
84
|
+
add("placeholder", "error", f"{name} still contains {ph}")
|
|
85
|
+
if not (repo / "android" / "gradlew").is_file():
|
|
86
|
+
add("android-tree", "error", "android/ with gradlew is not committed; the pipeline never runs expo prebuild")
|
|
87
|
+
else:
|
|
88
|
+
mode = _gradlew_mode(repo)
|
|
89
|
+
if mode and mode != "100755":
|
|
90
|
+
add("gradlew-exec", "error", f"android/gradlew is mode {mode} in git, needs 100755 (git update-index --chmod=+x android/gradlew)")
|
|
91
|
+
if ci:
|
|
92
|
+
inc = re.search(r"project:\s*(\S+)\s*\n\s*ref:\s*['\"]?([^\s'\"#]+)", ci)
|
|
93
|
+
pin = re.search(r"^\s*MRK_KIT_REF:\s*['\"]?([^\s'\"#]+)", ci, re.M)
|
|
94
|
+
if not inc:
|
|
95
|
+
add("kit-include", "error", "no kit include with project and ref found")
|
|
96
|
+
elif not TAG_REF.match(inc.group(2)):
|
|
97
|
+
add("kit-ref-pinned", "error", f"include ref '{inc.group(2)}' is not a vX.Y.Z tag; pin a tag, never a branch")
|
|
98
|
+
if not pin:
|
|
99
|
+
add("kit-ref-parity", "error", "variables: MRK_KIT_REF is not set next to the include ref")
|
|
100
|
+
elif inc and pin.group(1) != inc.group(2):
|
|
101
|
+
add("kit-ref-parity", "error", f"MRK_KIT_REF {pin.group(1)} differs from include ref {inc.group(2)}")
|
|
102
|
+
stages = _stage_list(ci)
|
|
103
|
+
if not _is_subsequence(STAGE_NAMES, stages):
|
|
104
|
+
add("stage-order", "error", f"stages {stages or '(none)'} must contain, in order: {STAGE_NAMES}")
|
|
105
|
+
if "when: manual" not in ci and "promote_production" not in ci:
|
|
106
|
+
add("release-manual", "error", "no manual release gate; the release job must be manual")
|
|
107
|
+
if "promote_production" not in ci:
|
|
108
|
+
add("release-fail-closed", "warn", "release job does not extend .mrk:android:promote_production (kit channel and track check)")
|
|
109
|
+
if "needs:" not in ci:
|
|
110
|
+
add("release-needs", "warn", "no needs: found; release must need the production build artifact")
|
|
111
|
+
if re.search(r"\beas\s+(build|submit|update)\b", ci):
|
|
112
|
+
add("cloud-build", "error", "CI calls an EAS cloud command; the pipeline builds on own runners")
|
|
113
|
+
errors = sum(f["severity"] == "error" for f in findings)
|
|
114
|
+
return {"ok": errors == 0, "errors": errors, "findings": findings, "remote_checks_needed": REMOTE_CHECKS}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def init(repo: Path, args: argparse.Namespace) -> dict:
|
|
118
|
+
values = {"KIT_PROJECT": args.kit_project, "KIT_REF": args.kit_ref, "PACKAGE": args.package,
|
|
119
|
+
"OFFSET": str(args.offset), "PRERELEASE_ID": args.prerelease_id or ""}
|
|
120
|
+
plan = []
|
|
121
|
+
for src, dst in (("release-kit.yml.tmpl", "release-kit.yml"), ("gitlab-ci.yml.tmpl", ".gitlab-ci.yml")):
|
|
122
|
+
text = (TEMPLATES / src).read_text(encoding="utf-8")
|
|
123
|
+
for k, v in values.items():
|
|
124
|
+
text = text.replace("{{" + k + "}}", v)
|
|
125
|
+
exists = (repo / dst).exists()
|
|
126
|
+
plan.append({"file": dst, "action": "skip-exists" if exists else "write", "text": text})
|
|
127
|
+
if args.write:
|
|
128
|
+
for p in plan:
|
|
129
|
+
if p["action"] == "write":
|
|
130
|
+
(repo / p["file"]).write_text(p["text"], encoding="utf-8", newline="\n")
|
|
131
|
+
return {"ok": True, "written": bool(args.write), "plan": [{"file": p["file"], "action": p["action"]} for p in plan]}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def kit_fetch(url: str, ref: str, dest: Path) -> dict:
|
|
135
|
+
if not TAG_REF.match(ref):
|
|
136
|
+
return {"ok": False, "error": f"kit ref '{ref}' must be a vX.Y.Z tag"}
|
|
137
|
+
if dest.exists():
|
|
138
|
+
return {"ok": False, "error": f"{dest} exists; remove it or pick another --dest"}
|
|
139
|
+
r = headless_run(["git", "clone", "--depth", "1", "--branch", ref, url, str(dest)], capture_output=True, text=True)
|
|
140
|
+
return {"ok": r.returncode == 0, "dest": str(dest), "ref": ref, "error": r.stderr.strip() if r.returncode else ""}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def kit_run(kit_dir: Path, name: str, extra: list[str]) -> int:
|
|
144
|
+
script = kit_dir / "scripts" / KIT_SCRIPTS[name]
|
|
145
|
+
if not script.is_file():
|
|
146
|
+
print(json.dumps({"ok": False, "error": f"{script} not found; run kit-fetch or set MRK_KIT_DIR"}))
|
|
147
|
+
return 1
|
|
148
|
+
return headless_run([sys.executable, "-I", str(script), *extra]).returncode
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
152
|
+
p = argparse.ArgumentParser(prog="expo_release.py", description=__doc__)
|
|
153
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
154
|
+
sub.add_parser("stages", help="print the stage and gate list as JSON")
|
|
155
|
+
c = sub.add_parser("check", help="audit a repo against the pipeline contract (offline)")
|
|
156
|
+
c.add_argument("--repo", type=Path, default=Path("."))
|
|
157
|
+
i = sub.add_parser("init", help="scaffold release-kit.yml and .gitlab-ci.yml (dry run unless --write; never overwrites)")
|
|
158
|
+
i.add_argument("--repo", type=Path, default=Path("."))
|
|
159
|
+
i.add_argument("--kit-project", required=True, help="GitLab path of the kit project, group/name")
|
|
160
|
+
i.add_argument("--kit-ref", required=True, help="kit tag, vX.Y.Z")
|
|
161
|
+
i.add_argument("--package", required=True, help="Android application id")
|
|
162
|
+
i.add_argument("--offset", type=int, required=True, help="highest versionCode ever uploaded to the store")
|
|
163
|
+
i.add_argument("--prerelease-id", default="")
|
|
164
|
+
i.add_argument("--write", action="store_true")
|
|
165
|
+
f = sub.add_parser("kit-fetch", help="clone the kit at a pinned tag")
|
|
166
|
+
f.add_argument("--url", default=os.environ.get("MRK_KIT_URL", ""))
|
|
167
|
+
f.add_argument("--ref", required=True)
|
|
168
|
+
f.add_argument("--dest", type=Path, default=Path.home() / ".mobile-release-kit")
|
|
169
|
+
k = sub.add_parser("kit-run", help="run one kit script; arguments after -- go to it")
|
|
170
|
+
k.add_argument("name", choices=sorted(KIT_SCRIPTS))
|
|
171
|
+
k.add_argument("--kit-dir", type=Path, default=Path(os.environ.get("MRK_KIT_DIR") or Path.home() / ".mobile-release-kit"))
|
|
172
|
+
k.add_argument("extra", nargs=argparse.REMAINDER)
|
|
173
|
+
return p
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def main(argv: list[str] | None = None) -> int:
|
|
177
|
+
a = build_parser().parse_args(argv)
|
|
178
|
+
if a.cmd == "stages":
|
|
179
|
+
print(json.dumps(STAGES))
|
|
180
|
+
return 0
|
|
181
|
+
if a.cmd == "check":
|
|
182
|
+
res = check(a.repo)
|
|
183
|
+
print(json.dumps(res))
|
|
184
|
+
return 0 if res["ok"] else 1
|
|
185
|
+
if a.cmd == "init":
|
|
186
|
+
ok = TAG_REF.match(a.kit_ref) and re.fullmatch(r"[\w.-]+/[\w./-]+", a.kit_project) and re.fullmatch(r"[A-Za-z]\w*(\.[A-Za-z]\w*)+", a.package)
|
|
187
|
+
if not ok:
|
|
188
|
+
print(json.dumps({"ok": False, "error": "bad --kit-ref (vX.Y.Z), --kit-project (group/name) or --package (a.b.c)"}))
|
|
189
|
+
return 2
|
|
190
|
+
print(json.dumps(init(a.repo, a)))
|
|
191
|
+
return 0
|
|
192
|
+
if a.cmd == "kit-fetch":
|
|
193
|
+
if not a.url:
|
|
194
|
+
print(json.dumps({"ok": False, "error": "pass --url or set MRK_KIT_URL"}))
|
|
195
|
+
return 2
|
|
196
|
+
res = kit_fetch(a.url, a.ref, a.dest)
|
|
197
|
+
print(json.dumps(res))
|
|
198
|
+
return 0 if res["ok"] else 1
|
|
199
|
+
extra = a.extra[1:] if a.extra[:1] == ["--"] else a.extra
|
|
200
|
+
return kit_run(a.kit_dir, a.name, extra)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
if __name__ == "__main__":
|
|
204
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
include:
|
|
2
|
+
- project: {{KIT_PROJECT}}
|
|
3
|
+
ref: {{KIT_REF}}
|
|
4
|
+
file:
|
|
5
|
+
- ci/base.yml
|
|
6
|
+
- ci/android.yml
|
|
7
|
+
|
|
8
|
+
variables:
|
|
9
|
+
MRK_KIT_REF: "{{KIT_REF}}"
|
|
10
|
+
MRK_PRERELEASE_ID: "{{PRERELEASE_ID}}"
|
|
11
|
+
MRK_ANDROID_CHANNEL_COUNT: "100"
|
|
12
|
+
MRK_ANDROID_CHANNEL_INDEX: "0"
|
|
13
|
+
|
|
14
|
+
stages: [validate, version, preflight, build, submit, verify, release]
|
|
15
|
+
|
|
16
|
+
validate:checks:
|
|
17
|
+
stage: validate
|
|
18
|
+
image: node:20
|
|
19
|
+
script:
|
|
20
|
+
- npm ci
|
|
21
|
+
- npm run lint
|
|
22
|
+
- npm run typecheck
|
|
23
|
+
- npm test
|
|
24
|
+
|
|
25
|
+
version:tag:
|
|
26
|
+
stage: version
|
|
27
|
+
image: node:20
|
|
28
|
+
rules:
|
|
29
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
30
|
+
script:
|
|
31
|
+
- npx semantic-release
|
|
32
|
+
|
|
33
|
+
preflight:release:
|
|
34
|
+
extends: .mrk:android:preflight_release
|
|
35
|
+
stage: preflight
|
|
36
|
+
|
|
37
|
+
android:build:
|
|
38
|
+
extends: .mrk:android:build
|
|
39
|
+
stage: build
|
|
40
|
+
needs: ["preflight:release"]
|
|
41
|
+
|
|
42
|
+
android:submit:
|
|
43
|
+
extends: .mrk:android:submit_internal
|
|
44
|
+
stage: submit
|
|
45
|
+
needs: ["android:build", "preflight:release"]
|
|
46
|
+
|
|
47
|
+
android:verify:
|
|
48
|
+
extends: .mrk:android_runner
|
|
49
|
+
stage: verify
|
|
50
|
+
needs: ["android:submit", "preflight:release"]
|
|
51
|
+
rules:
|
|
52
|
+
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
|
|
53
|
+
script:
|
|
54
|
+
- source "$MRK_KIT_DIR/scripts/secrets.sh"
|
|
55
|
+
- mrk_materialise_secret "$MRK_PLAY_SERVICE_ACCOUNT_JSON" "$CI_PROJECT_DIR/.mrk-secrets/play-sa.json"
|
|
56
|
+
- export MRK_PLAY_SERVICE_ACCOUNT_JSON="$CI_PROJECT_DIR/.mrk-secrets/play-sa.json"
|
|
57
|
+
- (cd "$MRK_KIT_DIR" && bundle exec fastlane android fetch_track_version_codes track:"${MRK_PLAY_TRACK:-internal}")
|
|
58
|
+
- python3 "$MRK_KIT_DIR/scripts/verify_track_version_code.py" --codes-file "$MRK_KIT_DIR/fastlane/track_version_codes.txt" --expected "$MRK_VERSION_CODE"
|
|
59
|
+
|
|
60
|
+
android:release:
|
|
61
|
+
extends: .mrk:android:promote_production
|
|
62
|
+
stage: release
|
|
63
|
+
needs: ["android:build", "android:verify", "preflight:release"]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""expo-release tests. Run: python -m pytest skills/expo-release/tests -q"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import re
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
SKILL_DIR = Path(__file__).resolve().parents[1]
|
|
13
|
+
sys.path.insert(0, str(SKILL_DIR))
|
|
14
|
+
|
|
15
|
+
import expo_release as er # noqa: E402
|
|
16
|
+
|
|
17
|
+
SKILL_MD = (SKILL_DIR / "SKILL.md").read_text(encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def scaffold(tmp_path, **over):
|
|
21
|
+
args = er.build_parser().parse_args(
|
|
22
|
+
["init", "--repo", str(tmp_path), "--kit-project", "grp/kit", "--kit-ref", "v1.2.3",
|
|
23
|
+
"--package", "com.example.app", "--offset", "7", "--write"])
|
|
24
|
+
er.init(tmp_path, args)
|
|
25
|
+
(tmp_path / "android").mkdir()
|
|
26
|
+
(tmp_path / "android" / "gradlew").write_text("#!/bin/sh\n")
|
|
27
|
+
return tmp_path
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def ids(res):
|
|
31
|
+
return {f["id"] for f in res["findings"]}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_skill_md_is_lean_and_generic():
|
|
35
|
+
assert len(SKILL_MD.splitlines()) < 100
|
|
36
|
+
assert re.match(r"---\nname: expo-release\ndescription: ", SKILL_MD)
|
|
37
|
+
for word in ("insta-manager", "social-manager", "social-poster"):
|
|
38
|
+
assert word not in SKILL_MD
|
|
39
|
+
for f in (SKILL_DIR / "templates").iterdir():
|
|
40
|
+
assert word not in f.read_text(encoding="utf-8")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_skill_md_stage_list_equals_code():
|
|
44
|
+
m = re.search(r"^stages: \[(.*?)\]", SKILL_MD, re.M)
|
|
45
|
+
assert [s.strip() for s in m.group(1).split(",")] == er.STAGE_NAMES
|
|
46
|
+
assert set(re.search(r"release_gates:\n((?: .*\n)+)", SKILL_MD).group(1).split(":")[0::1]) >= {" validate"}
|
|
47
|
+
for name in er.STAGE_NAMES:
|
|
48
|
+
assert re.search(rf"^ {name}: \[", SKILL_MD, re.M), name
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_stages_command_prints_json(capsys):
|
|
52
|
+
assert er.main(["stages"]) == 0
|
|
53
|
+
assert [s["stage"] for s in json.loads(capsys.readouterr().out)] == er.STAGE_NAMES
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_scaffold_passes_check(tmp_path):
|
|
57
|
+
res = er.check(scaffold(tmp_path))
|
|
58
|
+
assert res["ok"], res
|
|
59
|
+
assert res["remote_checks_needed"]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_init_is_dry_run_and_never_overwrites(tmp_path):
|
|
63
|
+
argv = ["init", "--repo", str(tmp_path), "--kit-project", "grp/kit", "--kit-ref", "v1.2.3",
|
|
64
|
+
"--package", "com.example.app", "--offset", "7"]
|
|
65
|
+
assert er.main(argv) == 0
|
|
66
|
+
assert not (tmp_path / ".gitlab-ci.yml").exists()
|
|
67
|
+
(tmp_path / "release-kit.yml").write_text("keep\n")
|
|
68
|
+
assert er.main(argv + ["--write"]) == 0
|
|
69
|
+
assert (tmp_path / "release-kit.yml").read_text() == "keep\n"
|
|
70
|
+
assert "grp/kit" in (tmp_path / ".gitlab-ci.yml").read_text()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize("argv", [
|
|
74
|
+
["--kit-ref", "main", "--kit-project", "grp/kit", "--package", "com.example.app"],
|
|
75
|
+
["--kit-ref", "v1.0.0", "--kit-project", "bad", "--package", "com.example.app"],
|
|
76
|
+
["--kit-ref", "v1.0.0", "--kit-project", "grp/kit", "--package", "nodots"],
|
|
77
|
+
])
|
|
78
|
+
def test_init_rejects_bad_input(tmp_path, argv):
|
|
79
|
+
assert er.main(["init", "--repo", str(tmp_path), "--offset", "1", *argv]) == 2
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def edit(repo, fn):
|
|
83
|
+
p = repo / ".gitlab-ci.yml"
|
|
84
|
+
p.write_text(fn(p.read_text()))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_branch_ref_is_an_error(tmp_path):
|
|
88
|
+
repo = scaffold(tmp_path)
|
|
89
|
+
edit(repo, lambda t: t.replace("ref: v1.2.3", "ref: main"))
|
|
90
|
+
assert {"kit-ref-pinned", "kit-ref-parity"} <= ids(er.check(repo))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_ref_parity_mismatch(tmp_path):
|
|
94
|
+
repo = scaffold(tmp_path)
|
|
95
|
+
edit(repo, lambda t: t.replace('MRK_KIT_REF: "v1.2.3"', 'MRK_KIT_REF: "v1.2.4"'))
|
|
96
|
+
assert "kit-ref-parity" in ids(er.check(repo))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_missing_stage_and_wrong_order(tmp_path):
|
|
100
|
+
repo = scaffold(tmp_path)
|
|
101
|
+
edit(repo, lambda t: t.replace("[validate, version, preflight, build, submit, verify, release]", "[validate, build, preflight, submit, release]"))
|
|
102
|
+
assert "stage-order" in ids(er.check(repo))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_placeholder_and_missing_keys(tmp_path):
|
|
106
|
+
repo = scaffold(tmp_path)
|
|
107
|
+
(repo / "release-kit.yml").write_text("android_package: REPLACE_WITH_PACKAGE\n")
|
|
108
|
+
got = ids(er.check(repo))
|
|
109
|
+
assert {"placeholder", "kit-config-key"} <= got
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_eas_cloud_call_is_an_error(tmp_path):
|
|
113
|
+
repo = scaffold(tmp_path)
|
|
114
|
+
edit(repo, lambda t: t + "\nlegacy:\n script:\n - eas build --platform android\n")
|
|
115
|
+
assert "cloud-build" in ids(er.check(repo))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def test_release_job_without_kit_template_warns(tmp_path):
|
|
119
|
+
repo = scaffold(tmp_path)
|
|
120
|
+
edit(repo, lambda t: t.replace("extends: .mrk:android:promote_production", "extends: .other"))
|
|
121
|
+
res = er.check(repo)
|
|
122
|
+
assert {"release-manual", "release-fail-closed"} <= ids(res)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_missing_android_tree_and_files(tmp_path):
|
|
126
|
+
res = er.check(tmp_path)
|
|
127
|
+
assert {"kit-config-missing", "ci-missing", "android-tree"} <= ids(res)
|
|
128
|
+
assert not res["ok"]
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_gradlew_mode_checked_in_git(tmp_path):
|
|
132
|
+
repo = scaffold(tmp_path)
|
|
133
|
+
git = lambda *a: subprocess.run(["git", "-C", str(repo), *a], check=True, capture_output=True) # noqa: E731
|
|
134
|
+
git("init", "-q")
|
|
135
|
+
git("add", "-A")
|
|
136
|
+
assert "gradlew-exec" in ids(er.check(repo))
|
|
137
|
+
git("update-index", "--chmod=+x", "android/gradlew")
|
|
138
|
+
assert "gradlew-exec" not in ids(er.check(repo))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_check_exit_codes(tmp_path):
|
|
142
|
+
bad, good = tmp_path / "bad", tmp_path / "good"
|
|
143
|
+
bad.mkdir()
|
|
144
|
+
good.mkdir()
|
|
145
|
+
assert er.main(["check", "--repo", str(bad)]) == 1
|
|
146
|
+
assert er.main(["check", "--repo", str(scaffold(good))]) == 0
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def test_kit_fetch_rejects_branch_and_existing_dest(tmp_path):
|
|
150
|
+
assert not er.kit_fetch("u", "main", tmp_path / "x")["ok"]
|
|
151
|
+
assert not er.kit_fetch("u", "v1.0.0", tmp_path)["ok"]
|
|
152
|
+
assert er.main(["kit-fetch", "--ref", "v1.0.0", "--url", ""]) == 2
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def test_kit_fetch_clones_pinned_tag(tmp_path):
|
|
156
|
+
src = tmp_path / "src"
|
|
157
|
+
src.mkdir()
|
|
158
|
+
git = lambda *a: subprocess.run(["git", "-C", str(src), *a], check=True, capture_output=True) # noqa: E731
|
|
159
|
+
git("init", "-q")
|
|
160
|
+
(src / "f").write_text("x")
|
|
161
|
+
git("add", "f")
|
|
162
|
+
git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "c")
|
|
163
|
+
git("tag", "v1.0.0")
|
|
164
|
+
res = er.kit_fetch(str(src), "v1.0.0", tmp_path / "kit")
|
|
165
|
+
assert res["ok"] and (tmp_path / "kit" / "f").is_file()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_kit_run_delegates_to_kit_script(tmp_path):
|
|
169
|
+
(tmp_path / "scripts").mkdir()
|
|
170
|
+
(tmp_path / "scripts" / "version.py").write_text("import sys; sys.exit(int(sys.argv[1]))\n")
|
|
171
|
+
assert er.kit_run(tmp_path, "version", ["0"]) == 0
|
|
172
|
+
assert er.kit_run(tmp_path, "version", ["3"]) == 3
|
|
173
|
+
assert er.kit_run(tmp_path / "missing", "version", []) == 1
|
|
@@ -36,6 +36,7 @@ The token file is `~/.claude/secret-files/google_oauth_token.json` (owner-only,
|
|
|
36
36
|
The scan keeps only proven purchases of durable goods; everything else is reported, not dropped silently.
|
|
37
37
|
|
|
38
38
|
- **Proof of purchase.** An order confirmation, receipt or invoice that carries an order, invoice or receipt number and a total or payment line. A PDF attachment named like an invoice, receipt or order is proof too. Marketing, carts, wishlists, review requests, price drops, quotes and shipping mail without a confirmed order are not purchases. A cancellation, return or refund voids its order number. The rules are data in `purchases/data/vendors.json` (`proof`, per-vendor overrides such as Amazon's `auto-confirm@` sender).
|
|
39
|
+
- **Split orders.** One confirmation mail can hold several orders ("Your purchase has been divided into 4 orders", `Order 2 of 4`). The reader returns one receipt per order from `parse_receipts(message)`, each with its own order number, order total and lines (`parse_receipt` returns the first). The storage key of such a receipt is `<message id>#<order number>` (`receipt_key`, `message_id_of`). An order with one line and no line price is paid its order total (basis `order_total`, proof lines: heading, order number, total line); an order with several lines and one total leaves every line unpriced, never a guess; a total of `$0.00` is no price either.
|
|
39
40
|
- **Filtered at the source.** The Gmail query leaves out the promotions, social and forums categories and asks each vendor for its order senders only (Amazon `auto-confirm@`, Costco `orderstatus@`, and so on; `order_senders` in `vendors.json`). `scan_purchases` returns one record per proven order and a count of what it skipped and why (`skipped`: `not_an_order_sender`, `promotional`, `no_proof`, `shipping_without_order`, `ignored_sender`, `excluded_subject`, `before_date_floor`, `voided_order_notice`). `proven_only=True` passes nothing unproven to the caller.
|
|
40
41
|
- **Paid is the net.** Each item keeps list price, discount, net, a basis (`list`, `item_discount`, `single_item_order`, `order_discount`, `order_total`, `unpriced`) and the verbatim receipt lines. An order-level discount that the receipt does not assign to items leaves the net unverified, except when one item's list price equals the printed subtotal (`single_item_order`): the printed merchandise discount is then that item's discount. A printed discount total (`You saved`, `Total Promo Discount`) replaces its component lines, and shipping discounts are not merchandise.
|
|
41
42
|
- **Durable goods.** Food, groceries, cleaning and paper goods, toiletries, supplements, filters, ink, batteries, digital goods, services, tickets and receipt noise lines are hidden with a reason (`purchases/data/durable.json`).
|
|
@@ -33,13 +33,14 @@ Gmail access is read-only. Scope `gmail.readonly` only, a three-call allowlist (
|
|
|
33
33
|
| Returns and refunds: a vendor's `void_senders` (Amazon `return@amazon.com`) are always void mail and always fetched (own search query, counted as an order sender); the order number is read from the `orderId=` link of the plain-text part when the visible text names none; `proof.void_product(subject)` returns the product a return, refund or cancellation subject names (None for an order-level notice or a multi-item cancellation) so a consumer voids only that item | `purchases/proof.py`, `purchases/parse.py`, `purchases/scan.py`, `void_senders` in `vendors.json` | `test_returns.py` (real subjects and bodies) |
|
|
34
34
|
| Filter at the source: the Gmail query leaves out promotions, social and forums and asks each vendor for its order senders only (`order_senders` in `vendors.json`); marketing senders are skipped with a counted reason; `scan_purchases` returns one `OrderRecord` per proven order (merchant, order number, date, total, items, proof type, message id) and `PurchaseScan.skipped` counts what was left out; `proven_only=True` hands nothing unproven to the caller | `purchases/scan.py`, `purchases/proof.py` | `test_source_filter.py` |
|
|
35
35
|
| Paid is the net after discounts: item discount line, or the order discount when one item's list price equals the subtotal; any other order-level discount leaves it unverified | `purchases/parse.py` | `test_prices.py` |
|
|
36
|
+
| Split orders: a confirmation that divides the purchase (`Order 2 of 4`, then `Order #...`) is read as one receipt per order, each with its own order number, `Order Total` and lines; `parse_receipts(message)` returns them, `receipt_key(message_id, parsed)` is the storage key (`<message id>` or `<message id>#<order number>`), `message_id_of(key)` gives the Gmail id back; an order with one line and no line price is paid its order total (`order_total`, proof lines: the order heading, the order number, the `Order Total` line); an order with several unpriced lines stays unpriced, and so does a one-line order whose total is `$0.00` (no charge is no price); a `Bargain recommendations` block ends the order section; each receipt lists the items of its sibling orders (`elsewhere`) so a re-read never calls them stale | `purchases/parse.py`, `purchases/scan.py` | `test_split_orders.py` |
|
|
36
37
|
| Recall: storefront order mail (`Order #X confirmed`, `<name> × N` summary, `x 1` and `Quantity:` layouts, `$net $list` sale line, unclosed `<head>`, invoice PDF named after the order) is fetched and named from the product line, not the variant or SKU | `scan.py` queries, `parse.py`, `htmltext.py`, `proof.py`, vendors `order_senders` | `test_recall.py` |
|
|
37
38
|
| Proof types also include `shipping_only` (listed order sender + order number + item lines, no confirmation found) and PayPal payment receipts (transaction id is the order number) | `proof.py`, `parse.py`, `data/vendors.json` | `test_recall.py` |
|
|
38
39
|
| Durable goods only: consumables, digital goods, services, tickets and receipt noise lines are hidden with a category reason | `purchases/durable.py`, `data/durable.json` | `test_durable.py` |
|
|
39
40
|
| Ignored senders (finance, games, food delivery, utilities) are never fetched | `ignore_domains`, `ignore_senders` | `test_scan.py` |
|
|
40
41
|
| Date floor: `since_epoch` replaces the default window; an explicit `since_days` still caps it | `purchases/scan.py` | `test_a_receipts_floor_older_than_the_default_window_is_honoured` |
|
|
41
42
|
| Quota: HTTP 403 `rateLimitExceeded` waits 15, 30, 60, 60 s, then `GmailQuotaError`; a scan stops and the next scan resumes | `client.py`, `scan.py` | `test_readonly.py`, `test_scan.py` |
|
|
42
|
-
| Amazon price split into dollars and cents, recommendation blocks, glued Sam's names, label words inside product names | `htmltext.py`, `parse.py`, `durable.py` | `test_purchase_parsers.py`, `test_durable.py` |
|
|
43
|
+
| Amazon price split into dollars and cents, recommendation blocks (`Items from Your List`, `Deals inspired by your recent history`, the footer `We hope to see you again` cut the order section, so a suggested product is never an item), glued Sam's names, label words inside product names | `htmltext.py`, `parse.py`, `durable.py` | `test_purchase_parsers.py`, `test_durable.py` |
|
|
43
44
|
| No test reads the founder's secrets or token: home and the agents env module point into a temporary folder, `GOOGLE_OAUTH_*` are unset, and opening a file under the real `~/.claude` fails the test | `tests/conftest.py` | `test_secrets_isolation.py` |
|
|
44
45
|
| The Google setup guide names the billing account, the home page and privacy policy URLs needed to publish, and the 7-day Testing token | `README.md`, `resale/README.md` | `test_setup_docs.py` |
|
|
45
46
|
|