Repository navigation
test(typecheck): type-check __tests__/ with tsc -p tsconfig.test.json and fix the 29 errors it finds - #599
Conversation
…huffle `npx vitest run --sequence.shuffle` fails 11 tests in 8 files on main under 4 of 12 seeds tried; the default order passes only because each leaking test happens to run before a neighbour that would not notice. Three mechanisms, all within a file: - a shared imported JSON fixture mutated and never restored: assign, unassign and handleIssueComment rewrite `comment.body`; the cron lgtm test pushed a `hold` label onto the list every other test is served. Clone the fixture or reset the field in beforeEach. - loadProwConfig probes the organization and repository tiers under Promise.all, so when the tier a test exercises rejects, the other tier's sequential probe chain keeps issuing requests after the test returned, and the next test's unhandled-request guard or request:start listener records them. Waiting for the in-flight count to reach zero is satisfied in the gap between two probes. `utils.configFoundAt` serves an empty configuration at the other tier's first probe, so the only sibling request is already in flight when the rejection lands. - module memos not reset: auth.test.ts's outer describes never reset the configuration cache and inherited a `trusted` policy; owners.test.ts's expandOwnersSet describe never reset the group memo; mergeQueueGuards imported @actions/core fresh after a sibling's vi.resetModules while still calling the statically imported queueState, so the assertion spied on a different core instance than the one the module warns through. Adds `npm run test:shuffle` and a "Test order" section to docs/contributing.md describing the three patterns. 18 seeds pass after the change; the bundle suite was already order-independent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…and fix the 29 errors it finds tsconfig.json excludes __tests__/, and Vitest's esbuild transform strips types without checking them, so nothing in the repository type-checks the test suite. Running tsc over src/ and __tests__/ together reports 29 errors in 17 files, several of them fixtures that drifted from the production types they claim to be: - PullRequestOwners gained headSha; the pullOwners() fixture in approve.test.ts, approveErrorPaths.test.ts and approveGuards.test.ts still builds the old shape - ProwConfig gained approve, lgtm, sweep and authorization; the hand-built configs in blunderbuss.test.ts and requireMatchingLabel.test.ts still carry only the original six keys (now built from mergeProwConfig) - msw 3 renamed SetupServerApi to SetupServer (testUtils.ts) - missingNumberMessage.test.ts imports @actions/github/lib/context, which docs/contributing.md forbids; it now imports src/utils/context - lgtmBinding.test.ts builds a sender without the type field the payload type requires - the remainder are untyped spy declarations (tide.test.ts, tideGuards.test.ts), an untyped it.each table (ownersGuards.test.ts), an unresolved this (fakeGithub.ts), a delete on a required field (sweepArms.test.ts), an over-narrow createLabel parameter (labelSync.test.ts), a milestone type intersection that can never be null (milestone.test.ts), a spyOn over a module/name union (handleIssueComment.test.ts) and index-signature mismatches (configurationDocs.test.ts) Adds tsconfig.test.json (extends tsconfig.json, noEmit, includes src/ and __tests__/, excludes the coverageEntry build which has its own tsconfig) and an npm run typecheck script that runs it. npm run build is unchanged. 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 |
e2f71df
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
Verified locally at head e2f71df, independent of the PR description: on main@9acb046 with this PR's tsconfig.test.json, npx tsc -p tsconfig.test.json reports exactly 29 errors; on this branch it reports 0. The three production-type claims hold in the tree: PullRequestOwners.headSha is a required field (src/utils/pullRequestOwners.ts:14) consumed by approveReview.ts:180/197, mergeProwConfig is exported at src/utils/config.ts:754 and returns the full default config the fixtures now spread, and Context is exported from src/utils/context.ts:3, which is the alias docs/contributing.md mandates over @actions/github/lib/context.
Every hunk is type-level only; the two that change runtime code are behavior-preserving:
__tests__/bundle/fakeGithub.ts:146-157—this.unexpectedRequests()becomes a closure reference to the same object. Equivalent at every current call site, and strictly safer ifassertNoUnexpectedRequestsis ever destructured.__tests__/configurationDocs.test.ts:75-79— spreading the settings objects into plain records;toEqualsemantics unchanged, and CI'sbuild-test+e2e-coverageare green on this head.
docs/contributing.md documents the new npm run typecheck, and package.json adds only that script; npm run build is untouched.
The remaining piece — the - run: npm run typecheck line in .github/workflows/test.yml — is correctly left to a human (Refs #170) since workflow files are outside this token tier; until it lands, the script is opt-in. The body's note that held #593 and #595 would fail that future step matches what their diffs add and does not block this PR.
Looks correct to me. No findings.
— 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 |
|
#607 moved the per-run memos into the platform's RunState and removed the reset*() exports this branch's beforeEach hooks called. setup.ts now installs a fresh platform before every test, so those hooks are dropped rather than re-pointed; the fresh-import queueState case installs a platform on its own module graph the way main's sibling case does, and the contributing.md "memo on a module instance" bullet now describes RunState. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Keeps main's two-project build next to the typecheck script, and brings the two test files #607 added under tsc -p tsconfig.test.json: the in-memory Platform in portability.test.ts gains the now-required state(), and both files pass the shared failOnUnhandledRequest to server.listen instead of an msw-2-only option literal that msw 3's SharedOptions rejects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Merged 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
a69b326
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
Verified locally at head a69b326:
npm run typecheck(tsc -p tsconfig.test.json) passes on this branch.- Applying only the new
tsconfig.test.jsonto current main reproduces the drift: real errors in__tests__/bundle/fakeGithub.ts:157(thistyped asFakeGithub | PromiseLike<FakeGithub>),configurationDocs.test.ts:75-79(settings types lack index signatures),sweepArms.test.ts:161,testUtils.ts:1(msw'sSetupServerApi→SetupServer), and the stale fixture shapes. - The fixes are type-level only where it matters:
fakeGithub.tsbinds the object to a named const instead ofthis(same object, same behaviour);blunderbuss.test.ts/requireMatchingLabel.test.tsbuild configs frommergeProwConfig({}, {})so futureProwConfigkeys can't silently drift again; the spread copies inconfigurationDocs.test.tskeeptoEqualsemantics.
One observation, not a defect: nothing runs npm run typecheck automatically — .github/workflows/test.yml runs build/lint/test:coverage and npm run all omits it, so the drift this fixes can reaccumulate until the CI step lands (the body defers that to a human, consistent with this lane not pushing workflow files). A maintainer merging this may want to add the one-line CI step in the same breath.
Looks correct to me.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
jeefy
left a comment
There was a problem hiding this comment.
Type-checking tests/ is overdue; the 29 fixture drifts it found are real. Approving on content. It is conflicting with main — #607/#608/#614/#615 added files under tests/ (adapters/app, worker, server) that the new tsconfig.test.json will include; tests/worker/*.ts uses miniflare types and src/server/worker.ts is excluded from the main tsconfig on purpose, so expect to exclude tests/worker from tsconfig.test.json or give it its own program. Also #593 and #595 merged with the TS errors you flagged on them; fold those one-line fixes in here.
…check-tests After #615, tsconfig.test.json excludes src/server/worker.ts (checked by tsconfig.worker.json with the Cloudflare types, as tsconfig.json already does) and sets skipLibCheck so miniflare's bundled .d.ts does not fail the run. Fixes the five errors tsc then finds in the #608/#615 tests (worker.test.ts's UUID-typed delivery id, webhook.test.ts's TokenSource cast) and adds the 'npm run typecheck' step to build-test that the agent's token tier could not push. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Rebased on #598 +
|
a458931
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
The approach is sound and most of the 29 fixes read correctly, but this PR cannot land as-is: its own new check fails on current main.
Verified by running it (merged pull/599/head onto origin/main, resolving the one conflict):
npx tsc -p tsconfig.test.json reports 3 errors:
__tests__/issueCommentTest/meowImageEdges.test.ts:45— TS2344'"createComment"' does not satisfy the constraint 'never'__tests__/setup.ts:19— TS7006_superimplicitlyany__tests__/utils/configTypeGuards.test.ts:22— TS2532 object possiblyundefined
These are exactly the three the PR body predicted under "Still waiting on a human" for then-held #593 and #595 — both of which have since merged to main. The predicted one-line fixes now belong in this PR (or must land first), because the diff also adds - run: npm run typecheck to build-test in .github/workflows/test.yml, so CI would go red on the merge commit.
Body/diff mismatch worth fixing: the body says the enforcing CI step "cannot be pushed at this agent's token tier" and leaves it for a human via #170 — but the diff does contain the .github/workflows/test.yml hunk. Either the constraint lapsed or the hunk arrived later; either way the body misstates the diff, and a maintainer should be aware they are being asked to approve a bot-authored workflow edit (the step itself is benign: one run line, no permission changes).
Also: mergeable: CONFLICTING — only docs/contributing.md conflicts; code merges clean.
Asks: rebase, fix the three new type errors, and update the body to match the diff (workflow hunk included, #593/#595 no longer held). The tsconfig.test.json + npm run typecheck design itself looks right — extends the root config, noEmit, excludes the coverageEntry build that has its own tsconfig.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
2d9d1c0
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
…ests__/ meowImageEdges.test.ts types the spy as MockInstance<typeof comments.createComment>, setup.ts types overwriteMethod's _super parameter, and configTypeGuards.test.ts reads labels?.kind? off parseProwConfig's Partial<ProwConfig>. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
2d9d1c0 to
bc5324c
Compare
bc5324c
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
Decision needed: @jpmcb should confirm that the npm run typecheck CI step added to .github/workflows/test.yml on this branch via maintainer merge commits (a458931, c42c307, authored by Bob Killen) is intended to land with this PR, since the PR body still says the step is "waiting on a human".
The typecheck work itself checks out; one fact needs a maintainer's eyes because it touches CI.
Body ↔ diff mismatch (the reason for routing): the PR body says the enforcing step in .github/workflows/test.yml "cannot be pushed at this agent's token tier" and is still waiting on a human — but the diff does contain - run: npm run typecheck (test.yml:36, after npm run build). I traced it: the line entered only through merge commits a458931 and c42c307, both authored by Bob Killen (bkillen@linuxfoundation.org), so a maintainer added it to the branch and the body is simply stale. Since .github/workflows is a trust surface, confirming that was intentional is a human call; the step itself adds no permissions and runs an npm script defined in this same PR.
What I verified (at head bc5324c, fresh clone):
npm run typecheck(tsc -p tsconfig.test.json) passes at the head, and still passes after merging currentmain@feed1ba.- Plain
mainwith this PR'stsconfig.test.jsonfailstscwith real errors (e.g.__tests__/worker/worker.test.ts:118,127,145,147— UUID template-literal type violations), so the check is not vacuous and the fixes are needed. build-testCI (which runs the full vitest suite) is green, supporting the "no test semantics change" claim.
Stacking note: this branch contains #598 in full (its head 504e9b9 is an ancestor of bc5324c). Merging #599 first makes #598 a no-op; merging #598 first shrinks this PR to its own ~28-file delta. Both merge cleanly with current main.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
…Place, spy typing The four pre-existing threshold keys are quoted so style/quote-props is consistent with the two glob keys beside them. #615 added deferInPlace as appPlatform's default DeferStrategy and left it at zero unit hits, which the new 'src/adapters/app/**' gate turns into a failure, so platform.test.ts now drives it under fake timers: nothing resolves before the full delay, then 'continue'. tsconfig.test.json (#599) rejects ReturnType<typeof vi.spyOn> as an implicit any for the destructured chunk; the helper takes the structural mock shape instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…'s cron arms, and gate src/adapters/app/** + src/server/** at 100% (main.ts, node.ts:24/67/82, webhook.ts:65, cron.ts:85, vitest.config.mjs) (#611) * test(server): execute src/server's entry point, default background and the dist-server bundle Unit coverage at 282b8e0 reports src/server/main.ts at 0% lines and src/server/node.ts missing the default background arm (line 24), while vitest.e2e-coverage.config.mjs excludes src/server/** on the grounds that unit coverage holds it to 100%. Nothing executes the server as the Dockerfile ships it either: dist-server/ is built by npm run pack but no test reads or runs it. - __tests__/server/main.test.ts mirrors __tests__/main.test.ts: loading the entry point calls main() once with no arguments. - __tests__/server/node.test.ts pins buildReceiver's default background: a signed delivery is answered 202 while its dispatch is still pending. - __tests__/adapters/app/webhookNonErrorThrow.test.ts pins the arm of receiveWebhook that reports a thrown non-Error (webhook.ts:65). - __tests__/server/bundle.test.ts builds src/server/main.ts with ncc into a directory outside the repository, boots it there with no node_modules in reach, and checks the require() list, the json listening line, /healthz, a signed ping and an unsigned rejection. The env.PORT ?? 8080 default (node.ts:47) stays unpinned: it can only be reached by binding 8080. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> * test(server,app): pin #614's cron arms and gate src/adapters/app/** and src/server/** at 100% unit coverage vitest.e2e-coverage.config.mjs leaves the App adapter and its server out of the bundle run because the unit suite holds them at 100%, but nothing enforced that: the global floor is 99, and #614 landed with the String(error) arm of the scheduler's per-repository log (cron.ts:85), both arms of the PROW_CRON_INTERVAL tick's catch (node.ts:82) and the cron argv arm of the entry point (main.ts:6-7) never executed. Each gets a driver, the PORT default is observed through a mocked serve() so nothing binds :8080, and vitest.config.mjs now holds the two excluded trees at 100% so the premise of the exclusion is checked on every run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> * test(app): address review on the per-path gates: quote-props, deferInPlace, spy typing The four pre-existing threshold keys are quoted so style/quote-props is consistent with the two glob keys beside them. #615 added deferInPlace as appPlatform's default DeferStrategy and left it at zero unit hits, which the new 'src/adapters/app/**' gate turns into a failure, so platform.test.ts now drives it under fake timers: nothing resolves before the full delay, then 'continue'. tsconfig.test.json (#599) rejects ReturnType<typeof vi.spyOn> as an implicit any for the destructured chunk; the helper takes the structural mock shape instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Improvement
Nothing type-checks
__tests__/today:tsconfig.jsonexcludes it, Vitest's esbuild transform strips types without checking them, and ESLint runs without atsconfigPath. Runningtsc --noEmitoversrc/and__tests__/together atmain@9acb046reports 29 errors in 17 files, several of them fixtures that drifted from the production types they claim to be:PullRequestOwnersgainedheadSha; thepullOwners()fixture inapprove.test.ts,approveErrorPaths.test.tsandapproveGuards.test.tsstill builds the old shapeProwConfiggainedapprove,lgtm,sweep,authorization; the hand-built configs inblunderbuss.test.tsandrequireMatchingLabel.test.tscarry only the original six keys (now built frommergeProwConfig({}, {}))SetupServerApi→SetupServer;testUtils.ts:1has imported a non-existent type since the bumpmissingNumberMessage.test.ts:1imports@actions/github/lib/context, whichdocs/contributing.mdforbids; now importssrc/utils/contextlgtmBinding.test.tsbuilds asenderwithout thetypethe payload type requiresvi.spyOndeclarations (tide.test.ts,tideGuards.test.ts—.mock.callswasany), an untypedit.eachtable (ownersGuards.test.ts), unresolvedthis(fakeGithub.ts),deleteon a required field (sweepArms.test.ts), over-narrowcreateLabelparameter (labelSync.test.ts), a milestone intersection that can never benull(milestone.test.ts),vi.spyOnover a module/name union (handleIssueComment.test.ts), index-signature mismatches (configurationDocs.test.ts)This PR adds
tsconfig.test.json(extendstsconfig.json,noEmit, includessrc/+__tests__/, excludes thecoverageEntrybuild which has its own tsconfig), annpm run typecheckscript, fixes all 29 errors, and documents the command indocs/contributing.md(Development section).npm run buildis unchanged. No test semantics change:npx vitest run→ 191 files, 2473 passed / 75 skipped, identical tomain.Files / cluster claimed
tsconfig.test.json(new),package.json(typecheckscript only),docs/contributing.md(Development section, not the Testing table), and type-only edits to the 17 test files listed above. Verified withgit merge-tree --write-treeagainst held #591 #593 #595 #596 #597 #598: all six merge cleanly with this branch.Still waiting on a human: the CI step
The enforcing step lives in
.github/workflows/test.yml, which this agent's token tier cannot push. It is one line in jobbuild-test, afternpm run build:Two held PRs would fail that step once it lands and should get a one-line fix on their own branches first: #593
meowImageEdges.test.ts:45(ReturnType<typeof vi.spyOn<…>>→MockInstance<typeof comments.createComment>), #595setup.ts:16(type the_superparameter) andconfigTypeGuards.test.ts:22(labels.kindpossibly undefined). Merging this PR on its own does not break them — only the future CI step would.Related Issue
Refs #170 (needs-human: the
- run: npm run typecheckstep in.github/workflows/test.ymlcannot be pushed at this agent's token tier; the finding was folded onto #170 by the hive under componenttest.yml)Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88