Files
training-software/.github/workflows/ci.yml
Paperclip CTO 8054c1e1e4 feat(TRA-233): Django M1 foundation scaffold
- Environment-split settings: base/local/test/prod with django-environ
- Postgres + Redis + Celery wiring (broker, beat, result backend)
- All 9 domain app stubs: accounts, courses, cms, tracking, quizzes,
  training, certificates, reports, notifications
- api app: /healthz/ endpoint, custom DRF exception handler,
  SecurityAuditMiddleware, permissions/throttle/upload-validation stubs
- DRF global baseline: JWT+session auth, closed-by-default permissions,
  cursor/page pagination, drf-spectacular schema generation
- Dockerfile (multi-env build arg), docker-compose.yml (local),
  docker-compose.test.yml (CI-friendly tmpfs Postgres)
- pytest.ini with smoke + settings marker definitions
- tests/test_smoke.py: startup, URL resolution, healthcheck shape
- tests/test_settings_matrix.py: per-profile security assertions
- .github/workflows/ci.yml: test, lint, schema CI jobs
- .env.example with all required vars documented
- .gitignore

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-07 09:11:23 +02:00

153 lines
3.6 KiB
YAML

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
DJANGO_SECRET_KEY: ci-secret-key-not-for-production
DJANGO_SETTINGS_MODULE: config.settings.test
DJANGO_ALLOWED_HOSTS: testserver,localhost
DATABASE_URL: postgres://training:training@localhost:5432/training_test
REDIS_URL: redis://localhost:6379/0
jobs:
test:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: training_test
POSTGRES_USER: training
POSTGRES_PASSWORD: training
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements/test.txt
- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Check migrations up to date
run: python manage.py migrate --check
- name: Run migrations
run: python manage.py migrate
- name: Run smoke + settings tests
run: pytest -m "smoke or settings" -v --tb=short
- name: Run full test suite
run: pytest --cov=. --cov-report=xml --cov-report=term-missing -v
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: coverage.xml
fail_ci_if_error: false
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install lint tools
run: pip install ruff
- name: Ruff lint check
run: ruff check .
schema:
name: OpenAPI Schema
runs-on: ubuntu-latest
needs: test
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: training_test
POSTGRES_USER: training
POSTGRES_PASSWORD: training
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements/test.txt
- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Run migrations
run: python manage.py migrate
- name: Generate OpenAPI schema
run: python manage.py spectacular --file openapi.yaml --validate
- name: Upload schema artifact
uses: actions/upload-artifact@v4
with:
name: openapi-schema
path: openapi.yaml