fix: CI run postgres in-container instead of service container
Some checks failed
CI / test (push) Failing after 2m18s
CI / release (push) Has been skipped
CI / docker (push) Has been skipped

This commit is contained in:
Stefano Bertelli 2026-03-30 19:05:14 -05:00
parent bba8d113e4
commit 5ce17943d5

View file

@ -11,43 +11,30 @@ jobs:
runs-on: docker
container:
image: python:3.13-slim
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: wiregui
POSTGRES_PASSWORD: wiregui
POSTGRES_DB: wiregui
options: >-
--health-cmd "pg_isready -U wiregui"
--health-interval 5s
--health-timeout 5s
--health-retries 5
env:
CI: "true"
WG_DATABASE_URL: postgresql+asyncpg://wiregui:wiregui@postgres/wiregui
WG_DATABASE_URL: postgresql+asyncpg://wiregui:wiregui@localhost/wiregui
steps:
- name: Install system dependencies and checkout
run: |
apt-get update && apt-get install -y --no-install-recommends \
git wireguard-tools pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl
git wireguard-tools pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl \
postgresql postgresql-client
git clone --depth=1 ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
git checkout ${GITHUB_SHA}
- name: Start Postgres
run: |
pg_ctlcluster 17 main start || pg_ctlcluster 15 main start || pg_ctlcluster 16 main start
su - postgres -c "psql -c \"CREATE USER wiregui WITH PASSWORD 'wiregui' CREATEDB;\""
su - postgres -c "psql -c \"CREATE DATABASE wiregui OWNER wiregui;\""
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync
- name: Wait for Postgres
run: |
for i in $(seq 1 30); do
python -c "import socket; s=socket.create_connection(('postgres',5432),2); s.close(); print('Postgres ready')" 2>/dev/null && break
echo "Waiting for Postgres... ($i)"
sleep 2
done
- name: Run tests
run: uv run pytest -v --tb=short