-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
158 lines (118 loc) · 3.19 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
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
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env make
# Change this to be your variant of the python command
# Set the env variable PYTHON to another value if needed
# PYTHON=python3 make version
PYTHON ?= python # python3 py
# Print out colored action message
MESSAGE = printf "\033[32;01m---> $(1)\033[0m\n"
all:
# ---------------------------------------------------------
# Check the current python executable.
#
version:
@printf "Currently using executable: $(PYTHON)\n"
which $(PYTHON)
$(PYTHON) --version
# ---------------------------------------------------------
# Setup a venv and install packages.
#
venv:
[ -d .venv ] || $(PYTHON) -m venv .venv
@printf "Now activate the Python virtual environment.\n"
@printf "On Unix and Mac, do:\n"
@printf ". .venv/bin/activate\n"
@printf "On Windows (bash terminal), do:\n"
@printf ". .venv/Scripts/activate\n"
@printf "Type 'deactivate' to deactivate.\n"
install:
$(PYTHON) -m pip install -r requirements.txt
installed:
$(PYTHON) -m pip list
# ---------------------------------------------------------
# Cleanup generated and installed files.
#
clean:
@$(call MESSAGE,$@)
rm -f .coverage *.pyc
rm -rf __pycache__
rm -rf htmlcov
clean-doc: clean
@$(call MESSAGE,$@)
rm -rf doc
clean-all: clean clean-doc
@$(call MESSAGE,$@)
rm -rf .venv
# ---------------------------------------------------------
# Work with static code linters.
#
pylint:
@$(call MESSAGE,$@)
-cd game_classes && $(PYTHON) -m pylint *.py
flake8:
@$(call MESSAGE,$@)
-flake8
lint: flake8 pylint
# ---------------------------------------------------------
# Work with codestyle.
#
black:
@$(call MESSAGE,$@)
$(PYTHON) -m black guess/ test/
codestyle: black
# ---------------------------------------------------------
# Work with unit test and code coverage.
#
unittest:
@$(call MESSAGE,$@)
$(PYTHON) -m unittest discover
coverage:
@$(call MESSAGE,$@)
coverage run --omit='*/test*' -m unittest discover
coverage html
coverage report -m
test: lint coverage
# ---------------------------------------------------------
# Work with generating documentation.
#
.PHONY: pydoc
pydoc:
@$(call MESSAGE,$@)
install -d doc/pydoc
$(PYTHON) -m pydoc -w game_classes/*.py
mv *.html doc/pydoc
pdoc:
@$(call MESSAGE,$@)
pdoc --force --html --output-dir doc/pdoc game_classes/*/*.py
pyreverse:
@$(call MESSAGE,$@)
install -d doc/pyreverse
pyreverse -o png --ignore '*test*.py' game_classes
dot -Tpng classes.dot -o doc/pyreverse/game_classes.png
dot -Tpng packages.dot -o doc/pyreverse/packages.png
rm -f game_classes.dot packages.dot
doc: pdoc pyreverse #pydoc sphinx
# ---------------------------------------------------------
# Calculate software metrics for your project.
#
radon-cc:
@$(call MESSAGE,$@)
radon cc --show-complexity --average game_classes
radon-mi:
@$(call MESSAGE,$@)
radon mi --show game_classes
radon-raw:
@$(call MESSAGE,$@)
radon raw game_classes
radon-hal:
@$(call MESSAGE,$@)
radon hal game_classes
cohesion:
@$(call MESSAGE,$@)
cohesion game_classes/**/*.py
metrics: radon-cc radon-mi radon-raw radon-hal cohesion
# ---------------------------------------------------------
# Find security issues in your project.
#
bandit:
@$(call MESSAGE,$@)
bandit --recursive game_classes