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:
Maurice
2026-11-17 11:47:40 +01:00
parent 3b6d7238fe
commit e4b990b75e
6 changed files with 133 additions and 70 deletions
+23
View File
@@ -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) => {