Skip to content

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

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-wrangler-config
Oct 31, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-wrangler-config

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Test Improvement

One new file, __tests__/worker/wranglerConfig.test.ts, plus a pointer sentence in docs/github-app.md. No src/, config, chart or workflow change; worker.test.ts is untouched.

The suite reads the committed wrangler.toml through wrangler itself (unstable_getMiniflareWorkerOptions, unstable_readConfig — already devDependencies) and pins it two ways:

  • statically — the declared KV / Queue / Durable Object bindings equal the env.X reads in src/server/worker.ts; [vars] and the commented # NAME = examples name only variables settingsFromEnv reads; the consumer's queue is the producer's; every bound Durable Object class is in a migration; a cron trigger backs the exported scheduled(); main is the file the suite bundles; the wrangler kv namespace create / queues create / secret put lines in docs/github-app.md name the same binding, queue and required(env, …) secrets.
  • behaviourally — miniflare is started from exactly the options wrangler derives from the file (the three secrets added), and a redelivered issue_comment is 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" in wrangler.toml leaves wrangler deploy --dry-run at exit 0 and __tests__/worker 4/4 green, while the deployed Worker's env.DELIVERIES is undefined and kvDeliveryStore(env.DELIVERIES).seen() throws on every webhook (worker.ts:99). Removing the [[migrations]] block is a dry-run warning only; changing compatibility_date is silent. Only a wrong class_name is caught (dry-run exit 1), so that one is not asserted. worker.test.ts:49-62 hard-codes its own miniflare bindings, so it tests what its author remembered, not what the file declares. src/server/worker.ts is 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.ts closes for action.yml and configurationDocs.test.ts for docs/configuration.md.

Files / cluster claimed — __tests__/worker/wranglerConfig.test.ts (new) and four lines of docs/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-tree against 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 row
  • npx tsc -p tsconfig.test.json and npx 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)
  • every case fails under the drift it claims and nothing else, each applied to wrangler.toml / docs/github-app.md and reverted: KV binding renamed → the bindings, docs and behavioural cases (3); [[migrations]] removed → migrations case; consumer on prow-jobs-2 → queue and docs cases; PROW_FOO = "x" added to [vars] → vars case; crons = [ ] → trigger case; main = "src/server/node.ts" → main case; docs queues create prow-queue → docs case; # PROW_COMMAND = → vars case

Related 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 Closes unambiguous. 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).

…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>
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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 outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive hivecommons-hive 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.

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.toml binds exactly DELIVERIES, PROW_QUEUE, PULL_REQUEST_LOCK, and those are precisely the env.X resource reads in src/server/worker.ts (lines 77, 100, 108, 132). The PR body's motivating claim — worker.test.ts:12 hard-codes its own miniflare bindings so file drift is invisible — checks out: worker.test.ts never reads wrangler.toml.
  • Vars case (:57-64): settings.ts:17-22,53-56 names PROW_JOBS (the one [vars] entry), PROW_COMMANDS and GITHUB_API_URL (the two # NAME = commented examples), so the arrayContaining superset holds.
  • Queue/migrations/cron: producer prow-jobs = consumer prow-jobs; PullRequestLock is in [[migrations]] new_sqlite_classes; crons non-empty and async scheduled( exists at worker.ts:125.
  • Docs case (:86-93): the docs/github-app.md setup block creates DELIVERIES, prow-jobs, and puts exactly the three required(env, …) secrets from settings.ts:53-55.
  • Behavioural case: delivery:d-config → '1' matches kvDeliveryStore at worker.ts:44-48, and 'already handled' / 200 matches webhook.ts:56. globalSetup.ts builds dist-worker/worker.js for the whole run, so the bundle exists when this file runs.
  • Coverage exclusion claim is accurate: vitest.config.mjs:21 excludes src/server/worker.ts from 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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

/kind cleanup


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: ed3bb42

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 30, 2026
@mrbobbytables mrbobbytables removed the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 31, 2026
@mrbobbytables
mrbobbytables merged commit 3d2c7ec into main Oct 31, 2026
16 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-wrangler-config branch October 31, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant