From bec3e2f6a917f3e7135cbabcb818c8a91e2ffcae Mon Sep 17 00:00:00 2001 From: damascus-heartbeat Date: Wed, 24 Jun 2026 01:04:54 +0000 Subject: [PATCH] ci(test): reach the postgres service via service name, not 127.0.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that BB1's port 5432 is freed, CI gets past the port-bind step and actually attempts to run the tests. The next failure is: psycopg.OperationalError: connection to server at "127.0.0.1", port 5432 failed: Connection refused The job tried 127.0.0.1:5432 but the postgres service container had just been brought up and wasn't accepting connections yet. The '5432:5432' port mapping for self-hosted act_runner is racy — the host-side bind sometimes lags the service ready signal, and the job's 'Apply schema' step runs before pg_isready returns 0. Fix: - Use the service name 'postgres' as DAMASCUS_PG_HOST. In act_runner's service network, the service name is the DNS hostname, no port mapping required. - Drop the now-unused 'ports: 5432:5432' binding. This is the same fix the cron branch fix/compose-db-volume-self-heal should land in (PR #7). It's small enough to be a follow-up to this PR; if the test workflow on BB1's runner doesn't resolve 'postgres', we can revisit. Co-Authored-By: Claude --- .gitea/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index a754009..968acaf 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -17,8 +17,6 @@ jobs: POSTGRES_USER: damascus POSTGRES_PASSWORD: damascus POSTGRES_DB: damascus - ports: - - "5432:5432" options: >- --health-cmd "pg_isready -U damascus -d damascus" --health-interval 5s @@ -28,7 +26,12 @@ jobs: env: DAMASCUS_ROOT: ${{ github.workspace }} DAMASCUS_SCHEMA_PATH: ${{ github.workspace }}/schema.sql - DAMASCUS_PG_HOST: 127.0.0.1 + # The postgres service is reachable by its service name on the runner + # network. We tried 127.0.0.1 + a host port binding first; the binding + # is racy on self-hosted act_runner (the port map sometimes takes + # effect after the job tries to connect, causing "Connection refused"). + # Service-name DNS is reliable. + DAMASCUS_PG_HOST: postgres DAMASCUS_PG_PORT: "5432" DAMASCUS_PG_USER: damascus DAMASCUS_PG_PASSWORD: damascus