Repository navigation
test(worker): run the bundle under wrangler.toml's own bindings and pin the file to worker.ts and the docs (__tests__/worker/wranglerConfig.test.ts) - #632
Conversation
…in the file to worker.ts and the docs (__tests__/worker/wranglerConfig.test.ts) `wrangler deploy --dry-run` exits 0 when a KV or Queue binding in wrangler.toml no longer matches the name src/server/worker.ts dereferences, and only warns when a bound Durable Object has no migration; worker.test.ts spells out its own miniflare bindings, so it stays green through the same drift. This suite reads the committed file through wrangler's unstable_getMiniflareWorkerOptions and unstable_readConfig: statically, the declared resource bindings equal the `env.X` reads in worker.ts, `[vars]` (and the commented examples) name only variables settingsFromEnv reads, the consumer feeds the producer's queue, every bound Durable Object class is migrated, a cron trigger backs the exported scheduled(), `main` is the file the tests bundle, and the `wrangler kv namespace create` / `queues create` / `secret put` lines in docs/github-app.md name the same binding, queue and required secrets. Then it starts miniflare from exactly those options and dedupes a redelivered issue_comment through the KV namespace the file binds, so a renamed binding fails as it would in production. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
There was a problem hiding this comment.
Read the diff against main@ed3bb42 plus the files it pins. This looks correct to me; every assertion in the suite matches what the tree actually contains.
Verified against the tree:
- Binding parity (
wranglerConfig.test.ts:53-55):wrangler.tomlbinds exactlyDELIVERIES,PROW_QUEUE,PULL_REQUEST_LOCK, and those are precisely theenv.Xresource reads insrc/server/worker.ts(lines 77, 100, 108, 132). The PR body's motivating claim —worker.test.ts:12hard-codes its own miniflare bindings so file drift is invisible — checks out:worker.test.tsnever readswrangler.toml. - Vars case (
:57-64):settings.ts:17-22,53-56namesPROW_JOBS(the one[vars]entry),PROW_COMMANDSandGITHUB_API_URL(the two# NAME =commented examples), so thearrayContainingsuperset holds. - Queue/migrations/cron: producer
prow-jobs= consumerprow-jobs;PullRequestLockis in[[migrations]] new_sqlite_classes;cronsnon-empty andasync scheduled(exists atworker.ts:125. - Docs case (
:86-93): thedocs/github-app.mdsetup block createsDELIVERIES,prow-jobs, and puts exactly the threerequired(env, …)secrets fromsettings.ts:53-55. - Behavioural case:
delivery:d-config→'1'matcheskvDeliveryStoreatworker.ts:44-48, and'already handled'/ 200 matcheswebhook.ts:56.globalSetup.tsbuildsdist-worker/worker.jsfor the whole run, so the bundle exists when this file runs. - Coverage exclusion claim is accurate:
vitest.config.mjs:21excludessrc/server/worker.tsfrom lcov, so this is a config-contract test, not coverage theatre.
File set (__tests__/worker/wranglerConfig.test.ts + 4 lines of docs/github-app.md) is disjoint from #626/#630/#631 as the body states. CI is green at head b5d6e32 (build-test, e2e-coverage, chart, DCO).
No defects found. The PR carries the hold label per the lane's hold-gated mode, so landing it remains the maintainers' call.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Test Improvement
One new file,
__tests__/worker/wranglerConfig.test.ts, plus a pointer sentence indocs/github-app.md. Nosrc/, config, chart or workflow change;worker.test.tsis untouched.The suite reads the committed
wrangler.tomlthrough wrangler itself (unstable_getMiniflareWorkerOptions,unstable_readConfig— already devDependencies) and pins it two ways:env.Xreads insrc/server/worker.ts;[vars]and the commented# NAME =examples name only variablessettingsFromEnvreads; the consumer's queue is the producer's; every bound Durable Object class is in a migration; a cron trigger backs the exportedscheduled();mainis the file the suite bundles; thewrangler kv namespace create/queues create/secret putlines indocs/github-app.mdname the same binding, queue andrequired(env, …)secrets.issue_commentis deduped through the KV namespace the file binds, with the installation token minted on the way.Why. Verified at main@ed3bb42 with wrangler 4.155.0: renaming
binding = "DELIVERIES"inwrangler.tomlleaveswrangler deploy --dry-runat exit 0 and__tests__/worker4/4 green, while the deployed Worker'senv.DELIVERIESis undefined andkvDeliveryStore(env.DELIVERIES).seen()throws on every webhook (worker.ts:99). Removing the[[migrations]]block is a dry-run warning only; changingcompatibility_dateis silent. Only a wrongclass_nameis caught (dry-run exit 1), so that one is not asserted.worker.test.ts:49-62hard-codes its own miniflare bindings, so it tests what its author remembered, not what the file declares.src/server/worker.tsis excluded from both lcov runs by written config (vitest.config.mjs:21), so this is a configuration-contract gap, not a line-coverage one — the same class__tests__/workflows.test.tscloses foraction.ymlandconfigurationDocs.test.tsfordocs/configuration.md.Files / cluster claimed —
__tests__/worker/wranglerConfig.test.ts(new) and four lines ofdocs/github-app.md. Disjoint from held #626 (charts/prow-github-app/tests/**), #630 (__tests__/worker/worker.test.ts) and #631 (__tests__/server/**,__tests__/adapters/app/**);git merge-treeagainst all three heads is clean.Testing
rm -rf dist-worker && npx vitest run __tests__/worker— 12 passed (4 existing + 8 new), three runs in a rownpx tsc -p tsconfig.test.jsonandnpx eslint __tests__/worker docs/github-app.md— clean (wrangler's option types do not resolve from this project, so the suite declares the narrow shape it reads and casts once)wrangler.toml/docs/github-app.mdand reverted: KV binding renamed → the bindings, docs and behavioural cases (3);[[migrations]]removed → migrations case; consumer onprow-jobs-2→ queue and docs cases;PROW_FOO = "x"added to[vars]→ vars case;crons = [ ]→ trigger case;main = "src/server/node.ts"→ main case; docsqueues create prow-queue→ docs case;# PROW_COMMAND =→ vars caseRelated Issue
None — the issue request for this finding was folded by the hive onto the tracker that held #630 already closes, so it is not cited here to keep that PR's
Closesunambiguous. This PR is complete on its own.Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88
Refs #629 (the wrangler.toml drift finding folded into that issue).