diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65aacc1a5..9740e383a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ permissions: # Server tests i/10 one slice of the server suite, with coverage # Server coverage merges the slices, checks the per-domain # thresholds, uploads lcov -# Server Postgres 14 i/3, Server Postgres 18 i/3 +# Server Postgres 14 i/3, Server Postgres 19 i/3 # per supported major, in three slices: the probe # (the repository SQL against Postgres, first slice # only), then a slice of the lane (every suite that @@ -55,7 +55,7 @@ permissions: # Client e2e i/2 one slice of the browser flows in Chromium and # WebKit, in the Playwright container # Docker and Helm builds the image and boots it until ready, on -# SQLite and on Postgres 18; lints and renders the +# SQLite and on Postgres 19; lints and renders the # Helm chart and checks the compose files # Sonar SonarCloud analysis, not required # ci-ok the one required check (below) @@ -639,7 +639,7 @@ jobs: retention-days: 1 # TREK on Postgres, once per supported major: the oldest (14) and the newest - # (18). Both steps run against the same service, the probe on an empty + # (19). Both steps run against the same service, the probe on an empty # database of its own, the lane on databases it creates and drops. # # The probe (server/scripts/pg-probe.ts): against an empty Postgres it @@ -696,7 +696,7 @@ jobs: strategy: fail-fast: false matrix: - postgres: [14, 18] + postgres: [14, 19] shard: [1, 2, 3] services: postgres: @@ -757,14 +757,14 @@ jobs: if-no-files-found: ignore retention-days: 14 - # The image ships the 18 client tools, which write settings a 14 server + # The image ships the 19 client tools, which write settings a 14 server # does not know; the backup round trip runs with the same tools here. - - name: Install the PostgreSQL 18 client tools + - name: Install the PostgreSQL 19 client tools run: | set -euo pipefail sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y >/dev/null - sudo apt-get install -y --no-install-recommends postgresql-client-18 >/dev/null - /usr/lib/postgresql/18/bin/pg_restore --version + sudo apt-get install -y --no-install-recommends postgresql-client-19 >/dev/null + /usr/lib/postgresql/19/bin/pg_restore --version - name: Run the Postgres lane if: ${{ !cancelled() }} @@ -1347,7 +1347,7 @@ jobs: set -euo pipefail docker network create trek-ci-pg docker run -d --name trek-ci-db --network trek-ci-pg \ - -e POSTGRES_PASSWORD=ci -e POSTGRES_DB=trek postgres:18 + -e POSTGRES_PASSWORD=ci -e POSTGRES_DB=trek postgres:19 for _ in $(seq 1 30); do docker exec trek-ci-db pg_isready -U postgres -d trek >/dev/null 2>&1 && break sleep 2 diff --git a/CLAUDE.md b/CLAUDE.md index acfd440d3..056accbe3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -137,7 +137,7 @@ These principles come out of a full-repo audit and shape all new code: ## Quality gates in CI -`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:engine-dispatch`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in `server-lint`), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, TREK on Postgres (`server-postgres`, once per supported major, 14 and 18, each in three slices: first the Postgres probe (in the first slice), every dialect helper on SQLite and Postgres and the statements every repository method reaches with sample arguments, its SQL errors per method and the methods it cannot measure held to a baseline that only shrinks and fails while it is still unmeasured; then the Postgres lane, every suite that boots the app on the real database module, found by `server/tests/postgres/lane.ts` rather than listed, plus PARITY-PG and the write lock; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit, in the Playwright container, in two slices), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers, on SQLite and on Postgres 18, and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (both in `docker`, each part when its area changed). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags. +`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:engine-dispatch`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in `server-lint`), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, TREK on Postgres (`server-postgres`, once per supported major, 14 and 19, each in three slices: first the Postgres probe (in the first slice), every dialect helper on SQLite and Postgres and the statements every repository method reaches with sample arguments, its SQL errors per method and the methods it cannot measure held to a baseline that only shrinks and fails while it is still unmeasured; then the Postgres lane, every suite that boots the app on the real database module, found by `server/tests/postgres/lane.ts` rather than listed, plus PARITY-PG and the write lock; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit, in the Playwright container, in two slices), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers, on SQLite and on Postgres 19, and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (both in `docker`, each part when its area changed). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags. - **Job names read " [ ][ i/n]"** (`Server tests 3/10`, `Server Postgres 14 2/3`, `Docker and Helm`): the area first, one of Changes, Shared, Server, Client, Docker or Sonar, then lower case, with no colon, no parentheses and no middle dot, and a slice only at the end, so the checks list sorts by area. The workflow is named `CI`, so a check reads `CI / Server tests 3/10`. Job ids are the names in kebab-case (`server-tests`), the jobs stand in `test.yml` in area order, and the list at the top of `test.yml` says what each job holds. A new job follows the scheme and joins that list; `scripts/ci/workflow-jobs.test.mjs` fails on a name outside it. `ci-ok`, `lint` and `check-target` keep their names: the ruleset requires them by name. - **What the folded jobs hold.** `Shared tests` is the plugin SDK's typecheck and coverage, run before the root install so the SDK resolves only its own dependencies, then i18n parity and shared's coverage. `Client types` is the typecheck and the strict ratchet; `Client checks` the source ratchets, then the production build with `check:gl-split`. `Docker and Helm` builds and boots the image when the image area changed and checks the chart and compose files when the deploy area changed. Inside a folded job each group of steps runs after a failure in another, so one red check shows every gate that failed; the step names say which. diff --git a/Dockerfile b/Dockerfile index 21c0924c7..2e92a0c3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,22 +73,30 @@ COPY server/package.json ./server/ # The upgrade takes the Debian security fixes the base image was built before # (zlib, 11/2026, failed the image scan until node:24-trixie-slim caught up). # -# postgresql-client-18 brings pg_dump, pg_restore and psql to -# /usr/lib/postgresql/18/bin, which back up and restore an install on Postgres +# postgresql-client-19 brings pg_dump, pg_restore and psql to +# /usr/lib/postgresql/19/bin, which back up and restore an install on Postgres # (TREK_DB_URL). A client handles every server up to its own major and refuses -# a newer one, so the image carries the newest major TREK supports (14 to 18). +# a newer one, so the image carries the newest major TREK supports (14 to 19). # Debian 13 ships 17 only, so it comes from the PostgreSQL project's apt -# repository (PGDG): the `18` component lists that major's packages and no -# other, and the repository's signing key (fingerprint B97B 0AFC AA1A 47F0 44F2 -# 44A0 7FCC 7D46 ACCC 4CF8) is kept beside the entrypoint instead of fetched at -# build time. Raise both together when TREK supports a newer major. +# repository (PGDG): its `main` component carries every major the project +# supports, and the package name pins the one installed. The per-major +# components can trail a new release, so the image does not rely on them. The +# repository's signing key (fingerprint B97B 0AFC AA1A 47F0 44F2 44A0 7FCC 7D46 +# ACCC 4CF8) is kept beside the entrypoint instead of fetched at build time. +# Raise the package together with SUPPORTED_SERVER_MAJORS in +# server/src/db/engine/postgres/server-checks.ts. +# Earlier images carried the version 18 tools, and installs that set +# TREK_DB_PG_BIN_DIR=/usr/lib/postgresql/18/bin (the old .env.example value) +# would lose backups and the pre-migrate snapshot after updating, so that path +# stays as a link to the 19 tools, which handle every supported server. COPY server/scripts/pgdg-apt-key.asc /etc/apt/keyrings/pgdg.asc -RUN echo 'deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt trixie-pgdg main 18' \ +RUN echo 'deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt trixie-pgdg main' \ > /etc/apt/sources.list.d/pgdg.list && \ apt-get update && \ apt-get upgrade -y --no-install-recommends && \ apt-get install -y --no-install-recommends tzdata dumb-init wget ca-certificates \ - libkitinerary-bin libsqlite3-0 postgresql-client-18 && \ + libkitinerary-bin libsqlite3-0 postgresql-client-19 && \ + mkdir -p /usr/lib/postgresql/18 && ln -s /usr/lib/postgresql/19/bin /usr/lib/postgresql/18/bin && \ npm ci --workspace=server --omit=dev --ignore-scripts && \ { ln -sf "$(find /usr/lib -name kitinerary-extractor -type f | head -1)" /usr/local/bin/kitinerary-extractor || true; } && \ rm -rf /var/lib/apt/lists/* /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx && \ diff --git a/README.md b/README.md index 5b9b0a4d0..29d402aa4 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,7 @@ docker compose up -d See [Install with Docker Compose](https://github.com/liketrek/TREK/wiki/Install-Docker-Compose) for the full walkthrough. -TREK stores its data in SQLite by default. Set `TREK_DB_URL` to run it on a PostgreSQL 14 to 18 database instead. The +TREK stores its data in SQLite by default. Set `TREK_DB_URL` to run it on a PostgreSQL 14 to 19 database instead. The [`docker-compose.postgres.yml`](docker-compose.postgres.yml) example starts one beside TREK, and the [Postgres guide](https://github.com/liketrek/TREK/wiki/Database-Postgres) covers the requirements, the backups and how to move an existing SQLite install to Postgres with the command TREK ships for it. diff --git a/charts/trek/values.yaml b/charts/trek/values.yaml index baa1d2e06..175febec9 100644 --- a/charts/trek/values.yaml +++ b/charts/trek/values.yaml @@ -190,7 +190,7 @@ env: # starting it on SQLite. The role in the URL owns TREK's database and must not be a superuser # (nor a member of one, nor hold a right that reaches the server's files or programs): a # restore runs the backup's SQL as that role and refuses one that could reach the database host. The wiki page shows the -# SQL that creates such a role. PostgreSQL 14 to 18 is supported. +# SQL that creates such a role. PostgreSQL 14 to 19 is supported. # url: "postgres://trek:@postgres.example.internal:5432/trek?sslmode=require" database: url: "" diff --git a/docker-compose.postgres.yml b/docker-compose.postgres.yml index 574fc1124..051899caf 100644 --- a/docker-compose.postgres.yml +++ b/docker-compose.postgres.yml @@ -21,11 +21,12 @@ # superuser trek; the wiki page Database-Postgres ("Moving a compose install # off the superuser") shows how to move it to this layout. # -# The database runs PostgreSQL 18. TREK supports 14 to 18: to run 14 to 17, -# change the image tag and mount the volume at /var/lib/postgresql/data -# instead, where those images keep their data (the 18 image refuses that -# path). An existing database stays on the major it was created with: when -# you update this file, keep your image tag and volume path. Moving to +# The database runs PostgreSQL 18. TREK supports 14 to 19: a new database +# may run postgres:19 on the same volume path. To run 14 to 17, change the +# image tag and mount the volume at /var/lib/postgresql/data instead, where +# those images keep their data (the 18 and 19 images refuse that path). An +# existing database stays on the major it was created with: when you update +# this file, keep your image tag and volume path. Moving to # another major needs pg_upgrade, or a dump and restore (a TREK backup # restored into a new, empty database of the same or a newer major), never # just a new image tag. @@ -46,7 +47,7 @@ services: - no-new-privileges:true # No ports are published: only the trek service on the compose network reaches the database. volumes: - # The path the postgres:18 image expects. Images 14 to 17 need + # The path the postgres:18 and :19 images expect. Images 14 to 17 need # /var/lib/postgresql/data here (see the top of this file). - trek-pgdata:/var/lib/postgresql healthcheck: diff --git a/server/.env.example b/server/.env.example index 53d2da7e4..1b8c2a98d 100644 --- a/server/.env.example +++ b/server/.env.example @@ -53,7 +53,7 @@ DEMO_MODE=false # Demo mode: resets data hourly # BACKUP_UPLOAD_LIMIT_MB=500 # Max size (MB) of a backup archive you can upload when restoring. Raise it if your backup exceeds 500 MB. If you sit behind a reverse proxy, raise its upload limit too (e.g. nginx client_max_body_size). # TREK_DB_URL=postgres://trek:password@db:5432/trek # Run on a Postgres database instead of the SQLite file in data/. TREK creates its schema in an empty database and refuses one holding tables it did not create. sslmode=disable, require, verify-ca or verify-full (the last three always verify the certificate; sslrootcert= names the CA file). For a server that asks for a client certificate, sslcert= and sslkey= name the certificate and its key file, both together and only with a verifying sslmode. A Unix socket: postgresql://trek@localhost/trek?host=/var/run/postgresql (a host= or port= parameter takes the place of the URL's own, as in libpq). Cannot be combined with TREK_DB_FILE, TREK_DB_JOURNAL_MODE or TREK_DB_SYNCHRONOUS. -# TREK_DB_PG_BIN_DIR=/usr/lib/postgresql/18/bin # The directory holding pg_dump, pg_restore and psql, which back up and restore a Postgres database. Unset, TREK looks in /usr/lib/postgresql/<18..14>/bin, newest first, then /usr/local/bin and /usr/bin (the Docker image installs the version 18 tools, which work with every supported server; tools older than the server are refused). Unused on SQLite. +# TREK_DB_PG_BIN_DIR=/usr/lib/postgresql/19/bin # The directory holding pg_dump, pg_restore and psql, which back up and restore a Postgres database. Unset, TREK looks in /usr/lib/postgresql/<19..14>/bin, newest first, then /usr/local/bin and /usr/bin (the Docker image installs the version 19 tools, which work with every supported server; tools older than the server are refused). Unused on SQLite. # TREK_DB_POOL_MAX=10 # Most connections TREK opens to the Postgres database (1 to 100). Unused on SQLite. (default: 10) # TREK_DB_JOURNAL_MODE=WAL # SQLite journal mode (DELETE, TRUNCATE, PERSIST, MEMORY, WAL, OFF). WAL is fastest and the right choice on local disk. Set DELETE if the data directory lives on network storage (Azure App Service, an SMB/NFS volume on a NAS) — WAL coordinates writers through a shared-memory file that those filesystems do not implement reliably. The mode is stored inside the database file, so it survives a restart; changing this applies on the next boot. # TREK_DB_PRE_MIGRATE_SNAPSHOT=true # Copy the database to data/pre-migrate--