mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
ci(db): run the Postgres probe and lane on Postgres 14 and 18
TREK supports Postgres 14 to 18, and CI tested 17 only. One server-postgres job per major now runs the probe and then the lane against the same service, so the change keeps the job count of the two jobs it replaces. The lane's global setup refuses a service whose major is not TREK_TEST_PG_MAJOR, and the image's Postgres boot moves to 18, the major its client tools target. scripts/ci/workflow-jobs.test.mjs fails when a job other than the scan is missing from ci-ok's needs, and changed-areas pins that migrations, repositories, the engine and the lane's files always run the job.
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
* arguments against empty tables, not every statement the code can send: a
|
||||
* branch that only runs on data the empty tables do not hold stays unseen.
|
||||
*
|
||||
* It needs a Postgres server, so CI runs it in the `postgres-probe` job
|
||||
* It needs a Postgres server, so CI runs it in the `server-postgres` job
|
||||
* against a service container. Locally:
|
||||
*
|
||||
* docker run --rm -d -p 5432:5432 -e POSTGRES_PASSWORD=probe postgres:17
|
||||
|
||||
@@ -23,6 +23,8 @@ export async function setup(): Promise<void> {
|
||||
);
|
||||
}
|
||||
|
||||
await checkServerVersion(adminUrl);
|
||||
|
||||
// Left behind by an earlier run that was killed; nothing else uses these names.
|
||||
await dropLaneDatabases(adminUrl);
|
||||
await withAdmin(adminUrl, (run) => run(`CREATE DATABASE "${TEMPLATE_DATABASE}"`));
|
||||
@@ -42,6 +44,27 @@ export async function setup(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the server's version, so a run says what it tested. CI runs the lane
|
||||
* once per supported major and sets TREK_TEST_PG_MAJOR to the one its service
|
||||
* was meant to be: a service that came up with another version (an image tag
|
||||
* that moved, a typo in the matrix) fails the run instead of passing for it.
|
||||
*/
|
||||
async function checkServerVersion(adminUrl: string): Promise<void> {
|
||||
const [row] = await withAdmin(adminUrl, (run) =>
|
||||
run<{ server_version: string; server_version_num: string }>(
|
||||
"select current_setting('server_version') as server_version, " +
|
||||
"current_setting('server_version_num') as server_version_num",
|
||||
),
|
||||
);
|
||||
const major = Math.floor(Number(row.server_version_num) / 10000);
|
||||
process.stdout.write(`[postgres lane] PostgreSQL ${row.server_version}\n`);
|
||||
const expected = process.env.TREK_TEST_PG_MAJOR;
|
||||
if (expected && Number(expected) !== major) {
|
||||
throw new Error(`TREK_TEST_PG_MAJOR is ${expected}, but the server at TREK_TEST_DB_URL runs PostgreSQL ${major}.`);
|
||||
}
|
||||
}
|
||||
|
||||
/** The template and every worker's copy: names the lane alone uses (a prefix compared as text, not a LIKE pattern). */
|
||||
async function dropLaneDatabases(adminUrl: string): Promise<void> {
|
||||
await withAdmin(adminUrl, async (run) => {
|
||||
|
||||
@@ -64,7 +64,7 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
/**
|
||||
* The Postgres branches of the dialect layer, pinned as compiled text. Nothing
|
||||
* here talks to a Postgres server: the CI `postgres-probe` job
|
||||
* here talks to a Postgres server: the CI `server-postgres` job
|
||||
* (`scripts/pg-probe.ts`) runs every one of these spellings against a real
|
||||
* one and compares the values with what SQLite returns. This file holds the
|
||||
* text, so a change to a spelling is a visible diff in review.
|
||||
|
||||
Reference in New Issue
Block a user