Skip to content

test(api): keep the generated contracts sync test fast - #7946

Merged
jgoux merged 2 commits into
developfrom
test/api-fast-contract-format
Dec 3, 2026
Merged

jgoux merged 2 commits into
developfrom
test/api-fast-contract-format

Conversation

@jgoux

@jgoux jgoux commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The generated-output-sync drift test in packages/api re-renders contracts.ts and formats it with oxfmt to compare it with the committed file. Effect codegen prints each schema on a single line (up to ~30k characters), and oxfmt formats lines like that in superlinear time: about 27s for this file, which pushes the test past its timeout when the repo-wide unit and integration suites run together. pnpm generate:check paid the same cost.

The generator now adds a line break after { in object literals at least twice the print width. oxfmt keeps an object expanded when its source breaks after {, so it skips the fit search, and objects that wide would break anyway. The formatted output is byte-identical to the committed files, and formatting drops to well under a second. Brace matching skips string, template, and comment literals by reusing the generator's existing tokenizer.

The test timeout drops from 120s to 30s, which still leaves headroom under load.

Effect codegen renders each schema on one line, up to ~30k characters,
and oxfmt formats such lines in superlinear time: about 27s for
contracts.ts, past the sync test's timeout under repo-wide test load.

The generator now breaks after `{` in object literals far wider than the
print width. oxfmt keeps such objects expanded without searching for a
fit, and would break them anyway, so the formatted output is unchanged
and formatting takes well under a second.
@jgoux
jgoux requested a review from a team as a code owner December 3, 2026 15:01
@jgoux
jgoux requested a review from kanadgupta December 3, 2026 15:01
@jgoux jgoux self-assigned this Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit 71dd94b against develop at 8d059d9 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 116 ms 119 ms no real change
supabase --help help 121 ms 130 ms no real change (+8%, within normal variation)
supabase init init 127 ms 132 ms no real change
supabase migration new bench migration-new 134 ms 127 ms no real change (-5%, within normal variation)
supabase config convert config-convert 126 ms 122 ms no real change
supabase config validate config-validate 146 ms 139 ms no real change (-5%, within normal variation)
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 159 ms 153 ms no real change
supabase projects list projects-list 131 ms 132 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 134 ms 132 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.3 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 103-151 ms 98-141 ms +3 ms (+3%) within noise
supabase --help help 115-157 ms 110-156 ms +9 ms (+8%) within noise
supabase init init 109-155 ms 105-157 ms +5 ms (+4%) within noise
supabase migration new bench migration-new 111-176 ms 109-153 ms -7 ms (-5%) within noise
supabase config convert config-convert 117-151 ms 116-129 ms -4 ms (-3%) within noise
supabase config validate config-validate 121-170 ms 131-178 ms -8 ms (-5%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 144-195 ms 136-210 ms -7 ms (-4%) within noise
supabase projects list projects-list 116-147 ms 117-149 ms +1 ms (+1%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 127-148 ms 126-154 ms -2 ms (-1%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

Confirmed one documentation nit in the API generator. The comment presents a raw source-length heuristic as a guarantee about formatter output. The generated-output sync test was not run during adjudication. The PR changes no CLI reference prose and does not conflict with the pending work on next.

Findings

Severity Location Category Sources Claim
⚪ NIT packages/api/scripts/generate.ts:555 code-comments codex The comment overstates what the 200-character cutoff guarantees about formatted output.

Stats

Claude findings: 0 · Codex findings: 1 · Confirmed: 1 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread packages/api/scripts/generate.ts Resolved
@jgoux
jgoux added this pull request to the merge queue Dec 3, 2026
Merged via the queue into develop with commit 8329f43 Dec 3, 2026
53 checks passed
@jgoux
jgoux deleted the test/api-fast-contract-format branch December 3, 2026 20:04
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.

2 participants