|
| 1 | +.PHONY: static |
| 2 | + |
| 3 | +docker_compose_path = "docker-compose.yml" |
| 4 | + |
| 5 | +DC = docker-compose -f $(docker_compose_path) |
| 6 | +DC_RUN = $(DC) run --rm |
| 7 | +DC_RUN_MNG = $(DC_RUN) django python manage.py |
| 8 | + |
| 9 | +################################################################################################### |
| 10 | +## Build/run/stop/etc. ############################################################################ |
| 11 | + |
| 12 | +createsuperuser: |
| 13 | + $(DC_RUN_MNG) createsuperuser |
| 14 | + |
| 15 | +static: |
| 16 | + $(DC_RUN_MNG) collectstatic --no-input |
| 17 | + |
| 18 | +build: |
| 19 | + $(DC) build --no-cache |
| 20 | + make static |
| 21 | + |
| 22 | +up: |
| 23 | + $(DC) up -d --build |
| 24 | + |
| 25 | +down: |
| 26 | + $(DC) down |
| 27 | + |
| 28 | +restart: |
| 29 | + $(DC) restart |
| 30 | + |
| 31 | +################################################################################################### |
| 32 | +## Databases ###################################################################################### |
| 33 | + |
| 34 | +migrations: # produce migrations from code |
| 35 | + $(DC_RUN_MNG) makemigrations |
| 36 | + |
| 37 | +migrate: # apply db migrations |
| 38 | + $(DC_RUN_MNG) migrate |
| 39 | + |
| 40 | +################################################################################################### |
| 41 | +## Testing ######################################################################################## |
| 42 | + |
| 43 | +# Run tests locally. All pytest args can be specified using `pytest-args`: |
| 44 | +# $ make tests pytest-args='-k test_name' # Run specific test. |
| 45 | +# $ make tests pytest-args='--ff -x' # Run all tests. Stop if any fail. Rerun last failed if any. |
| 46 | + |
| 47 | +test: |
| 48 | + @echo 'Running tests with arguments: '$(pytest-args) |
| 49 | + $(DC_RUN) django poetry run pytest --ds=settings.test -v $(pytest-args) . |
| 50 | + |
| 51 | +test-coverage: |
| 52 | + @echo 'Running test coverage with arguments: '$(pytest-args) |
| 53 | + $(DC_RUN) django pytest --ds=settings.test --cov=. --cov-report=term-missing --cov-config=../pyproject.toml -c ../pyproject.toml . |
| 54 | + |
| 55 | +################################################################################################### |
| 56 | +## Code tools ##################################################################################### |
| 57 | + |
| 58 | +install-pre-commit: |
| 59 | + poetry run pre-commit install |
| 60 | + |
| 61 | +check: |
| 62 | + poetry run black --check backend |
| 63 | + poetry run isort --check backend |
| 64 | + |
| 65 | +format: |
| 66 | + poetry run black . |
| 67 | + poetry run isort . |
| 68 | + |
| 69 | +lint: |
| 70 | + poetry run black --check backend |
| 71 | + poetry run isort --check backend |
| 72 | + poetry run flake8 --inline-quotes '"' |
| 73 | + @# For some reason, mypy and pylint fails to resolve PYTHONPATH, set manually. |
| 74 | + PYTHONPATH=./app poetry run pylint app |
| 75 | + PYTHONPATH=./app poetry run mypy --namespace-packages --show-error-codes app --check-untyped-defs --ignore-missing-imports --show-traceback |
| 76 | + |
| 77 | +safety: |
| 78 | + poetry run safety check --policy-file=.safety-policy.yml |
0 commit comments