ci: support dynamic Postgres ports in Gitea Actions
This commit is contained in:
1 parent
add64ff180
commit
a15827fe76
1 file changed
+11
-4
@@ -65,15 +65,15 @@ jobs:
|
|||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_DB: scratch
|
POSTGRES_DB: scratch
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432/tcp
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "pg_isready -U postgres"
|
--health-cmd "pg_isready -U postgres"
|
||||||
--health-interval 5s
|
--health-interval 5s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 10
|
--health-retries 10
|
||||||
env:
|
env:
|
||||||
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:5432/scratch?sslmode=disable
|
SHARED_TEST_DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/scratch?sslmode=disable
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -84,7 +84,14 @@ jobs:
|
|||||||
cache: true
|
cache: true
|
||||||
# -p 1 runs one package at a time, because the database tests share one scratch database.
|
# -p 1 runs one package at a time, because the database tests share one scratch database.
|
||||||
- name: Run Go tests
|
- 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:
|
python:
|
||||||
name: Test (Python)
|
name: Test (Python)
|
||||||
|
|||||||
Reference in new issue
Block a user