Skip to content

Test CMS

Test CMS #53

Workflow file for this run

name: Test CMS
on:
push:
paths: &paths
- "cms/**"
- ".github/workflows/test-cms.yml"
# The datastore mirror drift check depends on the backend schema:
- "backend/app/models.py"
- "backend/app/alembic/**"
# Also on PRs, so the suite runs against the MERGE RESULT rather than only
# the branch tip.
pull_request:
paths: *paths
jobs:
container-job:
runs-on: ubuntu-latest
container: python:3.12.6
services:
postgres:
image: postgis/postgis:16-3.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DJANGO_SETTINGS_MODULE: config.settings.dev
DJANGO_SECRET_KEY: test-only-secret-key
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_SERVER: postgres
POSTGRES_PORT: 5432
steps:
- name: Checkout repo code
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt --no-cache-dir
working-directory: cms
- name: Django system checks
run: python manage.py check
working-directory: cms
- name: Bootstrap schema and migrate
run: |
python manage.py bootstrap_schema
python manage.py migrate --noinput
working-directory: cms
- name: Check for missing migrations
run: python manage.py makemigrations --check --dry-run
working-directory: cms
- name: Run tests
run: python manage.py test
working-directory: cms
# Drift guard: datastore mirrors the Alembic-owned `public` tables with
# managed=False models. Run the backend's migrations against the same
# database, then verify the mirrors still match the live schema.
- name: Install backend dependencies (for Alembic)
run: |
pip install -r requirements.txt --no-cache-dir
working-directory: backend
- name: Run backend (Alembic) migrations
run: alembic upgrade head
working-directory: backend
env:
DOMAIN: postgres
ENVIRONMENT: test
PROJECT_NAME: Districtr v2 backend
BACKEND_CORS_ORIGINS: "http://localhost,http://localhost:5173"
SECRET_KEY: mysupersecretkey
DATABASE_URL: postgresql+psycopg://postgres:postgres@postgres:5432/postgres
POSTGRES_SCHEME: postgresql+psycopg
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_SERVER: postgres
POSTGRES_PORT: 5432
AUTH_JWKS_URL: http://localhost:8001/.well-known/jwks.json
AUTH_AUDIENCE: http://localhost:8000/
AUTH_ISSUER: http://localhost:8001
AUTH_ALGORITHMS: RS256
- name: Check mirror drift
run: python manage.py check_mirror_drift
working-directory: cms