This project uses Continuous Integration and Continuous Deployment workflows to automate testing, linting, building, and deployment processes.
The project uses pre-commit to ensure code quality before changes are committed. These hooks run automatically on every commit and push.
# Install pre-commit hooks (one-time setup)
uv run pre-commit install
uv run pre-commit install --hook-type pre-push
# Verify installation
uv run pre-commit --version- Trailing Whitespace: Removes trailing spaces
- End of Files: Ensures files end with a newline
- File Size: Prevents large files (>1MB) from being committed
- Merge Conflicts: Detects unresolved merge conflict markers
- Black: Python code formatter (88 char line length)
- isort: Sorts and organizes imports
- Flake8: Python linter with Django-specific plugins
- Bandit: Security vulnerability scanner
- Django Upgrade: Updates code to latest Django patterns
- pyupgrade: Upgrades Python syntax to 3.12+
- Django Check: Runs Django's system check framework
- Migration Check: Ensures no missing migrations
- Critical Tests: Runs core test suite to prevent broken pushes
# Run all hooks manually
uv run pre-commit run --all-files
# Run specific hook
uv run pre-commit run black --all-files
uv run pre-commit run flake8 --all-files
# Update hook versions to latest
uv run pre-commit autoupdate
# Skip hooks temporarily (use sparingly!)
git commit -m "Emergency fix" --no-verify
git push --no-verify
# Uninstall hooks
uv run pre-commit uninstallThe pre-commit configuration is in .pre-commit-config.yaml. Key settings:
# Exclude patterns for all hooks
exclude: migrations|\.venv|staticfiles|node_modules
# Fail fast setting (stop on first failure)
fail_fast: false
# Default stages (when hooks run)
default_stages: [pre-commit, pre-push]Hook failures blocking commit:
# See detailed error output
uv run pre-commit run --verbose
# Fix formatting issues automatically
uv run black .
uv run isort .
# Then try committing again
git add -A && git commitHooks running slowly:
# Skip expensive hooks during development
SKIP=flake8,bandit git commit -m "WIP"
# Or temporarily disable specific hooks in .pre-commit-config.yamlHooks not running:
# Reinstall hooks
uv run pre-commit uninstall
uv run pre-commit installThe project includes several GitHub Actions workflows that mirror and extend the pre-commit checks:
- Trigger: Runs on pushes and pull requests to the
mainbranch - Jobs:
- Spins up a PostgreSQL database service
- Runs core tests with pytest to validate basic functionality
- Trigger: Runs on pushes and pull requests to the
mainbranch - Jobs:
- Format Check: Validates Black and isort formatting
- Lint: Runs flake8 with Django plugins
- Type Check: Runs mypy for type checking
- Note: Must pass same checks as local pre-commit hooks
- Trigger: Runs on pushes and pull requests to the
mainbranch - Jobs:
- Bandit: Scans for security vulnerabilities
- Safety: Checks dependencies for known CVEs
- Note: More comprehensive than local pre-commit security checks
- Trigger: Runs on pushes and pull requests to the
mainbranch when files in theapps/ordocs/directories change - Jobs:
- Builds Sphinx documentation
- Deploys documentation to GitHub Pages (only from the
mainbranch)
- GitHub Pages (for documentation):
- In your repository settings, enable GitHub Pages
- Select the source as "GitHub Actions"
-
Team Setup:
# Add to your onboarding documentation git clone <repo> cd <repo> uv sync --all-extras uv run pre-commit install
-
CI/CD Alignment:
- GitHub Actions use the same tools as pre-commit
- Failures in pre-commit will also fail in CI
- Fix issues locally before pushing
To test CI workflows locally before pushing changes:
-
Run Pre-commit Hooks:
# Simulates what happens on commit uv run pre-commit run --all-files -
Run Full Test Suite:
# Simulates GitHub Actions test workflow DJANGO_SETTINGS_MODULE=settings uv run pytest -
Check Security:
# Simulates security workflow uv run bandit -r apps/ settings/ safety check -
Build Documentation:
# Simulates docs workflow cd docs/sphinx_docs make html
The CI/CD setup supports multiple deployment environments:
- Staging: Automatically deployed from the
mainbranch after all checks pass - Production: Deployed from git tags after manual approval
- Always install pre-commit hooks after cloning the repository
- Fix issues locally before pushing to save CI minutes
- Don't skip hooks unless absolutely necessary
- Keep hooks updated with
uv run pre-commit autoupdate - Match CI and local checks to avoid surprises
Developer → Pre-commit Hooks → Git Commit → Push → GitHub Actions → Deploy
↓ (if fails) ↓ (if fails)
Fix locally Fix and push again