3 Commits

Author SHA1 Message Date
f0076ff1f4 [NX-501 Issue] Replace GitHub Actions postgres service with Docker container.
Some checks failed
Container CVE Scan (development) / Scan backend/frontend images for CVEs (push) Successful in 2m41s
E2E API Smoke / Core API E2E Smoke (push) Failing after 2m8s
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 8s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 8s
Python Dependency Security / pip-audit (block high/critical) (push) Successful in 26s
The PostgreSQL service in the GitHub Actions workflow was replaced by a Docker container for better control and flexibility. Additional steps were added to manage the container lifecycle, including starting, logging, and cleaning up. Also, updated the app version from 0.2.4 to 0.2.5.
2026-02-15 20:14:12 +01:00
8d47c0c378 [NX-501 Issue] Add wait for PostgreSQL in e2e API smoke workflow
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
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
7f7cf9179f Remove Trivy scans from container CVE scan workflow
Trivy-based scanning steps and their summaries have been removed from the GitHub Actions workflow. This change focuses on streamlining the workflow by reducing redundancy and relying on alternate scanning methods.
2026-02-15 20:04:20 +01:00
3 changed files with 48 additions and 62 deletions

View File

@@ -55,50 +55,6 @@ jobs:
provenance: false provenance: false
sbom: false sbom: false
- name: Trivy scan (backend)
uses: aquasecurity/trivy-action@0.24.0
with:
image-ref: nexapg-backend:dev-scan
format: json
output: trivy-backend.json
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
ignore-unfixed: false
exit-code: 0
- name: Trivy scan (frontend)
uses: aquasecurity/trivy-action@0.24.0
with:
image-ref: nexapg-frontend:dev-scan
format: json
output: trivy-frontend.json
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
ignore-unfixed: false
exit-code: 0
- name: Summarize Trivy severities
run: |
python - <<'PY'
import json
from collections import Counter
def summarize(path):
c = Counter()
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
for result in data.get("Results", []):
for v in result.get("Vulnerabilities", []) or []:
c[v.get("Severity", "UNKNOWN")] += 1
for sev in ["CRITICAL", "HIGH", "MEDIUM", "LOW", "UNKNOWN"]:
c.setdefault(sev, 0)
return c
for label, path in [("backend", "trivy-backend.json"), ("frontend", "trivy-frontend.json")]:
s = summarize(path)
print(f"===== Trivy {label} =====")
print(f"CRITICAL={s['CRITICAL']} HIGH={s['HIGH']} MEDIUM={s['MEDIUM']} LOW={s['LOW']} UNKNOWN={s['UNKNOWN']}")
print()
PY
- name: Docker Scout scan (backend) - name: Docker Scout scan (backend)
continue-on-error: true continue-on-error: true
run: | run: |
@@ -152,7 +108,5 @@ jobs:
with: with:
name: container-cve-scan-reports name: container-cve-scan-reports
path: | path: |
trivy-backend.json
trivy-frontend.json
scout-backend.txt scout-backend.txt
scout-frontend.txt scout-frontend.txt

View File

@@ -17,21 +17,6 @@ jobs:
name: Core API E2E Smoke name: Core API E2E Smoke
runs-on: ubuntu-latest 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: env:
APP_NAME: NexaPG Monitor APP_NAME: NexaPG Monitor
ENVIRONMENT: test ENVIRONMENT: test
@@ -62,12 +47,55 @@ jobs:
with: with:
python-version: "3.13" python-version: "3.13"
- name: Start PostgreSQL container
run: |
docker rm -f nexapg-e2e-pg >/dev/null 2>&1 || true
docker run -d \
--name nexapg-e2e-pg \
-e POSTGRES_DB=nexapg \
-e POSTGRES_USER=nexapg \
-e POSTGRES_PASSWORD=nexapg \
-p 5432:5432 \
postgres:16
- name: Install backend dependencies + test tooling - name: Install backend dependencies + test tooling
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install -r backend/requirements.txt pip install -r backend/requirements.txt
pip install pytest 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: Show PostgreSQL container status
if: ${{ always() }}
run: |
docker ps -a --filter "name=nexapg-e2e-pg"
docker logs --tail=80 nexapg-e2e-pg || true
- name: Run Alembic migrations - name: Run Alembic migrations
working-directory: backend working-directory: backend
run: alembic upgrade head run: alembic upgrade head
@@ -76,3 +104,7 @@ jobs:
env: env:
PYTHONPATH: backend PYTHONPATH: backend
run: pytest -q backend/tests/e2e/test_api_smoke.py run: pytest -q backend/tests/e2e/test_api_smoke.py
- name: Cleanup PostgreSQL container
if: ${{ always() }}
run: docker rm -f nexapg-e2e-pg >/dev/null 2>&1 || true

View File

@@ -2,7 +2,7 @@ from functools import lru_cache
from pydantic import field_validator from pydantic import field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings import BaseSettings, SettingsConfigDict
NEXAPG_VERSION = "0.2.4" NEXAPG_VERSION = "0.2.5"
class Settings(BaseSettings): class Settings(BaseSettings):