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:<port> 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 <noreply@anthropic.com>
This commit is contained in:
@@ -114,31 +114,27 @@ jobs:
|
|||||||
api-integration:
|
api-integration:
|
||||||
name: API Integration Tests
|
name: API Integration Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
timeout-minutes: 15
|
||||||
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
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Start MinIO
|
- name: Start services
|
||||||
run: |
|
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 \
|
docker run -d --name ci-minio \
|
||||||
--network container:$(hostname) \
|
--network container:$(hostname) \
|
||||||
-e MINIO_ROOT_USER=minioadmin \
|
-e MINIO_ROOT_USER=minioadmin \
|
||||||
-e MINIO_ROOT_PASSWORD=minioadmin \
|
-e MINIO_ROOT_PASSWORD=minioadmin \
|
||||||
quay.io/minio/minio server /data
|
quay.io/minio/minio server /data
|
||||||
|
|
||||||
- name: Create MinIO bucket
|
- name: Wait for services and create bucket
|
||||||
run: |
|
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
|
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc
|
||||||
chmod +x /tmp/mc
|
chmod +x /tmp/mc
|
||||||
until /tmp/mc alias set local http://localhost:9000 minioadmin minioadmin; do sleep 2; done
|
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
|
run: uv run pytest tests/integration/ -q
|
||||||
working-directory: api
|
working-directory: api
|
||||||
env:
|
env:
|
||||||
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@postgres/reactbin_test
|
DATABASE_URL: postgresql+asyncpg://reactbin:reactbin@localhost/reactbin_test
|
||||||
S3_ENDPOINT_URL: http://localhost:9000
|
S3_ENDPOINT_URL: http://localhost:9000
|
||||||
S3_BUCKET_NAME: reactbin-test
|
S3_BUCKET_NAME: reactbin-test
|
||||||
S3_ACCESS_KEY_ID: minioadmin
|
S3_ACCESS_KEY_ID: minioadmin
|
||||||
@@ -176,9 +172,9 @@ jobs:
|
|||||||
OWNER_USERNAME: testowner
|
OWNER_USERNAME: testowner
|
||||||
OWNER_PASSWORD: testpass
|
OWNER_PASSWORD: testpass
|
||||||
|
|
||||||
- name: Stop MinIO
|
- name: Stop services
|
||||||
if: always()
|
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) ────────────────────────────────
|
# ── Image builds (tag-only, gated on all jobs) ────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user