|
| 1 | +.PHONY: help install lint lint-fix format test test-unit test-integration test-cov security ci migrate createsuperuser runserver shell clean |
| 2 | + |
| 3 | +# Default target |
| 4 | +help: |
| 5 | + @echo "Available commands:" |
| 6 | + @echo " make install - Install dependencies with poetry" |
| 7 | + @echo " make lint - Run ruff linter and formatter check" |
| 8 | + @echo " make lint-fix - Auto-fix linting and formatting issues" |
| 9 | + @echo " make format - Format code with ruff" |
| 10 | + @echo " make test - Run all tests" |
| 11 | + @echo " make test-unit - Run unit tests only" |
| 12 | + @echo " make test-integration - Run integration tests only" |
| 13 | + @echo " make test-cov - Run tests with coverage report" |
| 14 | + @echo " make security - Run bandit security scanner" |
| 15 | + @echo " make ci - Run all CI checks (lint, test-cov, security)" |
| 16 | + @echo " make migrate - Run Django migrations" |
| 17 | + @echo " make createsuperuser - Create Django superuser" |
| 18 | + @echo " make runserver - Run Django development server" |
| 19 | + @echo " make shell - Open Django shell" |
| 20 | + @echo " make clean - Remove Python cache files and test artifacts" |
| 21 | + |
| 22 | +# Install dependencies |
| 23 | +install: |
| 24 | + poetry install |
| 25 | + |
| 26 | +# Linting and formatting |
| 27 | +lint: |
| 28 | + poetry run ruff check . |
| 29 | + poetry run ruff format --check . |
| 30 | + |
| 31 | +lint-fix: |
| 32 | + poetry run ruff check --fix . |
| 33 | + poetry run ruff format . |
| 34 | + |
| 35 | +format: |
| 36 | + poetry run ruff format . |
| 37 | + |
| 38 | +# Testing |
| 39 | +test: |
| 40 | + cd src && poetry run pytest |
| 41 | + |
| 42 | +test-unit: |
| 43 | + cd src && poetry run pytest tests/unit/ |
| 44 | + |
| 45 | +test-integration: |
| 46 | + cd src && poetry run pytest tests/integration/ |
| 47 | + |
| 48 | +test-cov: |
| 49 | + cd src && DJANGO_ENV=testing ENVIRONMENT=TEST SECRET_KEY=test-secret-key poetry run pytest --cov=. --cov-report=xml --cov-report=term-missing -v |
| 50 | + |
| 51 | +# Security |
| 52 | +security: |
| 53 | + poetry run bandit -r src --skip B101 -f txt |
| 54 | + |
| 55 | +# CI - runs all checks that CI will run |
| 56 | +ci: lint test-cov security |
| 57 | + @echo "" |
| 58 | + @echo "✓ All CI checks passed!" |
| 59 | + |
| 60 | +# Django commands |
| 61 | +migrate: |
| 62 | + poetry run python src/manage.py migrate |
| 63 | + |
| 64 | +createsuperuser: |
| 65 | + poetry run python src/manage.py createsuperuser |
| 66 | + |
| 67 | +runserver: |
| 68 | + poetry run python src/manage.py runserver |
| 69 | + |
| 70 | +shell: |
| 71 | + poetry run python src/manage.py shell |
| 72 | + |
| 73 | +# Cleanup |
| 74 | +clean: |
| 75 | + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true |
| 76 | + find . -type f -name "*.pyc" -delete |
| 77 | + find . -type f -name "*.pyo" -delete |
| 78 | + find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true |
| 79 | + find . -type f -name ".coverage" -delete |
| 80 | + find . -type f -name "coverage.xml" -delete |
| 81 | + rm -rf .ruff_cache htmlcov |
| 82 | + @echo "✓ Cleaned up Python cache files and test artifacts" |
0 commit comments