Merge ~vultaire/charm-kubernetes-service-checks:makefile-20.08 into charm-kubernetes-service-checks:master
- Git
- lp:~vultaire/charm-kubernetes-service-checks
- makefile-20.08
- Merge into master
Proposed by
Paul Goins
Status: | Merged |
---|---|
Merged at revision: | 321cb490400fbb814ec50f951221fb8665e7435d |
Proposed branch: | ~vultaire/charm-kubernetes-service-checks:makefile-20.08 |
Merge into: | charm-kubernetes-service-checks:master |
Diff against target: |
450 lines (+287/-53) 4 files modified
.gitignore (+25/-9) Makefile (+23/-23) copyright (+202/-0) tox.ini (+37/-21) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xav Paice (community) | Approve | ||
Review via email: mp+388614@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.gitignore b/.gitignore |
2 | index f04567f..6f1f367 100644 |
3 | --- a/.gitignore |
4 | +++ b/.gitignore |
5 | @@ -1,25 +1,41 @@ |
6 | +# Juju files |
7 | +.unit-state.db |
8 | +.go-cookies |
9 | + |
10 | +layers/* |
11 | +interfaces/* |
12 | + |
13 | # Byte-compiled / optimized / DLL files |
14 | __pycache__/ |
15 | *.py[cod] |
16 | *$py.class |
17 | |
18 | +# Tests files and dir |
19 | +.pytest_cache/ |
20 | +.coverage |
21 | +.tox |
22 | +report/ |
23 | +htmlcov/ |
24 | + |
25 | # Log files |
26 | *.log |
27 | |
28 | -.tox/ |
29 | -.coverage |
30 | +# pycharm |
31 | +.idea/ |
32 | |
33 | # vi |
34 | .*.swp |
35 | |
36 | -# pycharm |
37 | -.idea/ |
38 | - |
39 | # version data |
40 | repo-info |
41 | +version |
42 | + |
43 | +# Python builds |
44 | +deb_dist/ |
45 | +dist/ |
46 | |
47 | -# reports |
48 | -report/* |
49 | +# Snaps |
50 | +*.snap |
51 | |
52 | -# coverage |
53 | -htmlcov/* |
54 | +# Builds |
55 | +.build/ |
56 | \ No newline at end of file |
57 | diff --git a/Makefile b/Makefile |
58 | index d1435c4..c8be267 100644 |
59 | --- a/Makefile |
60 | +++ b/Makefile |
61 | @@ -1,10 +1,9 @@ |
62 | PYTHON := /usr/bin/python3 |
63 | |
64 | +PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST))) |
65 | ifndef CHARM_BUILD_DIR |
66 | - CHARM_BUILD_DIR=/tmp/charm-builds |
67 | + CHARM_BUILD_DIR=${PROJECTPATH}.build |
68 | endif |
69 | - |
70 | -PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST))) |
71 | METADATA_FILE="metadata.yaml" |
72 | CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E '^name:' | awk '{print $$2}') |
73 | |
74 | @@ -14,9 +13,11 @@ help: |
75 | @echo " make help - show this text" |
76 | @echo " make clean - remove unneeded files" |
77 | @echo " make submodules - make sure that the submodules are up-to-date" |
78 | + @echo " make submodules-update - update submodules to latest changes on remote branch" |
79 | @echo " make build - build the charm" |
80 | @echo " make release - run clean, submodules and build targets" |
81 | - @echo " make lint - run flake8 and black" |
82 | + @echo " make lint - run flake8 and black --check" |
83 | + @echo " make black - run black and reformat files" |
84 | @echo " make proof - run charm proof" |
85 | @echo " make unittests - run the tests defined in the unittest subdirectory" |
86 | @echo " make functional - run the tests defined in the functional subdirectory" |
87 | @@ -25,17 +26,7 @@ help: |
88 | |
89 | clean: |
90 | @echo "Cleaning files" |
91 | - @if [ -d .tox ] ; then rm -r .tox ; fi |
92 | - @if [ -d .pytest_cache ] ; then rm -r .pytest_cache ; fi |
93 | - @if [ -d .idea ] ; then rm -r .idea ; fi |
94 | - @if [ -d .coverage ] ; then rm -r .coverage ; fi |
95 | - @if [ -d report ] ; then rm -r report ; fi |
96 | - @find . -iname __pycache__ -exec rm -r {} + |
97 | - @find . -type f -name "*.py[cod]" -delete |
98 | - @find . -type f -name "*$py.class" -delete |
99 | - @find . -type f -name "*.log" -delete |
100 | - @find . -type f -name "*.swp" -delete |
101 | - @find . -type f -name ".unit-state.db" -delete |
102 | + @git clean -ffXd -e '!.idea' |
103 | @echo "Cleaning existing build" |
104 | @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME} |
105 | |
106 | @@ -43,25 +34,34 @@ submodules: |
107 | @echo "Cloning submodules" |
108 | @git submodule update --init --recursive |
109 | |
110 | +submodules-update: |
111 | + @echo "Pulling latest updates for submodules" |
112 | + @git submodule update --init --recursive --remote --merge |
113 | + |
114 | build: |
115 | @echo "Building charm to base directory ${CHARM_BUILD_DIR}/${CHARM_NAME}" |
116 | - @-git describe --tags > ./repo-info |
117 | + @-git rev-parse --abbrev-ref HEAD > ./repo-info |
118 | + @-git describe --always > ./version |
119 | @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME} |
120 | - @cp -r ./* ${CHARM_BUILD_DIR}/${CHARM_NAME} |
121 | - @echo "Installing/updating env from requirements.txt" |
122 | + @cp -a ./* ${CHARM_BUILD_DIR}/${CHARM_NAME} |
123 | + @echo "Installing/updating env if requirements.txt exists" |
124 | @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}/env/ |
125 | - @if [ -f requirements.txt ] ; then @pip3 install --target=${CHARM_BUILD_DIR}/${CHARM_NAME}/env -r requirements.txt --upgrade ; fi |
126 | + @if [ -f requirements.txt ] ; then pip3 install --target=${CHARM_BUILD_DIR}/${CHARM_NAME}/env -r requirements.txt --upgrade ; fi |
127 | |
128 | -release: clean submodules build |
129 | +release: clean build |
130 | @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}" |
131 | |
132 | lint: |
133 | @echo "Running lint checks" |
134 | @tox -e lint |
135 | |
136 | -proof: |
137 | +black: |
138 | + @echo "Reformat files with black" |
139 | + @tox -e black |
140 | + |
141 | +proof: build |
142 | @echo "Running charm proof" |
143 | - @-charm proof |
144 | + @-charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME} |
145 | |
146 | unittests: |
147 | @echo "Running unit tests" |
148 | @@ -75,4 +75,4 @@ test: lint proof unittests functional |
149 | @echo "Tests completed for charm ${CHARM_NAME}." |
150 | |
151 | # The targets below don't depend on a file |
152 | -.PHONY: help submodules clean build release lint proof unittests functional test |
153 | \ No newline at end of file |
154 | +.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test |
155 | diff --git a/copyright b/copyright |
156 | new file mode 100644 |
157 | index 0000000..d645695 |
158 | --- /dev/null |
159 | +++ b/copyright |
160 | @@ -0,0 +1,202 @@ |
161 | + |
162 | + Apache License |
163 | + Version 2.0, January 2004 |
164 | + http://www.apache.org/licenses/ |
165 | + |
166 | + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
167 | + |
168 | + 1. Definitions. |
169 | + |
170 | + "License" shall mean the terms and conditions for use, reproduction, |
171 | + and distribution as defined by Sections 1 through 9 of this document. |
172 | + |
173 | + "Licensor" shall mean the copyright owner or entity authorized by |
174 | + the copyright owner that is granting the License. |
175 | + |
176 | + "Legal Entity" shall mean the union of the acting entity and all |
177 | + other entities that control, are controlled by, or are under common |
178 | + control with that entity. For the purposes of this definition, |
179 | + "control" means (i) the power, direct or indirect, to cause the |
180 | + direction or management of such entity, whether by contract or |
181 | + otherwise, or (ii) ownership of fifty percent (50%) or more of the |
182 | + outstanding shares, or (iii) beneficial ownership of such entity. |
183 | + |
184 | + "You" (or "Your") shall mean an individual or Legal Entity |
185 | + exercising permissions granted by this License. |
186 | + |
187 | + "Source" form shall mean the preferred form for making modifications, |
188 | + including but not limited to software source code, documentation |
189 | + source, and configuration files. |
190 | + |
191 | + "Object" form shall mean any form resulting from mechanical |
192 | + transformation or translation of a Source form, including but |
193 | + not limited to compiled object code, generated documentation, |
194 | + and conversions to other media types. |
195 | + |
196 | + "Work" shall mean the work of authorship, whether in Source or |
197 | + Object form, made available under the License, as indicated by a |
198 | + copyright notice that is included in or attached to the work |
199 | + (an example is provided in the Appendix below). |
200 | + |
201 | + "Derivative Works" shall mean any work, whether in Source or Object |
202 | + form, that is based on (or derived from) the Work and for which the |
203 | + editorial revisions, annotations, elaborations, or other modifications |
204 | + represent, as a whole, an original work of authorship. For the purposes |
205 | + of this License, Derivative Works shall not include works that remain |
206 | + separable from, or merely link (or bind by name) to the interfaces of, |
207 | + the Work and Derivative Works thereof. |
208 | + |
209 | + "Contribution" shall mean any work of authorship, including |
210 | + the original version of the Work and any modifications or additions |
211 | + to that Work or Derivative Works thereof, that is intentionally |
212 | + submitted to Licensor for inclusion in the Work by the copyright owner |
213 | + or by an individual or Legal Entity authorized to submit on behalf of |
214 | + the copyright owner. For the purposes of this definition, "submitted" |
215 | + means any form of electronic, verbal, or written communication sent |
216 | + to the Licensor or its representatives, including but not limited to |
217 | + communication on electronic mailing lists, source code control systems, |
218 | + and issue tracking systems that are managed by, or on behalf of, the |
219 | + Licensor for the purpose of discussing and improving the Work, but |
220 | + excluding communication that is conspicuously marked or otherwise |
221 | + designated in writing by the copyright owner as "Not a Contribution." |
222 | + |
223 | + "Contributor" shall mean Licensor and any individual or Legal Entity |
224 | + on behalf of whom a Contribution has been received by Licensor and |
225 | + subsequently incorporated within the Work. |
226 | + |
227 | + 2. Grant of Copyright License. Subject to the terms and conditions of |
228 | + this License, each Contributor hereby grants to You a perpetual, |
229 | + worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
230 | + copyright license to reproduce, prepare Derivative Works of, |
231 | + publicly display, publicly perform, sublicense, and distribute the |
232 | + Work and such Derivative Works in Source or Object form. |
233 | + |
234 | + 3. Grant of Patent License. Subject to the terms and conditions of |
235 | + this License, each Contributor hereby grants to You a perpetual, |
236 | + worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
237 | + (except as stated in this section) patent license to make, have made, |
238 | + use, offer to sell, sell, import, and otherwise transfer the Work, |
239 | + where such license applies only to those patent claims licensable |
240 | + by such Contributor that are necessarily infringed by their |
241 | + Contribution(s) alone or by combination of their Contribution(s) |
242 | + with the Work to which such Contribution(s) was submitted. If You |
243 | + institute patent litigation against any entity (including a |
244 | + cross-claim or counterclaim in a lawsuit) alleging that the Work |
245 | + or a Contribution incorporated within the Work constitutes direct |
246 | + or contributory patent infringement, then any patent licenses |
247 | + granted to You under this License for that Work shall terminate |
248 | + as of the date such litigation is filed. |
249 | + |
250 | + 4. Redistribution. You may reproduce and distribute copies of the |
251 | + Work or Derivative Works thereof in any medium, with or without |
252 | + modifications, and in Source or Object form, provided that You |
253 | + meet the following conditions: |
254 | + |
255 | + (a) You must give any other recipients of the Work or |
256 | + Derivative Works a copy of this License; and |
257 | + |
258 | + (b) You must cause any modified files to carry prominent notices |
259 | + stating that You changed the files; and |
260 | + |
261 | + (c) You must retain, in the Source form of any Derivative Works |
262 | + that You distribute, all copyright, patent, trademark, and |
263 | + attribution notices from the Source form of the Work, |
264 | + excluding those notices that do not pertain to any part of |
265 | + the Derivative Works; and |
266 | + |
267 | + (d) If the Work includes a "NOTICE" text file as part of its |
268 | + distribution, then any Derivative Works that You distribute must |
269 | + include a readable copy of the attribution notices contained |
270 | + within such NOTICE file, excluding those notices that do not |
271 | + pertain to any part of the Derivative Works, in at least one |
272 | + of the following places: within a NOTICE text file distributed |
273 | + as part of the Derivative Works; within the Source form or |
274 | + documentation, if provided along with the Derivative Works; or, |
275 | + within a display generated by the Derivative Works, if and |
276 | + wherever such third-party notices normally appear. The contents |
277 | + of the NOTICE file are for informational purposes only and |
278 | + do not modify the License. You may add Your own attribution |
279 | + notices within Derivative Works that You distribute, alongside |
280 | + or as an addendum to the NOTICE text from the Work, provided |
281 | + that such additional attribution notices cannot be construed |
282 | + as modifying the License. |
283 | + |
284 | + You may add Your own copyright statement to Your modifications and |
285 | + may provide additional or different license terms and conditions |
286 | + for use, reproduction, or distribution of Your modifications, or |
287 | + for any such Derivative Works as a whole, provided Your use, |
288 | + reproduction, and distribution of the Work otherwise complies with |
289 | + the conditions stated in this License. |
290 | + |
291 | + 5. Submission of Contributions. Unless You explicitly state otherwise, |
292 | + any Contribution intentionally submitted for inclusion in the Work |
293 | + by You to the Licensor shall be under the terms and conditions of |
294 | + this License, without any additional terms or conditions. |
295 | + Notwithstanding the above, nothing herein shall supersede or modify |
296 | + the terms of any separate license agreement you may have executed |
297 | + with Licensor regarding such Contributions. |
298 | + |
299 | + 6. Trademarks. This License does not grant permission to use the trade |
300 | + names, trademarks, service marks, or product names of the Licensor, |
301 | + except as required for reasonable and customary use in describing the |
302 | + origin of the Work and reproducing the content of the NOTICE file. |
303 | + |
304 | + 7. Disclaimer of Warranty. Unless required by applicable law or |
305 | + agreed to in writing, Licensor provides the Work (and each |
306 | + Contributor provides its Contributions) on an "AS IS" BASIS, |
307 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
308 | + implied, including, without limitation, any warranties or conditions |
309 | + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
310 | + PARTICULAR PURPOSE. You are solely responsible for determining the |
311 | + appropriateness of using or redistributing the Work and assume any |
312 | + risks associated with Your exercise of permissions under this License. |
313 | + |
314 | + 8. Limitation of Liability. In no event and under no legal theory, |
315 | + whether in tort (including negligence), contract, or otherwise, |
316 | + unless required by applicable law (such as deliberate and grossly |
317 | + negligent acts) or agreed to in writing, shall any Contributor be |
318 | + liable to You for damages, including any direct, indirect, special, |
319 | + incidental, or consequential damages of any character arising as a |
320 | + result of this License or out of the use or inability to use the |
321 | + Work (including but not limited to damages for loss of goodwill, |
322 | + work stoppage, computer failure or malfunction, or any and all |
323 | + other commercial damages or losses), even if such Contributor |
324 | + has been advised of the possibility of such damages. |
325 | + |
326 | + 9. Accepting Warranty or Additional Liability. While redistributing |
327 | + the Work or Derivative Works thereof, You may choose to offer, |
328 | + and charge a fee for, acceptance of support, warranty, indemnity, |
329 | + or other liability obligations and/or rights consistent with this |
330 | + License. However, in accepting such obligations, You may act only |
331 | + on Your own behalf and on Your sole responsibility, not on behalf |
332 | + of any other Contributor, and only if You agree to indemnify, |
333 | + defend, and hold each Contributor harmless for any liability |
334 | + incurred by, or claims asserted against, such Contributor by reason |
335 | + of your accepting any such warranty or additional liability. |
336 | + |
337 | + END OF TERMS AND CONDITIONS |
338 | + |
339 | + APPENDIX: How to apply the Apache License to your work. |
340 | + |
341 | + To apply the Apache License to your work, attach the following |
342 | + boilerplate notice, with the fields enclosed by brackets "[]" |
343 | + replaced with your own identifying information. (Don't include |
344 | + the brackets!) The text should be enclosed in the appropriate |
345 | + comment syntax for the file format. We also recommend that a |
346 | + file or class name and description of purpose be included on the |
347 | + same "printed page" as the copyright notice for easier |
348 | + identification within third-party archives. |
349 | + |
350 | + Copyright [yyyy] [name of copyright owner] |
351 | + |
352 | + Licensed under the Apache License, Version 2.0 (the "License"); |
353 | + you may not use this file except in compliance with the License. |
354 | + You may obtain a copy of the License at |
355 | + |
356 | + http://www.apache.org/licenses/LICENSE-2.0 |
357 | + |
358 | + Unless required by applicable law or agreed to in writing, software |
359 | + distributed under the License is distributed on an "AS IS" BASIS, |
360 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
361 | + See the License for the specific language governing permissions and |
362 | + limitations under the License. |
363 | diff --git a/tox.ini b/tox.ini |
364 | index 3850104..9dc4234 100644 |
365 | --- a/tox.ini |
366 | +++ b/tox.ini |
367 | @@ -1,35 +1,31 @@ |
368 | [tox] |
369 | -skipsdist = True |
370 | -envlist = unit, func |
371 | +skipsdist=True |
372 | skip_missing_interpreters = True |
373 | +envlist = lint, unit, func |
374 | |
375 | [testenv] |
376 | basepython = python3 |
377 | setenv = |
378 | - PYTHONPATH = {toxinidir}/lib/:{toxinidir} |
379 | + PYTHONPATH = {toxinidir}:{toxinidir}/lib/:{toxinidir}/hooks/ |
380 | passenv = |
381 | HOME |
382 | - MODEL_SETTINGS |
383 | + PATH |
384 | CHARM_BUILD_DIR |
385 | - |
386 | -[testenv:unit] |
387 | -commands = |
388 | - coverage run -m unittest discover -s {toxinidir}/tests/unit -v |
389 | - coverage report \ |
390 | - --omit tests/*,mod/*,.tox/* |
391 | - coverage html \ |
392 | - --omit tests/*,mod/*,.tox/* |
393 | -deps = -r{toxinidir}/tests/unit/requirements.txt |
394 | - |
395 | -[testenv:func] |
396 | -changedir = {toxinidir}/tests/functional |
397 | -commands = functest-run-suite {posargs} |
398 | -deps = -r{toxinidir}/tests/functional/requirements.txt |
399 | + PYTEST_KEEP_MODEL |
400 | + PYTEST_CLOUD_NAME |
401 | + PYTEST_CLOUD_REGION |
402 | + PYTEST_MODEL |
403 | + MODEL_SETTINGS |
404 | + HTTP_PROXY |
405 | + HTTPS_PROXY |
406 | + NO_PROXY |
407 | + SNAP_HTTP_PROXY |
408 | + SNAP_HTTPS_PROXY |
409 | |
410 | [testenv:lint] |
411 | commands = |
412 | flake8 |
413 | - black --check --exclude /(\.eggs|\.git|\.tox|\.venv|build|dist|charmhelpers|mod)/ . |
414 | + black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" . |
415 | deps = |
416 | black |
417 | flake8 |
418 | @@ -43,10 +39,30 @@ exclude = |
419 | .git, |
420 | __pycache__, |
421 | .tox, |
422 | + charmhelpers, |
423 | mod, |
424 | + .build |
425 | + |
426 | max-line-length = 88 |
427 | max-complexity = 10 |
428 | + |
429 | +# From previous tox.ini |
430 | import-order-style = google |
431 | |
432 | -[isort] |
433 | -force_to_top=setuppath |
434 | +[testenv:black] |
435 | +commands = |
436 | + black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" . |
437 | +deps = |
438 | + black |
439 | + |
440 | +[testenv:unit] |
441 | +commands = |
442 | + coverage run -m unittest discover -s {toxinidir}/tests/unit -v |
443 | + coverage report --omit tests/*,mod/*,.tox/* |
444 | + coverage html --omit tests/*,mod/*,.tox/* |
445 | +deps = -r{toxinidir}/tests/unit/requirements.txt |
446 | + |
447 | +[testenv:func] |
448 | +changedir = {toxinidir}/tests/functional |
449 | +commands = functest-run-suite {posargs} |
450 | +deps = -r{toxinidir}/tests/functional/requirements.txt |
charm proof is failing because of no copyright file. Apart from that, LGTM. Please add copyright, and we can pass this through.