ci: support dynamic Postgres ports in Gitea Actions

This commit is contained in:
Gabriel20xx committed 2026-10-21 09:45:39 +00:00
1 parent add64ff180
commit a15827fe76
1 file changed
+11 -4
+11 -4
View File
@@ -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)