Skip to content

ci: one reader for the pinned Playwright version, validated once - #464

Merged
sydevs-dispatcher[bot] merged 8 commits into
mainfrom
claude/ci-462-one-playwright-reader
Nov 23, 2026
Merged

sydevs-dispatcher[bot] merged 8 commits into
mainfrom
claude/ci-462-one-playwright-reader

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • One reader, scripts/playwright-version.mjs, produces the version every Chromium cache key is built from, and refuses a pin that is not exact.
  • The browser lane now installs Chromium whether the cache hit or missed, as the gate does — its hit branch handed a partially restored entry on as a browser.

Change outline

How each job's cache key gets its version. One key had two sources, and only one of them refused a range pin — or a newline, which forges a further step output on a fork's pull request.

 gate · Browser lane · Warm the Chromium cache
-  gate:        node -e  require('./package.json').devDependencies.playwright
-                 refuse unless /^\d+\.\d+\.\d+$/, then append version=…
-  lane, warm:  node -p  require('@playwright/test/package.json').version
-                 echo it, unvalidated
+  all three:   node scripts/playwright-version.mjs >> "$GITHUB_OUTPUT"
+                 pinnedPlaywrightVersion(readPackage().devDependencies)
+                   not /^\d+\.\d+\.\d+$/ → throw, so the step exits non-zero
   → key: playwright-chromium-${{ runner.os }}-${{ steps.playwright.outputs.version }}

The browser lane's install, which branched on the restore's outcome.

 Browser lane
   restore (restore-only, the entry browser-cache.yml saves on main)
-  cache-hit != 'true' → playwright install --with-deps --no-shell chromium
-  cache-hit == 'true' → playwright install-deps chromium   # a partial entry is launched into
+  playwright install --with-deps --no-shell chromium       # heals a partial entry

What the spec holds, as one cross-job describe instead of three per-job copies.

 scripts/ci-workflows.test.ts
+├── the Chromium cache key
+│     each of the three scopes builds it from the one reader, and nothing else
+│     both consumers restore the warmed entry, saving none
+│     both consumers install whatever the restore left behind
+│     the key's `playwright` pin agrees with the `@playwright/test` both lanes launch through
-├── ci.yml browser lane: restores the entry browser-cache.yml saves
-├── ci.yml's gate job: restores it too, installs …, keys on a version both pins agree on
-└── versionRead(), the one-liner only two of the three shared

Preview

No preview surface: the diff is two CI workflows, two scripts, two specs and a doc. No deployed artifact changes.

Test results

  • Lean gate: ✓ lint, typecheck, test:run (189 files, 2372 passed, 1 skipped)
  • Targeted specs: scripts/playwright-version.test.ts (7), scripts/ci-workflows.test.ts (38), scripts/wrangler-config.test.ts and scripts/assert-preview-host.test.ts — all passed
  • Build: N/A — nothing in the bundle's graph changed

Manual verification

  1. Read this pull request's own Lint, Typecheck & Build and Browser lane logs: both Chromium steps must report a cache hit. That is what proves the three keys still resolve to one string, and no local run can show it. The value is unchanged (playwright-chromium-Linux-1.65.1), so the entry browser-cache.yml warmed on main should serve both.

Notes for reviewer

  • Why a script, not the composite action the ticket offered as its other shape. The three read → restore → install blocks are not interchangeable: the warm job does a lookup-only restore, downloads without --with-deps, and saves, so one action covering all three needs a save input plus three conditionals — the warm job's divergence moves inside rather than disappearing. Its reader could only be pinned as YAML text, never executed, and the ticket's own verification step wants the reader called directly. Two silent costs decided it: ci-workflows.test.ts's SHA-pin gate globs .github/workflows/*.y(a)ml only, and .github/dependabot.yml's directory: / does not reach a composite action's subdirectory — so every actions/cache pin moved into one would quietly stop being gated and stop being bumped.
  • The two-pin equality assertion is rewritten, not deleted — a deliberate deviation from the ticket's fourth criterion, which calls it spent. Its old reason is gone: two readers decided one key, and one reader does now. But pnpm exec playwright install resolves the playwright pin the key names, while the browser lane and the accessibility gate launch through @playwright/test, which nothing else pins. Bump one alone and pnpm installs a second, nested playwright; the lane then hunts a Chromium revision nothing downloaded and tells the reader to run the install that just ran. One unit assertion catches that in seconds, so it moved to the new describe with that reason. Say the word and it goes.
  • The reader calls readPackage() from _wrangler-config.mjs, the module that owns this parse, and the compiler that made duplicating it tempting is now required inside readWranglerConfig instead of imported at module scope. Measured here, 5 runs each: the script takes 35–42 ms either way, against 362–421 ms for an eager import ts from 'typescript'. Three CI steps import this module for readPackage alone, two of them on a required check's critical path, and none of them parses JSONC.
  • Every new assertion was watched failing against the defect it covers: each refusal against a permissive regex and against the check removed outright, the newline row against an unanchored one, the live pin against a ^1.65.1 pin, the equality against a one-sided bump, each scope's reader pin against its old read restored, the key assertion against hashFiles('package.json'), the install pin against the if: put back, the step-output assertion against both a guard forced false and the version= prefix dropped, each restore row against an actions/cache that saves in place of the restore-only one, and the printed pin against a hard-coded 1.64.0.
  • comment-lint.mjs: clean. Security review: skipped — the diff matches neither securityReview.triggerPattern nor contentPattern.
