All checks were successful
CI Deploy Checks / Build Container (push) Successful in 8s
CI Quality / Ruff Lint (push) Successful in 8s
CI Security / Bandit + pip-audit (push) Successful in 21s
CI Tests / Django Tests (push) Successful in 38s
CI Tests / OpenAPI Schema (push) Successful in 10s
84 lines
2.9 KiB
YAML
84 lines
2.9 KiB
YAML
name: CI Tests
|
|
|
|
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: sqlite:////tmp/training_test.sqlite3
|
|
REDIS_URL: redis://localhost:6379/0
|
|
|
|
jobs:
|
|
test:
|
|
name: Tests (Python ${{ matrix.python-version }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.12"]
|
|
|
|
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: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 python manage.py makemigrations --check --dry-run
|
|
|
|
- name: Run migrations
|
|
run: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 python manage.py migrate
|
|
|
|
- name: Run smoke + settings tests
|
|
run: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 pytest --ds=config.settings.test -m "smoke or settings" -v --tb=short
|
|
|
|
- name: Run full test suite
|
|
run: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 pytest --ds=config.settings.test --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
|
|
|
|
schema:
|
|
name: OpenAPI Schema
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
|
|
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: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 python manage.py migrate
|
|
|
|
- name: Generate OpenAPI schema
|
|
run: DJANGO_SETTINGS_MODULE=config.settings.test DATABASE_URL=sqlite:////tmp/training_test.sqlite3 REDIS_URL=redis://localhost:6379/0 python manage.py spectacular --settings=config.settings.test --file openapi.yaml --validate
|
|
|
|
- name: Upload schema artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: openapi-schema
|
|
path: openapi.yaml
|