ci(integration): add pgvector+redis integration job; amend lint-only policy
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
# Per FabledRulebook/forgejo.md: "CI runs analyzers + short unit tests.
|
# CI policy (amends the older FabledRulebook/forgejo.md "lint + unit only"
|
||||||
# Integration tests that need real Postgres/ffmpeg run locally via
|
# stance — operator opted in to running integration in CI):
|
||||||
# docker-compose." So this workflow deliberately does NOT spin up service
|
# - backend-lint-and-test: fast feedback — ruff + `pytest -m "not
|
||||||
# containers; DB-dependent tests are marked `@pytest.mark.integration` and
|
# integration"`, no service containers.
|
||||||
# excluded with `-m "not integration"`. To run integration tests, operator
|
# - frontend-build: vitest unit + vite build.
|
||||||
# uses docker-compose locally.
|
# - integration: spins up pgvector Postgres + Redis service containers,
|
||||||
|
# migrates a throwaway test DB, runs `pytest -m integration`. This is
|
||||||
|
# the first time the integration suite runs anywhere, so expect a
|
||||||
|
# debugging tail until it goes green.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -36,7 +39,7 @@ jobs:
|
|||||||
- name: Ruff lint
|
- name: Ruff lint
|
||||||
run: ruff check backend/ tests/ alembic/
|
run: ruff check backend/ tests/ alembic/
|
||||||
|
|
||||||
- name: Pytest (unit tests only — integration tests run locally)
|
- name: Pytest (unit only — integration runs in the integration job)
|
||||||
run: pytest tests/ -v -m "not integration"
|
run: pytest tests/ -v -m "not integration"
|
||||||
|
|
||||||
frontend-build:
|
frontend-build:
|
||||||
@@ -57,3 +60,50 @@ jobs:
|
|||||||
# convert to TS or add JSDoc.
|
# convert to TS or add JSDoc.
|
||||||
- run: npm run test:unit
|
- run: npm run test:unit
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
|
integration:
|
||||||
|
# First-ever execution of the integration suite. Postgres uses the same
|
||||||
|
# pgvector image as docker-compose; Redis backs the celery smoke tests.
|
||||||
|
# Assumes the python-ci runner executes jobs in a container so services
|
||||||
|
# are reachable by name (postgres/redis). If the runner runs jobs on the
|
||||||
|
# host instead, switch DB_HOST to localhost + add `ports:` mappings.
|
||||||
|
runs-on: python-ci
|
||||||
|
env:
|
||||||
|
DB_USER: fabledcurator
|
||||||
|
DB_PASSWORD: ci_integration
|
||||||
|
DB_HOST: postgres
|
||||||
|
DB_PORT: "5432"
|
||||||
|
DB_NAME: fabledcurator_test
|
||||||
|
SECRET_KEY: ci_integration_placeholder
|
||||||
|
CELERY_BROKER_URL: redis://redis:6379/0
|
||||||
|
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: pgvector/pgvector:pg16
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: fabledcurator
|
||||||
|
POSTGRES_PASSWORD: ci_integration
|
||||||
|
POSTGRES_DB: fabledcurator_test
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U fabledcurator"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 10
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
options: >-
|
||||||
|
--health-cmd "redis-cli ping"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Python deps
|
||||||
|
run: pip install -r requirements.txt pytest pytest-asyncio
|
||||||
|
|
||||||
|
- name: Migrate the test database
|
||||||
|
run: alembic upgrade head
|
||||||
|
|
||||||
|
- name: Pytest (integration only)
|
||||||
|
run: pytest tests/ -v -m integration
|
||||||
|
|||||||
+4
-4
@@ -9,9 +9,9 @@ where = ["."]
|
|||||||
include = ["backend*"]
|
include = ["backend*"]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
# Per FabledRulebook/forgejo.md: CI runs lint + short unit tests only.
|
# The fast backend job runs `-m "not integration"`; the dedicated CI
|
||||||
# Integration tests that need a real Postgres/Redis run locally via
|
# `integration` job (pgvector Postgres + Redis service containers) runs
|
||||||
# docker-compose; CI passes `-m "not integration"` to skip them.
|
# `-m integration`. Both also runnable locally via docker-compose.
|
||||||
markers = [
|
markers = [
|
||||||
"integration: tests that require a real Postgres/Redis. Run locally via docker-compose, skipped in CI.",
|
"integration: tests that require a real Postgres/Redis. Run by the CI integration job and locally via docker-compose.",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user