Detail

Dropping the lane's if: adds no work on a hit. Read out of the installed [email protected]: install --with-deps returns at the top of downloadBrowserWithProgressBar on the INSTALLATION_COMPLETE marker inside the restored directory, so a hit downloads zero bytes; and the apt set is identical, because registry.installDeps keys on _dependencyGroup, which is chromium for both chromium and chromium-headless-shell — so --no-shell narrows the executable list and not the package list. New work on a hit is a dirlock, a .links write and the installation-cache validation, all sub-second. Step count on the hit path is unchanged.

Per-edit budget. Editing the reader selects one spec, at 0.69 s. _wrangler-config.mjs goes from 4 selected specs to 5 — the new spec joins it, since it reads the pin back through readPackage — timed at 1.23 s against the 12 s budget. scripts/select-unit-specs.test.ts's width ceiling of 22 is untouched: the widest edit is still src/test-support/repo-source.ts at 22, and the new spec reaches no repo file through it.

Considered and not done: having the reader print key= and path= too, so the four copies of each literal across the two workflow files collapse to one. It would make the key true by construction rather than held by regex pins, at the cost of moving the key out of sight of anyone reading ci.yml — and ~ expansion in a cache path taken from a step output is a silent-miss risk no local run can settle. Asked as a question thread on the diff.

Closes #462

Three jobs keyed one Chromium cache on the pinned Playwright version and
read it two ways. The gate validated `devDependencies.playwright` as exact
semver before writing its step output, because a step output is repository
text and a newline inside one forges further outputs on a fork's pull
request. The browser lane and the warm job wrote an unvalidated command
substitution over the installed `@playwright/test`. So one key had two
sources, and only one of them refused a range pin.

`scripts/playwright-version.mjs` is the only reader now, and it carries that
validation. `ci-workflows.test.ts` pins that each consumer's key reads its
output and that no job writes a second one, in place of the two-pin equality
assertion #461 needed: with one reader, a divergent `@playwright/test` pin
fails the lane loudly instead of keying the cache on a version nothing wrote.

The browser lane also installs Chromium unconditionally, as the gate does.
Its `if: cache-hit != 'true'` branch ran `install-deps` alone on a hit, so a
partially restored entry was handed on as a browser — the hazard the gate's
own step comment documents.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXWmAFgogYjJfzh1se
Measured: `readPackage()` from `_wrangler-config.mjs` loads the TypeScript
compiler for the wrangler JSONC configs, which this read has no use for.
`node scripts/playwright-version.mjs` went from 380 ms to 35 ms, and the
spec's own run from 645 ms to 166 ms. The reader now parses `package.json`
itself and exports `readPinnedPlaywrightVersion`, so the spec covers the
real file read rather than asserting a value it supplied.

The spec's refusal table drops the two rows that died on a character a row
beside them already covered, and the live-pin case asserts it does not throw
rather than re-matching the pattern the function returns through.

`ci-workflows.test.ts` gains one `describe` for the key all three jobs share,
in place of three per-job copies of the same `it`. Its reader assertion now
pins the step the key names and the key literal, rather than counting step
outputs of any kind — the gate job writes others, so the old shape would have
reddened a test whose name says the version grew a second read.

And the two-pin equality assertion is rewritten rather than deleted. Its old
reason is gone, but `pnpm exec playwright install` resolves the `playwright`
pin the key names while both consumers launch through `@playwright/test`: a
one-sided bump installs a nested second copy, and the lane then hunts a
Chromium revision nothing downloaded.

Prose: one fact had six homes. The newline-forges-an-output why now lives in
the reader alone, and each workflow comment keeps only what its own step
decides.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXWmAFgogYjJfzh1se
…le on it

`/code-review high` found the one gap the two commits before this left: no
spec ran the command the workflows run, so the entry guard, the `version=`
prefix and the newline were uncovered. A guard that stopped firing writes
nothing and exits 0, and because all three jobs share the reader every key
degrades to the same `playwright-chromium-<os>-` at once — the cache keeps
hitting while it tracks no version, with nothing red. Watched failing both
ways: the guard forced false, and the prefix dropped.

`docs/testing.md`'s `paths:` now names the reader, so the rule loads for
whoever edits it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXWmAFgogYjJfzh1se

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread scripts/playwright-version.mjs Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot

