-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (60 loc) · 1.87 KB
/
Makefile
File metadata and controls
83 lines (60 loc) · 1.87 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
VENV := venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
REQUIREMENTS_FILE := requirements.txt
PROJECT_NAME := mastermind
ROOT_FOLDER := src
TESTS_FOLDER := tests
UML_FOLDER := docs/diagrams/c4
DB_FILE := src/infra/database/mastermind.db
all: run
.PHONY: all
.env:
echo 'ERROR: No environment variable configured'
exit 1
$(VENV)/bin/activate:
python3.13 -m venv $(VENV)
$(PIP) install --upgrade pip
install: $(VENV)/bin/activate
$(PIP) install -r ${REQUIREMENTS_FILE}
requirements:
$(PIP) freeze > ${REQUIREMENTS_FILE}
run: install .env
@if [ -f "${DB_FILE}" ]; then \
rm ${DB_FILE}; \
fi
$(PYTHON) main.py
tests: install
pytest ${TESTS_FOLDER}
coverage: install
pytest --cov=${ROOT_FOLDER} --cov-report=term-missing --cov-fail-under=10 ${TESTS_FOLDER}
.PHONY: install requirements run tests coverage
UML_FILE_EXTENSION := dot
UML_IMAGE_EXTENSION := png
UML_FILE_NAME_TO_CONVERT := classes
UML_GENERATED_FILE_NAME := code
UML_FILE_TO_CONVERT := ${UML_FILE_NAME_TO_CONVERT}.${UML_IMAGE_EXTENSION}
uml: install
pyreverse -o ${UML_FILE_EXTENSION} -p ${PROJECT_NAME} ${ROOT_FOLDER}/.
dot -Tpng ${UML_FILE_NAME_TO_CONVERT}_${PROJECT_NAME}.${UML_FILE_EXTENSION} -o ${UML_FILE_TO_CONVERT}
mv ${UML_FILE_TO_CONVERT} ${UML_FOLDER}/${UML_GENERATED_FILE_NAME}.${UML_IMAGE_EXTENSION}
rm *.${UML_FILE_EXTENSION}
.PHONY: uml
tree:
tree -dL 6 --gitignore -I 'docs|__pycache__'
check_init_files:
@missing=$$(find src -type d ! -path "*/__pycache__*" ! -exec test -e "{}/__init__.py" \; -print); \
if [ -n "$$missing" ]; then \
echo "❌ ERROR: The following directories are missing an __init__.py file:"; \
echo "$$missing"; \
exit 1; \
else \
echo "✅ All good! Every directory contains an __init__.py file."; \
fi
clean:
rm -rf $(VENV)
rm *.${UML_FILE_EXTENSION}
rm *.${UML_IMAGE_EXTENSION}
rm .env
find . -name "__pycache__" -exec rm -rf {} +
.PHONY: clean