@@ -5,13 +5,42 @@ VERSION=$(shell cat VERSION)
5
5
REQUIRED_VENV: =python_secrets
6
6
VENV_DIR =$(HOME ) /.virtualenvs/$(REQUIRED_VENV )
7
7
PROJECT: =$(shell basename `pwd`)
8
+ PYTHON =python3
8
9
9
10
.PHONY : default
10
11
default : all
11
12
12
13
.PHONY : all
13
14
all : install-active
14
15
16
+ .PHONY : help
17
+ help :
18
+ @echo ' usage: make [VARIABLE=value] [target [target..]]'
19
+ @echo ' '
20
+ @echo ' test - generic target for both "test-tox" and "test-bats"'
21
+ @echo ' test-tox - run tox tests'
22
+ @echo ' test-bats - run Bats unit tests'
23
+ @echo ' test-bats-runtime - run Bats runtime integration/system tests'
24
+ @echo ' release - produce a pypi production release'
25
+ @echo ' release-test - produce a pypi test release'
26
+ @echo ' release-prep - final documentation preparations for release'
27
+ @echo ' sdist - run "$(PYTHON) setup.py sdist"'
28
+ @echo ' bdist_wheel - build a universal binary wheel'
29
+ @echo ' twine-check - run "twine check"'
30
+ @echo ' clean - remove build artifacts'
31
+ @echo ' spotless - deep clean'
32
+ @echo ' build-packet-cafe - Build and bring up packet_cafe containers'
33
+ @echo ' up-packet-cafe - Bring up packet_cafe containers'
34
+ @echo ' down-packet-cafe - Bring up packet_cafe containers'
35
+ @echo ' clean-packet-cafe - remove packet_cafe contents'
36
+ @echo ' spotless-packet-cafe - Remove all packet_cafe files and containers'
37
+ @echo ' install - install pip package'
38
+ @echo ' install-active - run "$(PYTHON) -m pip install -U ."'
39
+ @echo ' docs-tests - generate bats test output for documentation'
40
+ @echo ' docs-help - generate "lim help" output for documentation'
41
+ @echo ' docs - build Sphinx docs'
42
+
43
+
15
44
# HELP test - run 'tox' for testing
16
45
.PHONY : test
17
46
test : test-tox
@@ -21,25 +50,25 @@ test: test-tox
21
50
test-tox :
22
51
@if [ -f .python_secrets_environment ]; then (echo ' [!] Remove .python_secrets_environment prior to testing' ; exit 1); fi
23
52
touch docs/psec_help.txt
24
- tox
53
+ @# See comment in tox.ini file.
54
+ tox -e pep8,bandit,docs && tox -e py36,py37,py38,bats,pypi
55
+ @-git checkout ChangeLog
25
56
26
57
.PHONY : test-bats
27
58
test-bats : bats-libraries
28
59
@if [ " $( TRAVIS) " != " true" ]; then \
29
60
if ! type bats 2> /dev/null > /dev/null; then \
30
61
echo " [-] Skipping bats tests" ; \
31
62
else \
32
- echo " [+] Running bats unit tests:" ; \
33
- (cd tests && ls -1 [0-9][0-9]* .bats); \
34
- bats --tap tests/[0-9][0-9]* .bats; \
63
+ echo " [+] Running bats tests: $( shell cd tests && echo [0-9][0-9]* .bats) " ; \
64
+ PYTHONWARNINGS=" ignore" bats --tap tests/[0-9][0-9]* .bats; \
35
65
fi \
36
66
fi
37
67
38
68
.PHONY : test-bats-runtime
39
69
test-bats-runtime : bats-libraries
40
- @echo " [+] Running bats runtime tests:"
41
- @cd tests && ls -1 runtime_[0-9][0-9]* .bats
42
- bats --tap tests/runtime_* .bats || true
70
+ @echo " [+] Running bats runtime tests: $( shell cd tests && echo runtime_[0-9][0-9]* .bats) " ; \
71
+ PYTHONWARNINGS=" ignore" bats --tap tests/runtime_[0-9][0-9]* .bats
43
72
44
73
.PHONY : no-diffs
45
74
no-diffs :
@@ -48,39 +77,44 @@ no-diffs:
48
77
49
78
# HELP release - package and upload a release to pypi
50
79
.PHONY : release
51
- release : clean twine-check
80
+ release : clean docs sdist bdist_wheel twine-check
52
81
twine upload $(shell cat dist/.LATEST_* ) -r pypi
53
82
83
+ # HELP release-prep - final documentation preparations for release
84
+ .PHONY : release-prep
85
+ release-prep : install-active clean sdist docs-help docs-tests
86
+ @echo ' Check in help text docs and ChangeLog?'
87
+
54
88
# HELP release-test - upload to "testpypi"
55
89
.PHONY : release-test
56
90
release-test : clean test docs-tests docs twine-check
57
91
$(MAKE ) no-diffs
58
92
twine upload $(shell cat dist/.LATEST_* ) -r testpypi
59
93
94
+ # HELP sdist - build a source package
95
+ .PHONY : sdist
96
+ sdist : clean-docs docs
97
+ rm -f dist/.LATEST_SDIST
98
+ $(PYTHON ) setup.py sdist
99
+ ls -t dist/* .tar.gz 2> /dev/null | head -n 1 > dist/.LATEST_SDIST
100
+ ls -l dist/* .tar.gz
101
+
60
102
# HELP bdist_egg - build an egg package
61
103
.PHONY : bdist_egg
62
104
bdist_egg :
63
105
rm -f dist/.LATEST_EGG
64
- python setup.py bdist_egg
106
+ $( PYTHON ) setup.py bdist_egg
65
107
ls -t dist/* .egg 2> /dev/null | head -n 1 > dist/.LATEST_EGG
66
108
ls -lt dist/* .egg
67
109
68
110
# HELP bdist_wheel - build a wheel package
69
111
.PHONY : bdist_wheel
70
112
bdist_wheel :
71
113
rm -f dist/.LATEST_WHEEL
72
- python setup.py bdist_wheel
114
+ $( PYTHON ) setup.py bdist_wheel
73
115
ls -t dist/* .whl 2> /dev/null | head -n 1 > dist/.LATEST_WHEEL
74
116
ls -lt dist/* .whl
75
117
76
- # HELP sdist - build a source package
77
- .PHONY : sdist
78
- sdist : clean-docs docs
79
- rm -f dist/.LATEST_SDIST
80
- python setup.py sdist
81
- ls -t dist/* .tar.gz 2> /dev/null | head -n 1 > dist/.LATEST_SDIST
82
- ls -l dist/* .tar.gz
83
-
84
118
# HELP twine-check
85
119
.PHONY : twine-check
86
120
twine-check : sdist bdist_egg bdist_wheel
@@ -89,7 +123,7 @@ twine-check: sdist bdist_egg bdist_wheel
89
123
# HELP clean - remove build artifacts
90
124
.PHONY : clean
91
125
clean : clean-docs
92
- python setup.py clean
126
+ $( PYTHON ) setup.py clean
93
127
rm -rf dist build * .egg-info
94
128
find . -name ' *.pyc' -delete
95
129
@@ -109,23 +143,36 @@ install:
109
143
exit 1; \
110
144
else \
111
145
echo " Installing into $( REQUIRED_VENV) virtual environment" ; \
112
- $(VENV_DIR ) /bin/python -m pip uninstall -y $(PROJECT ) ; \
113
- $(VENV_DIR ) /bin/python setup.py install; \
146
+ $(VENV_DIR ) /bin/$( PYTHON ) -m pip uninstall -y $(PROJECT ) ; \
147
+ $(VENV_DIR ) /bin/$( PYTHON ) setup.py install; \
114
148
fi
115
149
116
150
# HELP install-active - install in the active Python virtual environment
151
+ .PHONY : i
117
152
.PHONY : install-active
118
- install-active :
119
- python -m pip install -U .
153
+ i install-active : bdist_wheel
154
+ $(PYTHON ) -m pip uninstall -y $(PROJECT )
155
+ $(PYTHON ) -m pip install -U " dist/$( shell cat dist/.LATEST_WHEEL) " | grep -v ' already satisfied'
156
+ git checkout ChangeLog
120
157
121
158
# HELP docs-tests - generate bats test output for documentation
122
159
.PHONY : docs-tests
123
160
PR =pr --omit-header --omit-pagination --page-width 80
124
161
docs-tests :
162
+ $(MAKE ) -B docs/test-tox.txt
163
+ $(MAKE ) -B docs/test-bats.txt
164
+ $(MAKE ) -B docs/test-bats-runtime.txt
165
+
166
+ docs/test-tox.txt :
125
167
(echo ' $$ make test-tox' && $( MAKE) test-tox) | \
126
168
$(PR ) | tee docs/test-tox.txt
169
+
170
+ docs/test-bats.txt :
127
171
$(MAKE ) test-bats | $(PR ) | tee docs/test-bats.txt
128
172
173
+ docs/test-bats-runtime.txt :
174
+ (echo ' $$ make test-bats-runtime' && $( MAKE) test-bats-runtime) | \
175
+ $(PR ) | tee docs/test-bats-runtime.txt
129
176
130
177
# HELP docs - build Sphinx docs (NOT INTEGRATED YET FROM OPENSTACK CODE BASE)
131
178
.PHONY : docs
@@ -135,6 +182,11 @@ docs: docs/psec_help.txt
135
182
docs/psec_help.txt : install-active
136
183
psec help | tee docs/psec_help.txt
137
184
185
+ # HELP examples - produce some example output for docs
186
+ .PHONY : examples
187
+ examples :
188
+ psec --help
189
+
138
190
# Git submodules and subtrees are both a huge PITA. This is way simpler.
139
191
140
192
.PHONY : bats-libraries
0 commit comments