fix: CI run postgres in-container instead of service container
This commit is contained in:
parent
bba8d113e4
commit
5ce17943d5
1 changed files with 9 additions and 22 deletions
|
|
@ -11,43 +11,30 @@ jobs:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: python:3.13-slim
|
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:
|
env:
|
||||||
CI: "true"
|
CI: "true"
|
||||||
WG_DATABASE_URL: postgresql+asyncpg://wiregui:wiregui@postgres/wiregui
|
WG_DATABASE_URL: postgresql+asyncpg://wiregui:wiregui@localhost/wiregui
|
||||||
steps:
|
steps:
|
||||||
- name: Install system dependencies and checkout
|
- name: Install system dependencies and checkout
|
||||||
run: |
|
run: |
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
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 clone --depth=1 ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
git checkout ${GITHUB_SHA}
|
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
|
- name: Install uv
|
||||||
run: pip install uv
|
run: pip install uv
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: uv sync
|
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
|
- name: Run tests
|
||||||
run: uv run pytest -v --tb=short
|
run: uv run pytest -v --tb=short
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue