Skip to content

fix(cli): port db test to native TypeScript (CLI-1962) - #6063

Merged
Coly010 merged 9 commits into
developfrom
columferry/cli-1962-port-db-test-to-native-typescript
Aug 6, 2026
Merged

fix(cli): port db test to native TypeScript (CLI-1962)#6063
Coly010 merged 9 commits into
developfrom
columferry/cli-1962-port-db-test-to-native-typescript

Conversation

@Coly010

@Coly010 Coly010 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What changed

Ports db test (a hidden, Phase-0 Go-proxy command) and its test db alias to native TypeScript. Go registers the same RunE function under two cobra commands (cmd/db.go:422-429 hidden, cmd/test.go:17-20 visible) with byte-identical flags (--db-url, --linked, --local — default true on both). This PR mirrors that structure: hoisted the shared implementation (handler, errors, pg-prove-args, a new command-handler, and runtime layers) into apps/cli/src/legacy/shared/legacy-test-db.*, with both db/test/test.command.ts and test/db/db.command.ts reduced to thin registrations differing only in their commandPath (needed for Go-parity telemetry, since cmd.CommandPath() differs even though RunE is identical).

The underlying pgTAP-enable/pg_prove-container-invocation logic itself was already natively correct from a prior PR (#5522) — this PR is primarily a rewire (removing the db test proxy handler), not a re-port. Confirmed via go-parity-auditor: bind-mount/workingDir derivation, network-mode switching, Bitbucket SecurityOpt handling, Linux-only ExtraHosts, and exit-code propagation (error running container: exit N) all already matched Go.

This also resolves the audit's previously-flagged "--local default-true modelling caveat" — confirmed the resolved default is true on both entry points, matching Go exactly.

Bonus, undisclosed-until-now parity fix: test db's help text previously read "Run pgTAP tests on the local or linked database." — Go's actual Short (shared via dbTestCmd.Short) is "Tests local database with pgTAP". Both entry points now byte-match.

Why

Part of the M9 "Go removal" milestone. Removes the LegacyGoProxy dependency for db test/test db entirely.

Review notes

Reviewed independently by go-parity-auditor, engineer-reviewer, and architect-reviewer — all approved after a follow-up commit. The engineer-reviewer caught (via mutation testing) that one new test didn't actually exercise the real command wiring and another assertion was vacuous; both are now fixed and mutation-verified. Also fixed: two stale Go line-number references in carried-over comments, a stale doc pointer in docs/go-cli-porting-status.md, and single-sourced the Short/description strings between the two command registrations to prevent future drift.

Fixes CLI-1962

Coly010 added 2 commits August 4, 2026 15:42
`db test` was the last Go-proxy seam in the db/test family: it forwarded
argv to the Go binary while its visible sibling `test db` had already been
natively ported (PR #5522). Go itself models these as two cobra.Command
registrations sharing the literal same RunE (cmd/test.go:19-20 borrows
cmd/db.go's dbTestCmd.RunE), so this port makes `db test` reuse `test db`'s
flag config and assembled handler verbatim instead of re-implementing pgTAP
enable/disable and the pg_prove docker invocation a second time.

Since the shared implementation is now used by two different top-level
command families (db and test), and legacy/commands/<family>/ files may not
import another family's internals (enforced by code-structure.unit.test.ts),
the whole test-db implementation (handler, errors, pg-prove-args builder,
config, assembled command handler, runtime layer) moves out of
legacy/commands/test/db/ into legacy/shared/legacy-test-db.*, mirroring Go's
own internal/db/test package consumed by two thin cmd/ registrations.

The recorded cli_command_executed telemetry `command` property now reflects
the actual invoked path ("db test" vs "test db"), matching Go's
cmd.CommandPath() parity (cmd/root_analytics.go:33) — the runtime layer
factory takes a commandPath argument so each entry point passes its own.

This also resolves the proxy-only "--local defaults to true" modelling
caveat: the flag now drives resolveLegacyDbTargetFlags's presence-based
selection directly, the same mechanism test db already used, so Go's real
default is reflected exactly with no proxy-only quirk to carry over.
Fix issues flagged by review on the db test/test db native TypeScript
port: the alias telemetry test now dispatches through the real
legacyDbTestCommand (via Command.runWith) instead of hand-building a
runtime layer with a test-supplied commandPath, so a regression in
test.command.ts's own commandPath wiring is actually caught; a vacuous
hidden-flag defect assertion now checks the real Die/Fail discriminator
and defect message instead of a near-always-true negative string check;
two weak alias-integration assertions are replaced with assertions on
actual docker invocation and exit-code state; the Short/description
strings are single-sourced to prevent drift between the two Go-parity
entry points; and stale Go line-number references (db.go/docker.go) and
the porting-status doc's implementation location/--network-id note are
corrected.
@Coly010

Coly010 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Coly010 Coly010 self-assigned this Aug 5, 2026
@Coly010
Coly010 marked this pull request as ready for review August 5, 2026 08:53
@Coly010
Coly010 requested a review from a team as a code owner August 5, 2026 08:54
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@53320795ece242d1be211a42acbed70cdc24cf53

Preview package for commit 5332079.

@Coly010
Coly010 added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Aug 5, 2026
Coly010 added 2 commits August 6, 2026 11:40
…2-port-db-test-to-native-typescript

# Conflicts:
#	apps/cli/docs/go-cli-porting-status.md
…on.test.ts

Dispatching through legacyDbCommand (the whole `db` subtree) pulls in every
sibling subcommand's global-flag and LegacyGoProxy requirements at the type
level, even though this test only runs `db test`. The develop merge bumped
effect/@effect/vitest, which now enforces `it.live`'s R = Scope exactly,
surfacing the gap.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef5a01557b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/shared/legacy-test-db.command-handler.ts
Coly010 added 3 commits August 6, 2026 11:59
…resolution

The merge-conflict resolution edited table cell text without re-running
oxfmt, so the padded column widths drifted and fmt:check failed in CI.
…ag test

The develop merge bumped effect to a version whose CliError._tag for this
case is upstream-misspelled "UnknownSubcomand" (see normalize-error.ts and
subcommand-flag-suggestions.ts, which already correct it for user-facing
output). This assertion checks the raw, un-normalized tag, so it must match
the upstream spelling rather than the aspirational correct one.
…2-port-db-test-to-native-typescript

# Conflicts:
#	apps/cli/docs/go-cli-porting-status.md
@Coly010
Coly010 added this pull request to the merge queue Aug 6, 2026
Merged via the queue into develop with commit 14f93c3 Aug 6, 2026
14 checks passed
@Coly010
Coly010 deleted the columferry/cli-1962-port-db-test-to-native-typescript branch August 6, 2026 11:30
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