diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 5a973bf..f26ac07 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -80,14 +80,24 @@ jobs: # act_runner (swarm-runner) puts service containers on the default bridge # with no embedded DNS, so the hostname `postgres` won't resolve — we # discover the service container's bridge IP via the docker socket. The - # job name `integration` (no underscore) is the docker-ps name filter. + # job container and its Postgres share a task-number name prefix. run: | set -euxo pipefail echo "=== container landscape (diagnostic for filter scoping) ===" docker ps -a --format '{{.ID}} {{.Image}} -> {{.Names}}' echo "=== end landscape ===" - PG=$(docker ps --filter "name=integration" --filter "ancestor=postgres:16-alpine" -q | head -n1) - test -n "$PG" + # The runner's daemon is shared: another repo's integration job can be + # running beside this one, and `name=integration` matches its Postgres + # too (run 8358 took the wrong one and every test failed to connect). + # Scope to this job's own task: act_runner names every container of a + # task GITEA-ACTIONS-TASK--…, so read from our own container + # (its id is in the /etc/hostname bind mount) and require one match. + SELF=$(grep -o '/containers/[0-9a-f]\{64\}/' /proc/self/mountinfo | head -n1 | cut -d/ -f3 || true) + SELF=${SELF:-$(hostname)} + TASK=$(docker inspect -f '{{.Name}}' "$SELF" | grep -o 'GITEA-ACTIONS-TASK-[0-9]*-') + test -n "$TASK" + PG=$(docker ps --filter "name=$TASK" --filter "ancestor=postgres:16-alpine" -q) + test "$(printf '%s\n' "$PG" | grep -c .)" -eq 1 PG_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$PG") test -n "$PG_IP" export STEWARD_DATABASE_URL="postgresql+asyncpg://steward:steward@$PG_IP:5432/steward"