-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (70 loc) · 2.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SHELL=/bin/bash
.DEFAULT_GOAL := help
PROJECT_SLUG=new-game-server
reset: ## Reset your local environment. Useful after switching branches, etc.
reset: poetry-install reset-db django-migrate django-user-passwords django-dev-createsuperuser
check: # Check for any obvious errors in the project's setup.
check: pipdeptree-check django-check
format: ## Run this project's code formatters.
format: black-format isort-format
lint: ## Lint the project.
lint: black-lint isort-lint ruff-lint
poetry-install:
poetry install --sync
run-server:
poetry run ./manage.py runserver
makemigrations:
poetry run ./manage.py makemigrations
run-tests:
poetry run ./manage.py test
test: poetry-install run-tests
# Pip
pip-install-local: venv-check
pip install -r requirements/local.txt
# Django
django-check: django-check-missing-migrations django-check-validate-templates
django-test: django-collectstatic
PYTHONWARNINGS=all coverage run --include="apps/*" --omit=*/migrations/* ./manage.py test --noinput . apps
PYTHONWARNINGS=all coverage report -m --fail-under 97
django-check-missing-migrations:
./manage.py makemigrations --check --dry-run
django-collectstatic:
./manage.py collectstatic --verbosity 0 --noinput
django-check-validate-templates:
./manage.py validate_templates --verbosity 0
django-dev-createsuperuser: DJANGO_DEV_USERNAME ?= admin@admin.co.uk
django-dev-createsuperuser: DJANGO_DEV_PASSWORD ?= password
django-dev-createsuperuser: DJANGO_DEV_EMAIL ?= admin@admin.co.uk
django-dev-createsuperuser:
@echo "import sys; from django.contrib.auth import get_user_model; obj = get_user_model().objects.create_superuser('$(DJANGO_DEV_USERNAME)', '$(DJANGO_DEV_EMAIL)', '$(DJANGO_DEV_PASSWORD)');" | python manage.py shell >> /dev/null
@echo
@echo "Superuser details: "
@echo
@echo " $(DJANGO_DEV_USERNAME):$(DJANGO_DEV_PASSWORD)"
@echo
django-user-passwords: DJANGO_USER_PASSWORD ?= password
django-user-passwords:
@echo "from django.contrib.auth.hashers import make_password; from django.contrib.auth import get_user_model; get_user_model().objects.update(password=make_password('$(DJANGO_USER_PASSWORD)'));" | python manage.py shell >> /dev/null
django-migrate:
poetry run ./manage.py migrate
# DB
reset-db: drop-db create-db
drop-db:
dropdb --if-exists gardenserver_django
create-db:
createdb gardenserver_django
# Black
black-lint:
poetry run black --check apps project
black-format:
poetry run black apps project
#pipdeptree
pipdeptree-check:
pipdeptree --warn fail > /dev/null
# ISort
isort-lint:
poetry run isort --check-only --diff apps project
isort-format:
poetry run isort apps project
ruff-lint:
poetry run ruff check .