fix(ci): fix postgres TCP setup and truncateAll superuser error
Check Deno code / Check Deno code (push) Failing after 5s
Tests / Unit tests (push) Successful in 11s
Tests / Integration tests (push) Successful in 55s

- Use apt-get install + configure listen_addresses + md5 auth in pg_hba
  so psql can connect via 127.0.0.1 (not just Unix socket)
- Use pg_ctlcluster restart after config changes + wait for pg_isready
- Replace session_replication_role (requires superuser) with a single
  TRUNCATE ... CASCADE which handles FK deps without elevated privileges
- All 3 integration tests now pass in CI (act + Gitea Actions)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #136.
This commit is contained in:
2026-04-26 13:22:45 +02:00
committed by djalim
parent a95818e3bf
commit daa7f4951f
3 changed files with 74 additions and 34 deletions
+6 -23
View File
@@ -18,29 +18,15 @@ function createTestPool(): pg.Pool {
user: Deno.env.get("POSTGRES_USER") ?? "test",
password: Deno.env.get("POSTGRES_PASS") ?? "test",
database: Deno.env.get("POSTGRES_DB") ?? "polympr_test",
ssl: false,
});
}
export const testPool = createTestPool();
export const testDb = drizzle(testPool, { schema });
// Ordre de truncate respectant les FK (enfants avant parents)
const TRUNCATE_ORDER = [
"mobility",
"ajustements",
"notes",
"ue_modules",
"enseignements",
"role_permissions",
"students",
"ue_modules",
"users",
"modules",
"ues",
"promotions",
"permissions",
"roles",
] as const;
const ALL_TABLES =
'"mobility","ajustements","notes","ue_modules","enseignements","role_permissions","students","users","modules","ues","promotions","permissions","roles"';
/**
* Vide toutes les tables dans le bon ordre.
@@ -49,12 +35,9 @@ const TRUNCATE_ORDER = [
export async function truncateAll(): Promise<void> {
const client = await testPool.connect();
try {
// Désactiver les FK temporairement pour simplifier
await client.query("SET session_replication_role = replica");
for (const table of TRUNCATE_ORDER) {
await client.query(`TRUNCATE TABLE "${table}" RESTART IDENTITY CASCADE`);
}
await client.query("SET session_replication_role = DEFAULT");
await client.query(
`TRUNCATE TABLE ${ALL_TABLES} RESTART IDENTITY CASCADE`,
);
} finally {
client.release();
}