mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +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:
@@ -44,6 +44,24 @@ describe('classify', () => {
|
||||
assert.deepEqual(classify(['server/src/nest/weather/weather.service.ts']), { code: true, image: true, deploy: false });
|
||||
});
|
||||
|
||||
it('runs the Postgres probe and lane for every file they read', () => {
|
||||
// server-postgres is gated on `code`; a migration, a repository, the
|
||||
// engine, the baseline or the lane's own config must never skip it.
|
||||
for (const file of [
|
||||
'server/src/db/migrations/Migration20200101046440_x.ts',
|
||||
'server/src/db/repositories/Trips.repository.ts',
|
||||
'server/src/db/dialect/sql-functions.ts',
|
||||
'server/src/db/engine/postgres/schema-bootstrap.ts',
|
||||
'server/assets/postgres/baseline.sql',
|
||||
'server/scripts/pg-probe-baseline.json',
|
||||
'server/vitest.pg.config.ts',
|
||||
'server/tests/postgres/lane.ts',
|
||||
'server/tests/postgres/snapshot-suites-baseline.json',
|
||||
]) {
|
||||
assert.equal(classify([file]).code, true, file);
|
||||
}
|
||||
});
|
||||
|
||||
it('runs the tests but not the image for a plugin-sdk change', () => {
|
||||
assert.deepEqual(classify(['plugin-sdk/src/index.ts']), { code: true, image: false, deploy: false });
|
||||
});
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, it } from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// ci-ok is the one required check, and a job counts for a merge only once it
|
||||
// is in ci-ok's needs. A new or renamed job that is left out runs, can fail,
|
||||
// and merges anyway. The scan is the one job kept out on purpose (see the
|
||||
// layout notes at the top of test.yml).
|
||||
const workflow = readFileSync(fileURLToPath(new URL('../../.github/workflows/test.yml', import.meta.url)), 'utf8');
|
||||
const NOT_REQUIRED = new Set(['ci-ok', 'scan']);
|
||||
|
||||
function jobIds() {
|
||||
const body = workflow.slice(workflow.indexOf('\njobs:\n'));
|
||||
return [...body.matchAll(/^ {2}([a-z0-9-]+):\s*$/gm)].map((match) => match[1]);
|
||||
}
|
||||
|
||||
function ciOkNeeds() {
|
||||
const block = /^ {2}ci-ok:\n {4}needs:\n((?: {6}- [a-z0-9-]+\n)+)/m.exec(workflow);
|
||||
assert.ok(block, 'test.yml must declare ci-ok with a needs: list, one job per line');
|
||||
return block[1]
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map((line) => line.replace(/^\s*- /, ''));
|
||||
}
|
||||
|
||||
describe('test.yml', () => {
|
||||
it('lists every job but the scan in ci-ok needs', () => {
|
||||
const needs = new Set(ciOkNeeds());
|
||||
const missing = jobIds().filter((id) => !NOT_REQUIRED.has(id) && !needs.has(id));
|
||||
assert.deepEqual(missing, [], `add these jobs to ci-ok's needs: in test.yml: ${missing.join(', ')}`);
|
||||
});
|
||||
|
||||
it('names only jobs that exist in ci-ok needs', () => {
|
||||
const ids = new Set(jobIds());
|
||||
const unknown = ciOkNeeds().filter((id) => !ids.has(id));
|
||||
assert.deepEqual(unknown, [], `ci-ok needs jobs test.yml does not define: ${unknown.join(', ')}`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user