fix(ci): wait for final PostgreSQL process

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-07-31 00:46:27 +08:00
parent 4fe1563e5f
commit 7b3f1144f7

View file

@ -46,17 +46,25 @@ docker run -d \
postgres:16-alpine >/dev/null
log "waiting for PostgreSQL readiness"
postgres_ready="false"
for _ in $(seq 1 60); do
if docker exec "${POSTGRES_CONTAINER}" \
pid_one_comm="$(
docker exec "${POSTGRES_CONTAINER}" \
cat /proc/1/comm 2>/dev/null || true
)"
if [[ "${pid_one_comm}" == "postgres" ]] \
&& docker exec "${POSTGRES_CONTAINER}" \
pg_isready -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" \
>/dev/null 2>&1; then
postgres_ready="true"
break
fi
sleep 1
done
docker exec "${POSTGRES_CONTAINER}" \
pg_isready -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" \
>/dev/null
if [[ "${postgres_ready}" != "true" ]]; then
log "PostgreSQL did not become ready after entrypoint initialization"
exit 1
fi
log "PostgreSQL is ready"
run_test() {