ci: load postgres in a way that works for v3 and v4 #342

Merged
ullrich merged 1 commit from ci-postgres-require-v4-compatible into main 2026-11-15 23:28:48 +00:00
Owner

Summary

The two "Provision database" steps in .forgejo/workflows/ci.yml (E2E Tests and Journal Image Smoke Test) loaded the driver with require("postgres") and called the result. postgres v4 is ESM-only, so require() returns the module namespace and the step fails before any test runs:

TypeError: postgres is not a function

This is why #311 (postgres v4) is red: CI never reached application code, so the PR says nothing yet about whether the app works on v4.

The steps now use mod.default ?? mod, which resolves to the function on both v3 (CommonJS) and v4 (ESM). No dependency changes.

Verification

  • node -e with the same two lines against the installed postgres 3.4.9: typeof postgres === "function".
  • The same against postgres 4.1.1 in a scratch directory (Node 24.0.1): require() returns an object, mod.default ?? mod is a function.
  • prettier --check passes on the workflow file.
  • Not run locally: pnpm typecheck, lint, test, test:e2e. The change is inside two CI shell steps; this PR's own E2E and smoke jobs exercise it on v3.

Risk and rollback

  • CI only; no runtime code changes. Revert the commit to roll back.
  • After merge, #311 needs a rebase to pick this up. Its E2E result will then show the real v4 risks (infer: false parameter typing, drizzle-orm's use of driver internals).

🤖 Generated with Claude Code

## Summary The two "Provision database" steps in `.forgejo/workflows/ci.yml` (E2E Tests and Journal Image Smoke Test) loaded the driver with `require("postgres")` and called the result. postgres v4 is ESM-only, so `require()` returns the module namespace and the step fails before any test runs: ``` TypeError: postgres is not a function ``` This is why #311 (postgres v4) is red: CI never reached application code, so the PR says nothing yet about whether the app works on v4. The steps now use `mod.default ?? mod`, which resolves to the function on both v3 (CommonJS) and v4 (ESM). No dependency changes. ## Verification - `node -e` with the same two lines against the installed postgres 3.4.9: `typeof postgres === "function"`. - The same against postgres 4.1.1 in a scratch directory (Node 24.0.1): `require()` returns an object, `mod.default ?? mod` is a function. - `prettier --check` passes on the workflow file. - Not run locally: `pnpm typecheck`, `lint`, `test`, `test:e2e`. The change is inside two CI shell steps; this PR's own E2E and smoke jobs exercise it on v3. ## Risk and rollback - CI only; no runtime code changes. Revert the commit to roll back. - After merge, #311 needs a rebase to pick this up. Its E2E result will then show the real v4 risks (`infer: false` parameter typing, drizzle-orm's use of driver internals). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ci: load postgres in a way that works for v3 and v4
All checks were successful
CI / Security Scan (pull_request) Successful in 8s
CI / Dockerfile Package Check (pull_request) Successful in 4s
CI / Checks (pull_request) Successful in 42s
CI / Visual Tests (pull_request) Successful in 36s
CI / Journal Image Smoke Test (pull_request) Successful in 57s
CI / E2E Tests (pull_request) Successful in 4m9s
CD Staging / Build & Push journal Image (pull_request) Has been skipped
CD Staging / Build & Push planner Image (pull_request) Has been skipped
CD Staging / Deploy Staging (pull_request) Has been skipped
CD Staging / Deploy PR Preview (pull_request) Has been skipped
Cancel superseded CI / Cancel in-flight CI (pull_request) Successful in 1s
CD Staging / Tear Down PR Preview (pull_request) Successful in 13s
980a6caf1c
The two "Provision database" steps used `require("postgres")` and called
the result. postgres v4 is ESM-only, so require() returns the module
namespace and the call fails with "postgres is not a function" before
any test runs (#311: E2E Tests and Journal Image Smoke Test).

Use `mod.default ?? mod`, which resolves to the function on both majors.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ullrich scheduled this pull request to auto merge when all checks succeed 2026-11-15 23:24:28 +00:00
ullrich deleted branch ci-postgres-require-v4-compatible 2026-11-15 23:28:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
trails-cool/trails!342
No description provided.