-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
148 lines (121 loc) · 4.57 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
#!/usr/bin/env make -f
# Python Repo Template
# ..................................
# Copyright (c) 2017-2024, Kendrick Walls
# ..................................
# Licensed under MIT (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# ..........................................
# http://www.github.com/reactive-firewall/python-repo/LICENSE.md
# ..........................................
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ifeq "$(ECHO)" ""
ECHO=echo
endif
ifeq "$(LINK)" ""
LINK=ln -sf
endif
ifeq "$(MAKE)" ""
MAKE=make
endif
ifeq "$(WAIT)" ""
WAIT=wait
endif
ifeq "$(INSTALL)" ""
INSTALL=install
ifeq "$(INST_OWN)" ""
INST_OWN=-o root -g staff
endif
ifeq "$(INST_OPTS)" ""
INST_OPTS=-m 755
endif
endif
ifeq "$(LOG)" ""
LOG=no
endif
ifeq "$(LOG)" "no"
QUIET=@
endif
ifeq "$(DO_FAIL)" ""
DO_FAIL=$(ECHO) "ok"
endif
PHONY: must_be_root cleanup
build:
$(QUIET)$(ECHO) "No need to build. Try make -f Makefile install"
$(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>/dev/null || true
init:
$(QUIET)$(ECHO) "$@: Done."
install: must_be_root
$(QUIET)python3 -m pip install "git+https://github.com/reactive-firewall/python-repo.git#egg=pythonrepo"
$(QUITE)$(WAIT)
$(QUIET)$(ECHO) "$@: Done."
user-install:
$(QUIET)python3 -m pip install --user "git+https://github.com/reactive-firewall/python-repo.git#egg=pythonrepo"
$(QUITE)$(WAIT)
$(QUIET)$(ECHO) "$@: Done."
uninstall:
$(QUITE)python3 -m pip uninstall pythonrepo || true
$(QUITE)$(WAIT)
$(QUIET)$(ECHO) "$@: Done."
test-reports:
$(QUIET)mkdir test-reports 2>/dev/null >/dev/null || true ;
$(QUIET)$(ECHO) "$@: Done."
purge: clean uninstall
$(QUIET)python3 -m pip uninstall pythonrepo && python -m pip uninstall pythonrepo || true
$(QUIET)$(ECHO) "$@: Done."
test: cleanup
$(QUIET)coverage run -p --source=pythonrepo -m unittest discover --verbose -s ./tests -t ./ || python3 -m unittest discover --verbose -s ./tests -t ./ || python -m unittest discover --verbose -s ./tests -t ./ || DO_FAIL=exit 2 ;
$(QUIET)coverage combine 2>/dev/null || true
$(QUIET)coverage report -m --include=pythonrepo* 2>/dev/null || true
$(QUIET)$(DO_FAIL);
$(QUIET)$(ECHO) "$@: Done."
test-tox: cleanup
$(QUIET)tox -v -- || tail -n 500 .tox/py*/log/py*.log 2>/dev/null
$(QUIET)$(ECHO) "$@: Done."
test-pytest: cleanup test-reports
$(QUIET)python3 -m pytest --junitxml=test-reports/junit.xml -v tests || python -m pytest --junitxml=test-reports/junit.xml -v tests
$(QUIET)$(ECHO) "$@: Done."
test-style: cleanup
$(QUIET)python3 -m flake8 --ignore=W191,W391 --max-line-length=100 --verbose --count --config=.flake8.ini --show-source || DO_FAIL="exit 2" ;
$(QUIET)tests/check_spelling 2>/dev/null || true
$(QUIET)$(ECHO) "$@: Done."
cleanup:
$(QUIET)rm -f tests/*.pyc 2>/dev/null || true
$(QUIET)rm -f tests/*~ 2>/dev/null || true
$(QUIET)rm -Rf tests/__pycache__ 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*.pyc 2>/dev/null || true
$(QUIET)rm -Rf pythonrepo/__pycache__ 2>/dev/null || true
$(QUIET)rm -Rf pythonrepo/*/__pycache__ 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*~ 2>/dev/null || true
$(QUIET)rm -f *.pyc 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*/*.pyc 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*/*~ 2>/dev/null || true
$(QUIET)rm -f *.DS_Store 2>/dev/null || true
$(QUIET)rm -Rf .pytest_cache/ 2>/dev/null || true
$(QUIET)rmdir ./test-reports/ 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*.DS_Store 2>/dev/null || true
$(QUIET)rm -f pythonrepo/*/*.DS_Store 2>/dev/null || true
$(QUIET)rm -f pythonrepo.egg-info/* 2>/dev/null || true
$(QUIET)rmdir pythonrepo.egg-info 2>/dev/null || true
$(QUIET)rm -f ./*/*~ 2>/dev/null || true
$(QUIET)rm -f ./*~ 2>/dev/null || true
$(QUIET)coverage erase 2>/dev/null || true
$(QUIET)rm -f ./.coverage 2>/dev/null || true
$(QUIET)rm -f ./coverage*.xml 2>/dev/null || true
$(QUIET)rm -f ./sitecustomize.py 2>/dev/null || true
$(QUIET)rm -f ./.*~ 2>/dev/null || true
$(QUIET)rm -Rf ./.tox/ 2>/dev/null || true
clean: cleanup
$(QUIET)rm -f test-results/junit.xml 2>/dev/null || true
$(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean || true
$(QUIET)$(ECHO) "$@: Done."
must_be_root:
$(QUIET)runner=`whoami` ; \
if test $$runner != "root" ; then echo "You are not root." ; exit 1 ; fi
%:
$(QUIET)$(ECHO) "No Rule Found For $@" ; $(WAIT) ;