From e13a81e31ee1c3e89c7c4a121bdb1a23fb110174 Mon Sep 17 00:00:00 2001 From: agatha Date: Sun, 10 May 2026 23:00:46 +0000 Subject: [PATCH] CI: Run both Postgres and MinIO with --network container:$(hostname) The Gitea runner executes jobs inside a container. Port-mapped services bind to the host VM's interface, not to the runner container's loopback, so localhost: is always unreachable regardless of services: config. --network container:$(hostname) joins each service to the job container's network namespace, making both accessible on localhost. Both DB URL and S3 endpoint use localhost accordingly. Also adds timeout-minutes: 15 to bound runaway jobs on cancel. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/pipeline.yml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 3e2f0a1..929c0d3 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -114,31 +114,27 @@ jobs: api-integration: name: API Integration Tests runs-on: ubuntu-latest - services: - postgres: - image: postgres:16 - env: - POSTGRES_USER: reactbin - POSTGRES_PASSWORD: reactbin - POSTGRES_DB: reactbin_test - options: >- - --health-cmd pg_isready - --health-interval 5s - --health-timeout 5s - --health-retries 10 + timeout-minutes: 15 steps: - uses: actions/checkout@v4 - - name: Start MinIO + - name: Start services run: | + docker run -d --name ci-postgres \ + --network container:$(hostname) \ + -e POSTGRES_USER=reactbin \ + -e POSTGRES_PASSWORD=reactbin \ + -e POSTGRES_DB=reactbin_test \ + postgres:16 docker run -d --name ci-minio \ --network container:$(hostname) \ -e MINIO_ROOT_USER=minioadmin \ -e MINIO_ROOT_PASSWORD=minioadmin \ quay.io/minio/minio server /data - - name: Create MinIO bucket + - name: Wait for services and create bucket run: | + until docker exec ci-postgres pg_isready -U reactbin; do sleep 2; done curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc chmod +x /tmp/mc until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done @@ -164,8 +160,8 @@ jobs: run: uv run pytest tests/integration/ -q working-directory: api env: - TEST_DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres/reactbin_test - DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@postgres/reactbin_test + TEST_DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@localhost/reactbin_test + DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@localhost/reactbin_test S3_ENDPOINT_URL: http://localhost:9000 S3_BUCKET_NAME: reactbin-test S3_ACCESS_KEY_ID: minioadmin @@ -176,9 +172,9 @@ jobs: OWNER_USERNAME: testowner OWNER_PASSWORD: testpass - - name: Stop MinIO + - name: Stop services if: always() - run: docker stop ci-minio || true && docker rm ci-minio || true + run: docker stop ci-postgres ci-minio || true && docker rm ci-postgres ci-minio || true # ── Image builds (tag-only, gated on all jobs) ────────────────────────────────