forked from mosbth/irc2phpbb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
195 lines (139 loc) · 4.53 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/make -f
# ----------------------------------------------------------------------------
#
# Generic stuff
#
# Detect OS
OS = $(shell uname -s)
# Defaults
ECHO = echo
# Make adjustments based on OS
# http://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux/27776822#27776822
ifneq (, $(findstring CYGWIN, $(OS)))
ECHO = /bin/echo -e
endif
# Colors and helptext
NO_COLOR = \033[0m
ACTION = \033[32;01m
OK_COLOR = \033[32;01m
ERROR_COLOR = \033[31;01m
WARN_COLOR = \033[33;01m
# Which makefile am I in?
WHERE-AM-I = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
THIS_MAKEFILE := $(call WHERE-AM-I)
# Echo some nice helptext based on the target comment
HELPTEXT = $(ECHO) "$(ACTION)--->" `egrep "^\# target: $(1) " $(THIS_MAKEFILE) | sed "s/\# target: $(1)[ ]*-[ ]* / /g"` "$(NO_COLOR)"
# Add local bin path for test tools
#PATH := "./.bin:./vendor/bin:./node_modules/.bin:$(PATH)"
#SHELL := env PATH=$(PATH) $(SHELL)
PHPUNIT := .bin/phpunit
PHPLOC := .bin/phploc
PHPCS := .bin/phpcs
PHPCBF := .bin/phpcbf
PHPMD := .bin/phpmd
PHPDOC := .bin/phpdoc
BEHAT := .bin/behat
# target: help - Displays help.
.PHONY: help
help:
@$(call HELPTEXT,$@)
@$(ECHO) "Usage:"
@$(ECHO) " make [target] ..."
@$(ECHO) "target:"
@egrep "^# target:" $(THIS_MAKEFILE) | sed 's/# target: / /g'
# ----------------------------------------------------------------------------
#
# Specifics
#
LOGFILES = aggregate.error aggregate.log aggregate.ignore
PYFILES = *.py
JSONFILES = *.json
# target: clean - Removes generated files and directories.
.PHONY: clean
clean:
@$(call HELPTEXT,$@)
rm -f $(LOGFILES)
rm -rf build
find -type d -name __pycache__ -exec rm -rf {} \;
find -type f -name '*.pyc' -exec rm -f {} \;
# target: prepare - Prepare for tests and build
.PHONY: prepare
prepare:
@$(call HELPTEXT,$@)
install -d build
# target: test - Run all tests.
.PHONY: test
#test: prepare jsonlint pylint pycodestyle flake8 unittest doctest coverage
test: prepare jsonlint pylint # pycodestyle flake8 unittest doctest coverage
@$(call HELPTEXT,$@)
# target: pylint - Run pylint validation.
.PHONY: pylint
pylint:
@$(call HELPTEXT,$@)
@install -d build/pylint
-pylint --reports=no *.py
-@pylint *.py > build/pylint/output.txt
# target: pycodestyle - Run pycodestyle validation.
.PHONY: pycodestyle
pycodestyle:
@$(call HELPTEXT,$@)
@install -d build/pycodestyle
-pycodestyle --exclude=orig --count --statistics . | tee build/pycodestyle/log.txt
# target: flake8 - Run flake8 validation.
.PHONY: flake8
flake8:
@$(call HELPTEXT,$@)
@install -d build/flake8
-flake8 --exclude=orig --count --statistics . | tee build/flake8/log.txt
# target: unittest - Run all unittests.
.PHONY: unittest
unittest:
@$(call HELPTEXT,$@)
python3 -m unittest discover -b -s tests
# target: doctest - Run all doctests.
.PHONY: doctest
doctest:
@$(call HELPTEXT,$@)
python3 -m doctest *.py
# target: coverage - Run code coverage of all unittests.
.PHONY: coverage
coverage:
@$(call HELPTEXT,$@)
@install -d build/coverage-html
$(ENV) && coverage run --source=. -m unittest discover -b -s tests
$(ENV) && coverage html --directory=build/coverage-html
$(ENV) && coverage report -m
# target: install-tools - Install needed devtools.
.PHONY: install-tools
install-tools:
@$(call HELPTEXT,$@)
python3 -m pip install --requirement .requirements.txt
# target: upgrade-tools - Upgrade needed devtools.
.PHONY: upgrade-tools
upgrade-tools:
@$(call HELPTEXT,$@)
python3 -m pip install --upgrade --requirement .requirements.txt
# target: check - Check versions of installed devtools.
.PHONY: check
check:
@$(call HELPTEXT,$@)
@$(ECHO) "$(INFO_COLOR)python:$(NO_COLOR)" && which python3 && python3 --version
@$(ECHO) "\n$(INFO_COLOR)pip:$(NO_COLOR)" && python3 -m pip --version
@$(ECHO) "\n$(INFO_COLOR)pylint:$(NO_COLOR)" && which pylint && pylint --version
@$(ECHO) "\n$(INFO_COLOR)coverage:$(NO_COLOR)" && which coverage && coverage --version
@$(ECHO) "\n$(INFO_COLOR)flake8:$(NO_COLOR)" && which flake8 && flake8 --version
@$(ECHO) "\n$(INFO_COLOR)pycodestyle:$(NO_COLOR)" && which pycodestyle && pycodestyle --version
#
#
# target: jsonlint - Validate all JSON files.
.PHONY: jsonlint
jsonlint: $(JSONFILES)
@$(call HELPTEXT,$@)
$(JSONFILES):
jsonlint --quiet $@ 2>&1 | tee build/jsonlint-$@
#
#
#
.PHONY: pylint
pylint:
pylint --rcfile=.pylintrc $(PYFILES) | tee build/pylint