Merge ~vultaire/charm-logrotated:makefile-20.08 into charm-logrotated:master
- Git
- lp:~vultaire/charm-logrotated
- makefile-20.08
- Merge into master
Status: | Merged |
---|---|
Approved by: | Xav Paice |
Approved revision: | 94645d6de5330219b5e81af1318a18ecd25e189e |
Merged at revision: | ec9985e94479b34a6b74d40326a1c9126fb40e3f |
Proposed branch: | ~vultaire/charm-logrotated:makefile-20.08 |
Merge into: | charm-logrotated:master |
Diff against target: |
482 lines (+137/-57) 9 files modified
.gitignore (+26/-7) Makefile (+60/-29) dev/null (+0/-1) src/actions/update-cronjob (+1/-0) src/actions/update-logrotate-files (+1/-0) src/lib/lib_cron.py (+0/-1) src/tests/functional/test_logrotate.py (+3/-2) src/tests/unit/conftest.py (+1/-0) src/tox.ini (+45/-17) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xav Paice (community) | Approve | ||
Canonical IS Reviewers | Pending | ||
Review via email: mp+388838@code.launchpad.net |
Commit message
Imported standard Makefile and tox.ini and fixed up tests
Description of the change
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Xav Paice (xavpaice) wrote : | # |
This was failing functional tests for me on the attempt to deploy the model.
There were a couple of issues, here's a diff:
diff --git a/src/tests/
index 06517c1..936c577 100644
--- a/src/tests/
+++ b/src/tests/
@@ -8,7 +8,7 @@ import pytest
pytestmark = pytest.mark.asyncio
SERIES = ['xenial',
- pytest.
+ 'focal',
]
@@ -29,7 +29,7 @@ async def deploy_app(request, model):
)
logrotate_app = await model.deploy(
- '{}/logrotate'
+ '{}/logrotated'
Paul Goins (vultaire) wrote : | # |
Changed pushed; running functional tests to verify.
Paul Goins (vultaire) wrote : | # |
Functional tests passed. Ready for review again.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Change successfully merged at revision ec9985e94479b34
Preview Diff
1 | diff --git a/.gitignore b/.gitignore |
2 | index 32e2995..6f1f367 100644 |
3 | --- a/.gitignore |
4 | +++ b/.gitignore |
5 | @@ -1,22 +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 | +# Snaps |
48 | +*.snap |
49 | |
50 | -# reports |
51 | -report/* |
52 | +# Builds |
53 | +.build/ |
54 | \ No newline at end of file |
55 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml |
56 | deleted file mode 100644 |
57 | index 6189d3a..0000000 |
58 | --- a/.pre-commit-config.yaml |
59 | +++ /dev/null |
60 | @@ -1,49 +0,0 @@ |
61 | -repos: |
62 | -- repo: git://github.com/pre-commit/pre-commit-hooks |
63 | - sha: v1.1.1 |
64 | - hooks: |
65 | - - id: trailing-whitespace |
66 | - exclude: cherrypy/test/static/index.html |
67 | - - id: flake8 |
68 | - args: |
69 | - # W503 ignored for https://github.com/PyCQA/pycodestyle/issues/498 |
70 | - - --ignore=W503 |
71 | - # E126 ignored, as yapf will give better identation |
72 | - - --ignore=E126 |
73 | - - id: check-merge-conflict |
74 | - - id: double-quote-string-fixer |
75 | - - id: end-of-file-fixer |
76 | - - id: name-tests-test |
77 | - - id: check-ast |
78 | - - id: check-added-large-files |
79 | - - id: check-byte-order-marker |
80 | - - id: check-case-conflict |
81 | - - id: check-json |
82 | - include: .mention-bot |
83 | - - id: pretty-format-json |
84 | - - id: check-symlinks |
85 | - - id: check-yaml |
86 | - - id: detect-private-key |
87 | -# exclude: cherrypy/test/test.pem |
88 | - - id: requirements-txt-fixer |
89 | - |
90 | - |
91 | -- repo: git://github.com/Lucas-C/pre-commit-hooks |
92 | - sha: v1.1.1 |
93 | - hooks: |
94 | - - id: remove-tabs |
95 | - |
96 | -- repo: https://github.com/pre-commit/mirrors-yapf |
97 | - sha: 'master' # Use the sha / tag you want to point at |
98 | - hooks: |
99 | - - id: yapf |
100 | - |
101 | -- repo: https://github.com/pre-commit/mirrors-isort |
102 | - sha: 'master' # Use the sha / tag you want to point at |
103 | - hooks: |
104 | - - id: isort |
105 | - |
106 | -- repo: git://github.com/FalconSocial/pre-commit-mirrors-pep257 |
107 | - sha: 'master' |
108 | - hooks: |
109 | - - id: pep257 |
110 | diff --git a/Makefile b/Makefile |
111 | index a8c1fd7..5416279 100644 |
112 | --- a/Makefile |
113 | +++ b/Makefile |
114 | @@ -1,49 +1,80 @@ |
115 | +PYTHON := /usr/bin/python3 |
116 | + |
117 | +PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST))) |
118 | +ifndef CHARM_BUILD_DIR |
119 | + CHARM_BUILD_DIR=${PROJECTPATH}.build |
120 | +endif |
121 | +ifndef CHARM_LAYERS_DIR |
122 | + CHARM_LAYERS_DIR=${PROJECTPATH}/layers |
123 | +endif |
124 | +ifndef CHARM_INTERFACES_DIR |
125 | + CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces |
126 | +endif |
127 | +METADATA_FILE="src/metadata.yaml" |
128 | +CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}') |
129 | + |
130 | help: |
131 | @echo "This project supports the following targets" |
132 | @echo "" |
133 | @echo " make help - show this text" |
134 | + @echo " make clean - remove unneeded files" |
135 | @echo " make submodules - make sure that the submodules are up-to-date" |
136 | - @echo " make lint - run flake8" |
137 | - @echo " make test - run the unittests and lint" |
138 | - @echo " make unittest - run the tests defined in the unittest subdirectory" |
139 | + @echo " make submodules-update - update submodules to latest changes on remote branch" |
140 | + @echo " make build - build the charm" |
141 | + @echo " make release - run clean, submodules, and build targets" |
142 | + @echo " make lint - run flake8 and black --check" |
143 | + @echo " make black - run black and reformat files" |
144 | + @echo " make proof - run charm proof" |
145 | + @echo " make unittests - run the tests defined in the unittest subdirectory" |
146 | @echo " make functional - run the tests defined in the functional subdirectory" |
147 | - @echo " make release - build the charm" |
148 | - @echo " make clean - remove unneeded files" |
149 | + @echo " make test - run lint, proof, unittests and functional targets" |
150 | @echo "" |
151 | |
152 | +clean: |
153 | + @echo "Cleaning files" |
154 | + @git clean -ffXd -e '!.idea' |
155 | + @echo "Cleaning existing build" |
156 | + @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME} |
157 | + |
158 | submodules: |
159 | @echo "Cloning submodules" |
160 | @git submodule update --init --recursive |
161 | |
162 | -lint: |
163 | - @echo "Running flake8" |
164 | - @tox -e lint |
165 | +submodules-update: |
166 | + @echo "Pulling latest updates for submodules" |
167 | + @git submodule update --init --recursive --remote --merge |
168 | |
169 | -test: unittest functional lint |
170 | +build: |
171 | + @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}" |
172 | + @-git rev-parse --abbrev-ref HEAD > ./src/repo-info |
173 | + @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \ |
174 | + TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/ |
175 | |
176 | -unittest: |
177 | - @tox -e unit |
178 | +release: clean build |
179 | + @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}" |
180 | |
181 | -functional: build |
182 | - @PYTEST_KEEP_MODEL=$(PYTEST_KEEP_MODEL) \ |
183 | - PYTEST_CLOUD_NAME=$(PYTEST_CLOUD_NAME) \ |
184 | - PYTEST_CLOUD_REGION=$(PYTEST_CLOUD_REGION) \ |
185 | - tox -e functional |
186 | +lint: |
187 | + @echo "Running lint checks" |
188 | + @cd src && tox -e lint |
189 | |
190 | -build: |
191 | - @echo "Building charm to base directory $(JUJU_REPOSITORY)" |
192 | - @-git describe --tags > ./repo-info |
193 | - @LAYER_PATH=./layers INTERFACE_PATH=./interfaces TERM=linux \ |
194 | - JUJU_REPOSITORY=$(JUJU_REPOSITORY) charm build . --force |
195 | +black: |
196 | + @echo "Reformat files with black" |
197 | + @cd src && tox -e black |
198 | |
199 | -release: clean build |
200 | - @echo "Charm is built at $(JUJU_REPOSITORY)/builds" |
201 | +proof: build |
202 | + @echo "Running charm proof" |
203 | + @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME} |
204 | |
205 | -clean: |
206 | - @echo "Cleaning files" |
207 | - @if [ -d .tox ] ; then rm -r .tox ; fi |
208 | - @if [ -d .pytest_cache ] ; then rm -r .pytest_cache ; fi |
209 | - @find . -iname __pycache__ -exec rm -r {} + |
210 | +unittests: |
211 | + @echo "Running unit tests" |
212 | + @cd src && tox -e unit |
213 | + |
214 | +functional: build |
215 | + @echo "Executing functional tests in ${CHARM_BUILD_DIR}" |
216 | + @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func |
217 | + |
218 | +test: lint proof unittests functional |
219 | + @echo "Tests completed for charm ${CHARM_NAME}." |
220 | |
221 | # The targets below don't depend on a file |
222 | -.PHONY: lint test unittest functional build release clean help submodules |
223 | +.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test |
224 | diff --git a/actions/update-cronjob b/actions/update-cronjob |
225 | deleted file mode 120000 |
226 | index 405a394..0000000 |
227 | --- a/actions/update-cronjob |
228 | +++ /dev/null |
229 | @@ -1 +0,0 @@ |
230 | -actions.py |
231 | \ No newline at end of file |
232 | diff --git a/actions/update-logrotate-files b/actions/update-logrotate-files |
233 | deleted file mode 120000 |
234 | index 405a394..0000000 |
235 | --- a/actions/update-logrotate-files |
236 | +++ /dev/null |
237 | @@ -1 +0,0 @@ |
238 | -actions.py |
239 | \ No newline at end of file |
240 | diff --git a/README.md b/src/README.md |
241 | similarity index 100% |
242 | rename from README.md |
243 | rename to src/README.md |
244 | diff --git a/actions.yaml b/src/actions.yaml |
245 | similarity index 100% |
246 | rename from actions.yaml |
247 | rename to src/actions.yaml |
248 | diff --git a/actions/.empty b/src/actions/.empty |
249 | similarity index 100% |
250 | rename from actions/.empty |
251 | rename to src/actions/.empty |
252 | diff --git a/actions/actions.py b/src/actions/actions.py |
253 | similarity index 100% |
254 | rename from actions/actions.py |
255 | rename to src/actions/actions.py |
256 | diff --git a/src/actions/update-cronjob b/src/actions/update-cronjob |
257 | new file mode 120000 |
258 | index 0000000..405a394 |
259 | --- /dev/null |
260 | +++ b/src/actions/update-cronjob |
261 | @@ -0,0 +1 @@ |
262 | +actions.py |
263 | \ No newline at end of file |
264 | diff --git a/src/actions/update-logrotate-files b/src/actions/update-logrotate-files |
265 | new file mode 120000 |
266 | index 0000000..405a394 |
267 | --- /dev/null |
268 | +++ b/src/actions/update-logrotate-files |
269 | @@ -0,0 +1 @@ |
270 | +actions.py |
271 | \ No newline at end of file |
272 | diff --git a/config.yaml b/src/config.yaml |
273 | similarity index 100% |
274 | rename from config.yaml |
275 | rename to src/config.yaml |
276 | diff --git a/icon.svg b/src/icon.svg |
277 | similarity index 100% |
278 | rename from icon.svg |
279 | rename to src/icon.svg |
280 | diff --git a/layer.yaml b/src/layer.yaml |
281 | similarity index 100% |
282 | rename from layer.yaml |
283 | rename to src/layer.yaml |
284 | diff --git a/lib/lib_cron.py b/src/lib/lib_cron.py |
285 | similarity index 100% |
286 | rename from lib/lib_cron.py |
287 | rename to src/lib/lib_cron.py |
288 | index 1478a24..b7d24c4 100644 |
289 | --- a/lib/lib_cron.py |
290 | +++ b/src/lib/lib_cron.py |
291 | @@ -87,6 +87,5 @@ def main(): |
292 | hookenv.status_set('active', 'Unit is ready.') |
293 | |
294 | |
295 | - |
296 | if __name__ == '__main__': |
297 | main() |
298 | diff --git a/lib/lib_logrotate.py b/src/lib/lib_logrotate.py |
299 | similarity index 100% |
300 | rename from lib/lib_logrotate.py |
301 | rename to src/lib/lib_logrotate.py |
302 | diff --git a/metadata.yaml b/src/metadata.yaml |
303 | similarity index 100% |
304 | rename from metadata.yaml |
305 | rename to src/metadata.yaml |
306 | diff --git a/reactive/logrotate.py b/src/reactive/logrotate.py |
307 | similarity index 100% |
308 | rename from reactive/logrotate.py |
309 | rename to src/reactive/logrotate.py |
310 | diff --git a/requirements.txt b/src/requirements.txt |
311 | similarity index 100% |
312 | rename from requirements.txt |
313 | rename to src/requirements.txt |
314 | diff --git a/revision b/src/revision |
315 | similarity index 100% |
316 | rename from revision |
317 | rename to src/revision |
318 | diff --git a/tests/functional/conftest.py b/src/tests/functional/conftest.py |
319 | similarity index 100% |
320 | rename from tests/functional/conftest.py |
321 | rename to src/tests/functional/conftest.py |
322 | diff --git a/tests/functional/juju_tools.py b/src/tests/functional/juju_tools.py |
323 | similarity index 100% |
324 | rename from tests/functional/juju_tools.py |
325 | rename to src/tests/functional/juju_tools.py |
326 | diff --git a/tests/functional/requirements.txt b/src/tests/functional/requirements.txt |
327 | similarity index 100% |
328 | rename from tests/functional/requirements.txt |
329 | rename to src/tests/functional/requirements.txt |
330 | diff --git a/tests/functional/test_logrotate.py b/src/tests/functional/test_logrotate.py |
331 | similarity index 95% |
332 | rename from tests/functional/test_logrotate.py |
333 | rename to src/tests/functional/test_logrotate.py |
334 | index 100690f..936c577 100644 |
335 | --- a/tests/functional/test_logrotate.py |
336 | +++ b/src/tests/functional/test_logrotate.py |
337 | @@ -8,9 +8,10 @@ import pytest |
338 | pytestmark = pytest.mark.asyncio |
339 | SERIES = ['xenial', |
340 | 'bionic', |
341 | - pytest.param('cosmic', marks=pytest.mark.xfail(reason='canary')), |
342 | + 'focal', |
343 | ] |
344 | |
345 | + |
346 | ############ |
347 | # FIXTURES # |
348 | ############ |
349 | @@ -28,7 +29,7 @@ async def deploy_app(request, model): |
350 | channel='stable' |
351 | ) |
352 | logrotate_app = await model.deploy( |
353 | - '{}/builds/logrotate'.format(os.getenv('JUJU_REPOSITORY')), |
354 | + '{}/logrotated'.format(os.getenv('CHARM_BUILD_DIR')), |
355 | application_name='logrotate-' + release, |
356 | series=release, |
357 | num_units=0, |
358 | diff --git a/tests/unit/conftest.py b/src/tests/unit/conftest.py |
359 | similarity index 100% |
360 | rename from tests/unit/conftest.py |
361 | rename to src/tests/unit/conftest.py |
362 | index 8520709..b4c0517 100644 |
363 | --- a/tests/unit/conftest.py |
364 | +++ b/src/tests/unit/conftest.py |
365 | @@ -5,6 +5,7 @@ import mock |
366 | |
367 | import pytest |
368 | |
369 | + |
370 | # If layer options are used, add this to ${fixture} |
371 | # and import layer in logrotate |
372 | @pytest.fixture |
373 | diff --git a/tests/unit/example.cfg b/src/tests/unit/example.cfg |
374 | similarity index 100% |
375 | rename from tests/unit/example.cfg |
376 | rename to src/tests/unit/example.cfg |
377 | diff --git a/tests/unit/logrotate_example b/src/tests/unit/logrotate_example |
378 | similarity index 100% |
379 | rename from tests/unit/logrotate_example |
380 | rename to src/tests/unit/logrotate_example |
381 | diff --git a/tests/unit/requirements.txt b/src/tests/unit/requirements.txt |
382 | similarity index 100% |
383 | rename from tests/unit/requirements.txt |
384 | rename to src/tests/unit/requirements.txt |
385 | diff --git a/tests/unit/test_logrotate.py b/src/tests/unit/test_logrotate.py |
386 | similarity index 100% |
387 | rename from tests/unit/test_logrotate.py |
388 | rename to src/tests/unit/test_logrotate.py |
389 | diff --git a/tox.ini b/src/tox.ini |
390 | similarity index 56% |
391 | rename from tox.ini |
392 | rename to src/tox.ini |
393 | index 6bae0d7..78da1be 100644 |
394 | --- a/tox.ini |
395 | +++ b/src/tox.ini |
396 | @@ -1,35 +1,33 @@ |
397 | [tox] |
398 | skipsdist=True |
399 | -envlist = unit, functional |
400 | skip_missing_interpreters = True |
401 | +envlist = lint, unit, func |
402 | |
403 | [testenv] |
404 | basepython = python3 |
405 | setenv = |
406 | - PYTHONPATH = . |
407 | - |
408 | -[testenv:unit] |
409 | -commands = pytest -o log_cli=true --full-trace -v --ignore {toxinidir}/tests/functional |
410 | -deps = -r{toxinidir}/tests/unit/requirements.txt |
411 | - -r{toxinidir}/requirements.txt |
412 | -setenv = PYTHONPATH={toxinidir}/lib |
413 | -whitelist_externals = pytest |
414 | - |
415 | -[testenv:functional] |
416 | + PYTHONPATH = {toxinidir}:{toxinidir}/lib/:{toxinidir}/hooks/ |
417 | passenv = |
418 | HOME |
419 | - JUJU_REPOSITORY |
420 | PATH |
421 | + CHARM_BUILD_DIR |
422 | PYTEST_KEEP_MODEL |
423 | PYTEST_CLOUD_NAME |
424 | PYTEST_CLOUD_REGION |
425 | -commands = pytest -v --ignore {toxinidir}/tests/unit |
426 | -deps = -r{toxinidir}/tests/functional/requirements.txt |
427 | - -r{toxinidir}/requirements.txt |
428 | + PYTEST_MODEL |
429 | + MODEL_SETTINGS |
430 | + HTTP_PROXY |
431 | + HTTPS_PROXY |
432 | + NO_PROXY |
433 | + SNAP_HTTP_PROXY |
434 | + SNAP_HTTPS_PROXY |
435 | |
436 | [testenv:lint] |
437 | -commands = flake8 |
438 | +commands = |
439 | + flake8 |
440 | +#TODO black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" . |
441 | deps = |
442 | + black |
443 | flake8 |
444 | flake8-docstrings |
445 | flake8-import-order |
446 | @@ -41,5 +39,35 @@ exclude = |
447 | .git, |
448 | __pycache__, |
449 | .tox, |
450 | -max-line-length = 120 |
451 | + charmhelpers, |
452 | + mod, |
453 | + .build |
454 | + |
455 | +#max-line-length = 88 |
456 | max-complexity = 10 |
457 | + |
458 | +# from old tox.ini |
459 | +max-line-length = 120 |
460 | + |
461 | +[testenv:black] |
462 | +commands = |
463 | + black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" . |
464 | +deps = |
465 | + black |
466 | + |
467 | +[testenv:unit] |
468 | +commands = |
469 | + pytest -v --ignore {toxinidir}/tests/functional \ |
470 | + --cov=lib \ |
471 | + --cov=reactive \ |
472 | + --cov=actions \ |
473 | + --cov=hooks \ |
474 | + --cov=src \ |
475 | + --cov-report=term \ |
476 | + --cov-report=annotate:report/annotated \ |
477 | + --cov-report=html:report/html |
478 | +deps = -r{toxinidir}/tests/unit/requirements.txt |
479 | + |
480 | +[testenv:func] |
481 | +commands = pytest -v --ignore {toxinidir}/tests/unit |
482 | +deps = -r{toxinidir}/tests/functional/requirements.txt |
This merge proposal is being monitored by mergebot. Change the status to Approved to merge.