From a15827fe76382353b3c5afb4d1062137250aa4b2 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 21 Oct 2026 09:45:39 +0000 Subject: [PATCH] ci: support dynamic Postgres ports in Gitea Actions --- .github/workflows/tests.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54decea..4f49db1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,15 +65,15 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_DB: scratch ports: - - 5432:5432 + - 5432/tcp options: >- --health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s --health-retries 10 env: - DATABASE_URL: postgres://postgres:postgres@localhost:5432/scratch?sslmode=disable - SHARED_TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/scratch?sslmode=disable + DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/scratch?sslmode=disable + SHARED_TEST_DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/scratch?sslmode=disable steps: - name: Checkout uses: actions/checkout@v4 @@ -84,7 +84,14 @@ jobs: cache: true # -p 1 runs one package at a time, because the database tests share one scratch database. - name: Run Go tests - run: go test -p 1 ./... + shell: bash + run: | + # Gitea Actions runs jobs in a container, where the service is reached by its label. + if [ "${GITEA_ACTIONS:-}" = "true" ]; then + export DATABASE_URL="postgres://postgres:postgres@postgres:5432/scratch?sslmode=disable" + export SHARED_TEST_DATABASE_URL="postgres://postgres:postgres@postgres:5432/scratch?sslmode=disable" + fi + go test -p 1 ./... python: name: Test (Python)