From 1539e41fcec0efe6e120e9eee3aec82f14690b70 Mon Sep 17 00:00:00 2001 From: IGNGserver <176017966+IGNGserver@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:16:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20compose=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=BC=94=E7=BB=83=E7=AD=89=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=8F=AF=E8=BF=9E=E6=8E=A5=E5=86=8D=E6=89=A7=E8=A1=8C=20pg=5Fr?= =?UTF-8?q?estore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pg_isready 在 entrypoint 的临时实例阶段就会返回成功,此时 POSTGRES_DB 还没 创建,pg_restore 会因 database does not exist 失败。改为用 psql 探测目标库。 --- scripts/compose-smoke.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/compose-smoke.ts b/scripts/compose-smoke.ts index 32309c1..4d8d8e3 100644 --- a/scripts/compose-smoke.ts +++ b/scripts/compose-smoke.ts @@ -282,12 +282,29 @@ async function main(): Promise { `${backupDir}:/backup:ro`, 'postgres:18.6-alpine3.24@sha256:d3e1620b530c944afa6e887d22eb899824da68e19c52024bf98f5220c88a65b2', ]); + // `pg_isready` reports success as soon as the entrypoint's temporary server + // accepts connections, which happens before POSTGRES_DB exists. Probing the + // database itself is the only check that distinguishes "initialising" from + // "ready to restore". let restored = false; for (let attempt = 0; attempt < 60; attempt += 1) { if ( spawnSync( 'docker', - ['exec', restoreContainer, 'pg_isready', '-U', 'devtodo', '-d', 'devtodo'], + [ + 'exec', + restoreContainer, + 'psql', + '--no-psqlrc', + '--quiet', + '--tuples-only', + '-U', + 'devtodo', + '-d', + 'devtodo', + '-c', + 'select 1', + ], { stdio: 'ignore', timeout: 5_000 }, ).status === 0 ) {