Files
NexaPG/.github/workflows/e2e-api-smoke.yml
nessi 8d47c0c378
Some checks failed
Container CVE Scan (development) / Scan backend/frontend images for CVEs (push) Successful in 2m20s
E2E API Smoke / Core API E2E Smoke (push) Failing after 2m8s
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 8s
[NX-501 Issue] Add wait for PostgreSQL in e2e API smoke workflow
This change introduces a step in the e2e API smoke workflow to wait for PostgreSQL readiness before executing further steps. It retries the connection multiple times to ensure the database is available, reducing potential errors caused by service unavailability.
2026-02-15 20:07:35 +01:00

105 lines
2.9 KiB
YAML

name: E2E API Smoke
on:
push:
branches: ["main", "master", "development"]
paths:
- "backend/**"
- ".github/workflows/e2e-api-smoke.yml"
pull_request:
paths:
- "backend/**"
- ".github/workflows/e2e-api-smoke.yml"
workflow_dispatch:
jobs:
e2e-smoke:
name: Core API E2E Smoke
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: nexapg
POSTGRES_USER: nexapg
POSTGRES_PASSWORD: nexapg
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U nexapg -d nexapg"
--health-interval 5s
--health-timeout 5s
--health-retries 20
env:
APP_NAME: NexaPG Monitor
ENVIRONMENT: test
LOG_LEVEL: INFO
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_NAME: nexapg
DB_USER: nexapg
DB_PASSWORD: nexapg
JWT_SECRET_KEY: smoke_jwt_secret_for_ci_only
JWT_ALGORITHM: HS256
JWT_ACCESS_TOKEN_MINUTES: 15
JWT_REFRESH_TOKEN_MINUTES: 10080
ENCRYPTION_KEY: 5fLf8HSTbEUeo1c4DnWnvkXxU6v8XJ8iW58wNw5vJ8s=
CORS_ORIGINS: http://localhost:5173
POLL_INTERVAL_SECONDS: 30
INIT_ADMIN_EMAIL: admin@example.com
INIT_ADMIN_PASSWORD: ChangeMe123!
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install backend dependencies + test tooling
run: |
python -m pip install --upgrade pip
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
- name: Run core API smoke suite
env:
PYTHONPATH: backend
run: pytest -q backend/tests/e2e/test_api_smoke.py