-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (119 loc) · 3.63 KB
/
Copy pathMakefile
File metadata and controls
146 lines (119 loc) · 3.63 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# author: @cseshahriar
.PHONY: help test lint format format-check coverage check all \
migrations migrate start superuser install update \
clear-pycache collectstatic makemessages compilemessages \
clean test-watch shell
DJANGO=python manage.py
PYTHON=python
help:
@echo "Available commands:"
@echo ""
@echo "🐍 Development:"
@echo " make start - Start development server"
@echo " make shell - Open Django shell"
@echo " make migrations- Create new migrations"
@echo " make migrate - Apply migrations"
@echo " make superuser - Create superuser"
@echo ""
@echo "🧪 Testing:"
@echo " make test - Run all tests"
@echo " make test-watch- Run tests on file change"
@echo " make coverage - Run tests with coverage"
@echo ""
@echo "📏 Code Quality:"
@echo " make lint - Run flake8 linting"
@echo " make format - Format code with black/isort"
@echo " make format-check - Check formatting without changes"
@echo " make check - Run all checks (format + lint + test)"
@echo " make all - Run everything"
@echo ""
@echo "🛠️ Maintenance:"
@echo " make install - Install dependencies"
@echo " make update - Update dependencies"
@echo " make clean - Remove cache files"
@echo " make clear-pycache - Remove __pycache__ directories"
@echo ""
@echo "🌐 Deployment:"
@echo " make collectstatic - Collect static files"
@echo " make makemessages - Create translation files"
@echo " make compilemessages - Compile translation files"
# 🧪 Testing
test:
$(DJANGO) test users --verbosity=2
test-all:
$(DJANGO) test --verbosity=2
test-watch:
find . -name "*.py" | entr -c $(DJANGO) test users --verbosity=2
test-coverage:
coverage run --source='.' $(DJANGO) test users
coverage report
coverage html
# 📏 Code Quality
lint:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
@echo "---"
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
format:
black .
isort .
format-check:
black . --check
isort . --check-only
coverage:
coverage erase
coverage run --source='.' $(DJANGO) test users
coverage report
coverage html -d htmlcov
# ✅ Combined checks
check: format-check lint test
all: format lint coverage
# 🐍 Development
migrations:
$(DJANGO) makemigrations
migrate:
$(DJANGO) migrate
start:
$(DJANGO) runserver 0.0.0.0:8000
superuser:
$(DJANGO) createsuperuser
shell:
$(DJANGO) shell_plus --ipython
# 📦 Dependencies
install:
pip install -r requirements/base.txt
update:
pip install --upgrade -r requirements/base.txt
# 🧹 Cleanup
clean:
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
find . -type f -name '*~' -delete
find . -type f -name '*.swp' -delete
find . -type d -name '.pytest_cache' -exec rm -rf {} +
find . -type d -name '.coverage' -delete
find . -type d -name 'htmlcov' -exec rm -rf {} +
find . -type d -name '*.egg-info' -exec rm -rf {} +
find . -type d -name '.mypy_cache' -exec rm -rf {} +
clear-pycache:
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
# 🌐 Deployment
collectstatic:
$(DJANGO) collectstatic --noinput
makemessages:
$(DJANGO) makemessages -l en
compilemessages:
$(DJANGO) compilemessages
# 🔧 Database
resetdb:
@echo "⚠️ This will delete your database! Are you sure? [y/N]" && read ans && [ $${ans:-N} = y ]
rm -f db.sqlite3
$(DJANGO) migrate
$(DJANGO) createsuperuser
# 📊 Requirements
requirements:
pip freeze > requirements.txt
requirements-dev:
pip freeze > requirements/dev.txt