forked from EduCraft/curriculum-project-hub
fix(ci): reach hub-check Postgres by service DNS
Concurrent hub-check jobs on the shared runner fought over published host ports (5432 then 15432). Drop host port mapping and connect to the service container as postgres:5432 on the job network.
This commit is contained in:
@@ -20,9 +20,9 @@ jobs:
|
|||||||
POSTGRES_USER: paradigm
|
POSTGRES_USER: paradigm
|
||||||
POSTGRES_PASSWORD: paradigm
|
POSTGRES_PASSWORD: paradigm
|
||||||
POSTGRES_DB: cph_hub_test
|
POSTGRES_DB: cph_hub_test
|
||||||
ports:
|
# Avoid host-port binds: concurrent hub-check jobs on the same runner
|
||||||
# Host 15432 avoids collisions with any runner-local Postgres on 5432.
|
# raced on 5432/15432 ("port is already allocated"). Reach the service
|
||||||
- 15432:5432
|
# by Docker DNS name from the job container instead.
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "pg_isready -U paradigm -d cph_hub_test"
|
--health-cmd "pg_isready -U paradigm -d cph_hub_test"
|
||||||
--health-interval 5s
|
--health-interval 5s
|
||||||
@@ -49,15 +49,15 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Linux sandbox dependency
|
- name: Install Linux sandbox dependency
|
||||||
run: sudo apt-get update && sudo apt-get install --yes bubblewrap socat
|
run: sudo apt-get update && sudo apt-get install --yes bubblewrap socat
|
||||||
|
|
||||||
- name: Wait for Postgres
|
- name: Wait for Postgres
|
||||||
run: |
|
run: |
|
||||||
node <<'NODE'
|
node <<'NODE'
|
||||||
const net = require("node:net");
|
const net = require("node:net");
|
||||||
const deadline = Date.now() + 60000;
|
const deadline = Date.now() + 60000;
|
||||||
const port = Number(process.env.HUB_CHECK_PG_PORT || "15432");
|
const host = process.env.HUB_CHECK_PG_HOST || "postgres";
|
||||||
|
const port = Number(process.env.HUB_CHECK_PG_PORT || "5432");
|
||||||
function tryConnect() {
|
function tryConnect() {
|
||||||
const socket = net.createConnection({ host: "127.0.0.1", port });
|
const socket = net.createConnection({ host, port });
|
||||||
socket.once("connect", () => {
|
socket.once("connect", () => {
|
||||||
socket.end();
|
socket.end();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
socket.once("error", () => {
|
socket.once("error", () => {
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
if (Date.now() > deadline) {
|
if (Date.now() > deadline) {
|
||||||
console.error(`Postgres did not become reachable at 127.0.0.1:${port}`);
|
console.error(`Postgres did not become reachable at ${host}:${port}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
setTimeout(tryConnect, 1000);
|
setTimeout(tryConnect, 1000);
|
||||||
@@ -110,7 +110,7 @@ jobs:
|
|||||||
npx prisma migrate deploy --schema prisma/schema.prisma
|
npx prisma migrate deploy --schema prisma/schema.prisma
|
||||||
npx vitest run test/integration \
|
npx vitest run test/integration \
|
||||||
--exclude test/integration/real-model.test.ts \
|
--exclude test/integration/real-model.test.ts \
|
||||||
--exclude test/integration/agent-sandbox-linux.test.ts
|
DATABASE_URL: postgresql://paradigm:paradigm@postgres:5432/cph_hub_test
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: postgresql://paradigm:paradigm@127.0.0.1:15432/cph_hub_test
|
DATABASE_URL: postgresql://paradigm:paradigm@127.0.0.1:15432/cph_hub_test
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user