Skip to content

feat(visual): Lot 4 — download baselines + route visual/* uploads - #9

Merged
PrestaEdit merged 4 commits into
mainfrom
feat/visual-regression-lot4
Jul 28, 2026
Merged

feat(visual): Lot 4 — download baselines + route visual/* uploads#9
PrestaEdit merged 4 commits into
mainfrom
feat/visual-regression-lot4

Conversation

@PrestaEdit

Copy link
Copy Markdown
Contributor

Summary

Lot 4 of visual regression MVP2 (spec: design doc). Closes the client-side round-trip: the action now downloads baselines from the API before the run and uploads actual/diff after.

  • New `visual` input (default `true`) — disables the round-trip if set to `false`.
  • New `src/visual/prepare.ts` module — runs BEFORE composer. Fetches manifest from `GET /ci/visual/baselines?branch=`, restores GHA cache keyed on `manifest_sha256`, downloads baselines on miss, saves cache. Tolerant to 404/501 for rollout (logs warning, continues). Wrapped in main.ts so a prepare failure never bricks the run.
  • Upload glob extended: `screens/actual/.png` → posted as `visual/actual/`, `screens/diff/.png` → posted as `visual/diff/` (matches the API contract from Lot 1).
  • New dep: `@actions/cache@^4`.
  • Fixed a pre-existing red test in `tests/upload/api.test.ts` (expected trailing slash on endpoint URL that had been dropped in an earlier commit).

Test plan

  • `npm test` → 63/63 PASS
  • `npm run lint` OK
  • `npm run build` — `dist/index.js` rebuilt and committed
  • End-to-end smoke via `PrestaFlow/github-action-smoke` (once branch is merged and `@main` picks up)

🤖 Generated with Claude Code

Add the visual input (default true) controlling the visual regression round-trip with the API.
New src/visual/prepare.ts:
- GET /ci/visual/baselines?branch=... with X-Api-Token
- 404/501 -> warn + no-op (rollout tolerance)
- other non-2xx -> throw
- restore/save GHA cache keyed on visual-baseline-<projectId>-<manifest_sha256>
- cache miss -> download each baseline PNG to <name>--<tag>.png, non-fatal per-file errors

Wired into main.ts before runComposer(); failures are caught and logged as a
warning so a broken/rolling-out visual API never brick the run.

Adds @actions/cache as a dependency.
Extend the upload glob to include screens/actual/*.png and screens/diff/*.png,
and rename them to visual/actual/<file> and visual/diff/<file> in the
multipart form (screens/errors/* keeps its existing screens/<file> naming).

Also fixes a pre-existing test regression: the endpoint URL expectation in
api.test.ts still had the trailing slash that was dropped from src in
14b7c23, so that test was failing on main before this change.
@PrestaEdit
PrestaEdit merged commit 50cba86 into main Jul 28, 2026
@PrestaEdit
PrestaEdit deleted the feat/visual-regression-lot4 branch July 28, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant