diff --git a/.github/workflows/e2e-api-smoke.yml b/.github/workflows/e2e-api-smoke.yml index e8be1f0..7186a16 100644 --- a/.github/workflows/e2e-api-smoke.yml +++ b/.github/workflows/e2e-api-smoke.yml @@ -68,6 +68,32 @@ jobs: pip install -r backend/requirements.txt pip install pytest + - name: Wait for PostgreSQL service + run: | + python - <<'PY' + import asyncio + import asyncpg + + async def wait_for_db(): + dsn = "postgresql://nexapg:nexapg@127.0.0.1:5432/nexapg?sslmode=disable" + last_err = None + for attempt in range(1, 61): + try: + conn = await asyncpg.connect(dsn=dsn, timeout=3) + try: + await conn.execute("SELECT 1") + finally: + await conn.close() + print(f"PostgreSQL ready after {attempt} attempt(s).") + return + except Exception as exc: + last_err = exc + await asyncio.sleep(2) + raise RuntimeError(f"PostgreSQL not ready after retries: {last_err}") + + asyncio.run(wait_for_db()) + PY + - name: Run Alembic migrations working-directory: backend run: alembic upgrade head