sydevs-bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 00:07Z address-review · attempt 1 · session · done
  • 00:07Z address-review · attempt 1 · session
  • 23:56Z review-pr · attempt 1 · session · done
  • 23:56Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 22, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is the size of #462 and no bigger: three read lines collapse into one script. The browser lane's install change is joined, not smuggled — same file, same cache entry, same verification step — and it ends an asymmetry with the gate rather than papering over one. Keeping the two-pin equality assertion against criterion 4 is right: the key names playwright while both lanes launch through @playwright/test, so a one-sided bump still breaks the lane and nothing else pins it.

Findings

  • should-fix — scripts/playwright-version.mjs:16: ROOT and the local package.json read duplicate readPackage() in _wrangler-config.mjs.
  • should-fix — scripts/playwright-version.mjs:39: readPinnedPlaywrightVersion is a middle layer with one production caller.
  • should-fix — docs/testing.md:423: the added ⚠ block restates ci.yml's own comment and retells the spec's cases.
  • consider — scripts/ci-workflows.test.ts:342: two describes are left holding one assertion each.

Second opinion — the key=/path= question: A, the built option. Resolved.

What was checked. #462 criterion by criterion: 1–3 met, 4 deviated with a reason that holds. Read whole on the branch: the new script, both specs, both workflow files, scripts/_wrangler-config.mjs, docs/testing.md. Ladder walked for the pieces new-pieces.mjs left under skipped — the test file's ciWorkflow/browserJob/SCOPES and the three workflow run lines — and for the invokedAs/realpathSync guard, which five sibling scripts/*.mjs write verbatim, so it stays. Streamliner: 5 pieces covered, 3 kept. No preview surface, and this repo declares no fixture block; every path the body names is on the branch. No consumer side to follow — neither contractSync nor docs/embedding.md is touched.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread scripts/playwright-version.mjs Resolved
Comment thread scripts/playwright-version.mjs Resolved
Comment thread docs/testing.md Resolved
Comment thread scripts/ci-workflows.test.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 23, 2026
`_wrangler-config.mjs` exists to own the script-side `package.json` read, and
the reader grew a second root and a second parse to avoid its cost: the module
imports the TypeScript compiler for the wrangler JSONC configs, which this read
has no use for and three CI steps would pay.

Requiring the compiler inside `readWranglerConfig` keeps the saving and drops
the duplication. Measured here, 5 runs each: the script takes 35-42 ms either
way, against 362-421 ms for an eager `import ts from 'typescript'`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVLqoXwaEoCcv9hoGM
`readPinnedPlaywrightVersion` stood between the print and the validator with
one production caller, and the spec case that covered it asserted the printed
line against the very function the script called, so it could not fail.

The print composes the two directly, and the command case asserts the pin as
`package.json` has it — watched failing against a hard-coded `1.64.0`, which the
old form passed. It keeps the live pin's own coverage: a `^1.65.1` entered in
`package.json` fails the command, and the case with it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVLqoXwaEoCcv9hoGM
Both held `expectRestoresWarmedCache` alone, one per consumer, while the table
below them already names those two as `SCOPES.slice(0, 2)`. The assertion is a
row there now, watched failing for each scope against an `actions/cache` that
saves in place of the restore-only one.

The gate describe's #459 reasoning moves onto that row, which is the only thing
left reading it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVLqoXwaEoCcv9hoGM
The install block's `if:` reason is the comment beside that step in `ci.yml`,
where whoever edits it reads it, and the two trailing clauses retold
`ci-workflows.test.ts`'s cases — which the paragraph above already points at in
one line. What is left is the claim the file owns: one reader, and why a
step output refuses an inexact pin.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVLqoXwaEoCcv9hoGM
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 601b855 Nov 23 2026, 12:17 AM

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Four critic threads, all adopted. One commit each, on 601b855.

origin/main merged in clean. Lean gate green: 2372 passed, 1 skipped. Every new or moved assertion watched failing.

The body's ## Change outline and readPackage() note said the opposite of what now ships. Both are refreshed, with the file count and the figures.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 23, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 23, 2026
@sydevs-dispatcher
sydevs-dispatcher Bot marked this pull request as ready for review November 23, 2026 00:20
@sydevs-dispatcher
sydevs-dispatcher Bot requested a review from Ardnived November 23, 2026 00:20
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 23, 2026
@sydevs-dispatcher
sydevs-dispatcher Bot added this pull request to the merge queue Nov 23, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 23, 2026
Merged via the queue into main with commit d257d20 Nov 23, 2026
85 of 90 checks passed
@sydevs-dispatcher
sydevs-dispatcher Bot deleted the claude/ci-462-one-playwright-reader branch November 23, 2026 00:45
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

ci: one reader for the pinned Playwright version, validated once

3 participants