Merge ~peppepetra/charm-sudo-pair:makefile-20.08 into charm-sudo-pair:master

Proposed by Giuseppe Petralia
Status: Merged
Approved by: Xav Paice
Approved revision: 421e6853e4098e11025c4e180215b1eeb76c604e
Merged at revision: 421e6853e4098e11025c4e180215b1eeb76c604e
Proposed branch: ~peppepetra/charm-sudo-pair:makefile-20.08
Merge into: charm-sudo-pair:master
Diff against target: 441 lines (+133/-78)
9 files modified
.gitignore (+24/-16)
Makefile (+60/-33)
dev/null (+0/-1)
interfaces/.empty (+0/-0)
layers/.empty (+0/-0)
src/actions/remove-sudopair (+1/-0)
src/tests/functional/conftest.py (+1/-1)
src/tests/functional/test_deploy.py (+2/-2)
src/tox.ini (+45/-25)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
Paul Goins Approve
Review via email: mp+388996@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Goins (vultaire) wrote :

LGTM. I did notice a couple of things which could get cleaned up and are (maybe, arguably) within scope, but they're not critical.

review: Approve
Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM, agreed on the things that could be cleaned up but I don't want to delay this change for those.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
index eda8bea..6f1f367 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,33 +1,41 @@
1# Juju files
2.unit-state.db
3.go-cookies
4
5layers/*
6interfaces/*
7
1# Byte-compiled / optimized / DLL files8# Byte-compiled / optimized / DLL files
2__pycache__/9__pycache__/
3*.py[cod]10*.py[cod]
4*$py.class11*$py.class
512
13# Tests files and dir
14.pytest_cache/
15.coverage
16.tox
17report/
18htmlcov/
19
6# Log files20# Log files
7*.log21*.log
822
9.tox/23# pycharm
10src/.tox/24.idea/
11.coverage
1225
13# vi26# vi
14.*.swp27.*.swp
1528
16# pycharm
17.idea/
18.unit-state.db
19src/.unit-state.db
20
21# version data29# version data
22repo-info30repo-info
31version
2332
33# Python builds
34deb_dist/
35dist/
2436
25# reports37# Snaps
26report/*38*.snap
27src/report/*
28
29# virtual env
30venv/*
3139
32# builds
33builds/*
34\ No newline at end of file40\ No newline at end of file
41# Builds
42.build/
35\ No newline at end of file43\ No newline at end of file
diff --git a/Makefile b/Makefile
index c7506b2..0a84b5f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,53 +1,80 @@
1PROJECTPATH = $(dir $(realpath $(MAKEFILE_LIST)))1PYTHON := /usr/bin/python3
2DIRNAME = $(notdir $(PROJECTPATH:%/=%))
32
3PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
4ifndef CHARM_BUILD_DIR4ifndef CHARM_BUILD_DIR
5 CHARM_BUILD_DIR := /tmp/$(DIRNAME)-builds5 CHARM_BUILD_DIR=${PROJECTPATH}.build
6 $(warning Warning CHARM_BUILD_DIR was not set, defaulting to $(CHARM_BUILD_DIR))
7endif6endif
7ifndef CHARM_LAYERS_DIR
8 CHARM_LAYERS_DIR=${PROJECTPATH}/layers
9endif
10ifndef CHARM_INTERFACES_DIR
11 CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
12endif
13METADATA_FILE="src/metadata.yaml"
14CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
815
9help:16help:
10 @echo "This project supports the following targets"17 @echo "This project supports the following targets"
11 @echo ""18 @echo ""
12 @echo " make help - show this text"19 @echo " make help - show this text"
13 @echo " make lint - run flake8"
14 @echo " make test - run the functional tests, unittests and lint"
15 @echo " make unittest - run the tests defined in the unittest subdirectory"
16 @echo " make functional - run the tests defined in the functional subdirectory"
17 @echo " make release - build the charm"
18 @echo " make clean - remove unneeded files"20 @echo " make clean - remove unneeded files"
21 @echo " make submodules - make sure that the submodules are up-to-date"
22 @echo " make submodules-update - update submodules to latest changes on remote branch"
23 @echo " make build - build the charm"
24 @echo " make release - run clean, submodules, and build targets"
25 @echo " make lint - run flake8 and black --check"
26 @echo " make black - run black and reformat files"
27 @echo " make proof - run charm proof"
28 @echo " make unittests - run the tests defined in the unittest subdirectory"
29 @echo " make functional - run the tests defined in the functional subdirectory"
30 @echo " make test - run lint, proof, unittests and functional targets"
19 @echo ""31 @echo ""
2032
21lint:33clean:
22 @echo "Running flake8"34 @echo "Cleaning files"
23 @tox -e lint35 @git clean -ffXd -e '!.idea'
2436 @echo "Cleaning existing build"
25test: lint unittest functional37 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
2638
27functional: build39submodules:
28 @PYTEST_KEEP_MODEL=$(PYTEST_KEEP_MODEL) \40 # @git submodule update --init --recursive
29 PYTEST_CLOUD_NAME=$(PYTEST_CLOUD_NAME) \41 @echo "No submodules. Skipping."
30 PYTEST_CLOUD_REGION=$(PYTEST_CLOUD_REGION) \
31 tox -e functional
3242
33unittest:43submodules-update:
34 @tox -e unit44 # @git submodule update --init --recursive --remote --merge
45 @echo "No submodules. Skipping."
3546
36build:47build:
37 @echo "Building charm to base directory $(CHARM_BUILD_DIR)"48 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
38 @-git describe --tags > ./repo-info49 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
39 @CHARM_LAYERS_DIR=./layers CHARM_INTERFACES_DIR=./interfaces TERM=linux\50 @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \
40 charm build --output-dir $(CHARM_BUILD_DIR) $(PROJECTPATH) --force51 TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/
4152
42release: clean build53release: clean build
43 @echo "Charm is built at $(CHARM_BUILD_DIR)/builds"54 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
4455
45clean:56lint:
46 @echo "Cleaning files"57 @echo "Running lint checks"
47 @find $(PROJECTPATH) -iname __pycache__ -exec rm -r {} +58 @cd src && tox -e lint
48 @if [ -d $(CHARM_BUILD_DIR)/builds ] ; then rm -r $(CHARM_BUILD_DIR)/builds ; fi59
49 @if [ -d $(PROJECTPATH)/.tox ] ; then rm -r $(PROJECTPATH)/.tox ; fi60black:
50 @if [ -d $(PROJECTPATH)/.pytest_cache ] ; then rm -r $(PROJECTPATH)/.pytest_cache ; fi61 @echo "Reformat files with black"
62 @cd src && tox -e black
63
64proof: build
65 @echo "Running charm proof"
66 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
67
68unittests:
69 @echo "Running unit tests"
70 @cd src && tox -e unit
71
72functional: build
73 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
74 @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
75
76test: lint proof unittests functional
77 @echo "Tests completed for charm ${CHARM_NAME}."
5178
52# The targets below don't depend on a file79# The targets below don't depend on a file
53.PHONY: lint test unittest functional build release clean help80.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
diff --git a/actions/remove-sudopair b/actions/remove-sudopair
54deleted file mode 12000081deleted file mode 120000
index ff9536b..0000000
--- a/actions/remove-sudopair
+++ /dev/null
@@ -1 +0,0 @@
1./actions.py
2\ No newline at end of file0\ No newline at end of file
diff --git a/interfaces/.empty b/interfaces/.empty
3new file mode 1006441new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/interfaces/.empty
diff --git a/layers/.empty b/layers/.empty
4new file mode 1006442new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/layers/.empty
diff --git a/README.md b/src/README.md
5similarity index 100%3similarity index 100%
6rename from README.md4rename from README.md
7rename to src/README.md5rename to src/README.md
diff --git a/actions.yaml b/src/actions.yaml
8similarity index 100%6similarity index 100%
9rename from actions.yaml7rename from actions.yaml
10rename to src/actions.yaml8rename to src/actions.yaml
diff --git a/actions/actions.py b/src/actions/actions.py
11similarity index 100%9similarity index 100%
12rename from actions/actions.py10rename from actions/actions.py
13rename to src/actions/actions.py11rename to src/actions/actions.py
diff --git a/src/actions/remove-sudopair b/src/actions/remove-sudopair
14new file mode 12000012new file mode 120000
index 0000000..ff9536b
--- /dev/null
+++ b/src/actions/remove-sudopair
@@ -0,0 +1 @@
1./actions.py
0\ No newline at end of file2\ No newline at end of file
diff --git a/config.yaml b/src/config.yaml
1similarity index 100%3similarity index 100%
2rename from config.yaml4rename from config.yaml
3rename to src/config.yaml5rename to src/config.yaml
diff --git a/files/sudo.prompt.pair b/src/files/sudo.prompt.pair
4similarity index 100%6similarity index 100%
5rename from files/sudo.prompt.pair7rename from files/sudo.prompt.pair
6rename to src/files/sudo.prompt.pair8rename to src/files/sudo.prompt.pair
diff --git a/files/sudo.prompt.user b/src/files/sudo.prompt.user
7similarity index 100%9similarity index 100%
8rename from files/sudo.prompt.user10rename from files/sudo.prompt.user
9rename to src/files/sudo.prompt.user11rename to src/files/sudo.prompt.user
diff --git a/files/sudo_pair.so b/src/files/sudo_pair.so
10similarity index 100%12similarity index 100%
11rename from files/sudo_pair.so13rename from files/sudo_pair.so
12rename to src/files/sudo_pair.so14rename to src/files/sudo_pair.so
13Binary files a/files/sudo_pair.so and b/src/files/sudo_pair.so differ15Binary files a/files/sudo_pair.so and b/src/files/sudo_pair.so differ
diff --git a/files/sudoers b/src/files/sudoers
14similarity index 100%16similarity index 100%
15rename from files/sudoers17rename from files/sudoers
16rename to src/files/sudoers18rename to src/files/sudoers
diff --git a/layer.yaml b/src/layer.yaml
17similarity index 100%19similarity index 100%
18rename from layer.yaml20rename from layer.yaml
19rename to src/layer.yaml21rename to src/layer.yaml
diff --git a/lib/libsudopair.py b/src/lib/libsudopair.py
20similarity index 100%22similarity index 100%
21rename from lib/libsudopair.py23rename from lib/libsudopair.py
22rename to src/lib/libsudopair.py24rename to src/lib/libsudopair.py
diff --git a/metadata.yaml b/src/metadata.yaml
23similarity index 100%25similarity index 100%
24rename from metadata.yaml26rename from metadata.yaml
25rename to src/metadata.yaml27rename to src/metadata.yaml
diff --git a/reactive/sudo_pair.py b/src/reactive/sudo_pair.py
26similarity index 100%28similarity index 100%
27rename from reactive/sudo_pair.py29rename from reactive/sudo_pair.py
28rename to src/reactive/sudo_pair.py30rename to src/reactive/sudo_pair.py
diff --git a/templates/91-bypass-sudopair-cmds.tmpl b/src/templates/91-bypass-sudopair-cmds.tmpl
29similarity index 100%31similarity index 100%
30rename from templates/91-bypass-sudopair-cmds.tmpl32rename from templates/91-bypass-sudopair-cmds.tmpl
31rename to src/templates/91-bypass-sudopair-cmds.tmpl33rename to src/templates/91-bypass-sudopair-cmds.tmpl
diff --git a/templates/sudo.conf.tmpl b/src/templates/sudo.conf.tmpl
32similarity index 100%34similarity index 100%
33rename from templates/sudo.conf.tmpl35rename from templates/sudo.conf.tmpl
34rename to src/templates/sudo.conf.tmpl36rename to src/templates/sudo.conf.tmpl
diff --git a/templates/sudo_approve.tmpl b/src/templates/sudo_approve.tmpl
35similarity index 100%37similarity index 100%
36rename from templates/sudo_approve.tmpl38rename from templates/sudo_approve.tmpl
37rename to src/templates/sudo_approve.tmpl39rename to src/templates/sudo_approve.tmpl
diff --git a/tests/00-unit b/src/tests/00-unit
38similarity index 100%40similarity index 100%
39rename from tests/00-unit41rename from tests/00-unit
40rename to src/tests/00-unit42rename to src/tests/00-unit
diff --git a/tests/01-functional b/src/tests/01-functional
41similarity index 100%43similarity index 100%
42rename from tests/01-functional44rename from tests/01-functional
43rename to src/tests/01-functional45rename to src/tests/01-functional
diff --git a/tests/functional/conftest.py b/src/tests/functional/conftest.py
44similarity index 99%46similarity index 99%
45rename from tests/functional/conftest.py47rename from tests/functional/conftest.py
46rename to src/tests/functional/conftest.py48rename to src/tests/functional/conftest.py
index aa42a09..68f3ffe 100644
--- a/tests/functional/conftest.py
+++ b/src/tests/functional/conftest.py
@@ -43,7 +43,7 @@ async def model(controller):
43 model = await controller.add_model(model_name)43 model = await controller.add_model(model_name)
44 yield model44 yield model
45 await model.disconnect()45 await model.disconnect()
46 if os.getenv('test_preserve_model'):46 if os.getenv('PYTEST_KEEP_MODEL'):
47 return47 return
48 await controller.destroy_model(model_name)48 await controller.destroy_model(model_name)
49 while model_name in await controller.list_models():49 while model_name in await controller.list_models():
diff --git a/tests/functional/requirements.txt b/src/tests/functional/requirements.txt
50similarity index 100%50similarity index 100%
51rename from tests/functional/requirements.txt51rename from tests/functional/requirements.txt
52rename to src/tests/functional/requirements.txt52rename to src/tests/functional/requirements.txt
diff --git a/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py
53similarity index 98%53similarity index 98%
54rename from tests/functional/test_deploy.py54rename from tests/functional/test_deploy.py
55rename to src/tests/functional/test_deploy.py55rename to src/tests/functional/test_deploy.py
index 2f0f272..1d531d1 100644
--- a/tests/functional/test_deploy.py
+++ b/src/tests/functional/test_deploy.py
@@ -6,10 +6,10 @@ import pytest
66
7pytestmark = pytest.mark.asyncio7pytestmark = pytest.mark.asyncio
88
9charm_build_dir = os.getenv("CHARM_BUILD_DIR", "..").rstrip("/")9charm_build_dir = os.getenv("CHARM_BUILD_DIR").rstrip("/")
1010
1111
12sources = [("local", "{}/builds/sudo-pair".format(charm_build_dir))]12sources = [("local", "{}/sudo-pair".format(charm_build_dir))]
1313
14series = [14series = [
15 "xenial",15 "xenial",
diff --git a/tests/tests.yaml b/src/tests/tests.yaml
16similarity index 100%16similarity index 100%
17rename from tests/tests.yaml17rename from tests/tests.yaml
18rename to src/tests/tests.yaml18rename to src/tests/tests.yaml
diff --git a/tests/unit/conftest.py b/src/tests/unit/conftest.py
19similarity index 100%19similarity index 100%
20rename from tests/unit/conftest.py20rename from tests/unit/conftest.py
21rename to src/tests/unit/conftest.py21rename to src/tests/unit/conftest.py
diff --git a/tests/unit/requirements.txt b/src/tests/unit/requirements.txt
22similarity index 100%22similarity index 100%
23rename from tests/unit/requirements.txt23rename from tests/unit/requirements.txt
24rename to src/tests/unit/requirements.txt24rename to src/tests/unit/requirements.txt
diff --git a/tests/unit/test_actions.py b/src/tests/unit/test_actions.py
25similarity index 100%25similarity index 100%
26rename from tests/unit/test_actions.py26rename from tests/unit/test_actions.py
27rename to src/tests/unit/test_actions.py27rename to src/tests/unit/test_actions.py
diff --git a/tests/unit/test_libsudopair.py b/src/tests/unit/test_libsudopair.py
28similarity index 100%28similarity index 100%
29rename from tests/unit/test_libsudopair.py29rename from tests/unit/test_libsudopair.py
30rename to src/tests/unit/test_libsudopair.py30rename to src/tests/unit/test_libsudopair.py
diff --git a/tox.ini b/src/tox.ini
31similarity index 62%31similarity index 62%
32rename from tox.ini32rename from tox.ini
33rename to src/tox.ini33rename to src/tox.ini
index fc364de..d07b692 100644
--- a/tox.ini
+++ b/src/tox.ini
@@ -1,51 +1,71 @@
1[tox]1[tox]
2skipsdist=True2skipsdist=True
3envlist = unit, functional
4skip_missing_interpreters = True3skip_missing_interpreters = True
4envlist = lint, unit, func
55
6[testenv]6[testenv]
7basepython = python37basepython = python3
8setenv =8setenv =
9 PYTHONPATH = .9 PYTHONPATH = {toxinidir}:{toxinidir}/lib/:{toxinidir}/hooks/
10
11[testenv:unit]
12commands = pytest -v --ignore {toxinidir}/tests/functional \
13 --cov=lib \
14 --cov=reactive \
15 --cov=actions \
16 --cov-report=term \
17 --cov-report=annotate:report/annotated \
18 --cov-report=html:report/html
19deps = -r{toxinidir}/tests/unit/requirements.txt
20
21setenv = PYTHONPATH={toxinidir}/lib
22
23[testenv:functional]
24passenv =10passenv =
25 HOME11 HOME
26 CHARM_BUILD_DIR
27 PATH12 PATH
13 CHARM_BUILD_DIR
28 PYTEST_KEEP_MODEL14 PYTEST_KEEP_MODEL
29 PYTEST_CLOUD_NAME15 PYTEST_CLOUD_NAME
30 PYTEST_CLOUD_REGION16 PYTEST_CLOUD_REGION
31commands = pytest -v --ignore {toxinidir}/tests/unit17 PYTEST_MODEL
32deps = -r{toxinidir}/tests/functional/requirements.txt18 MODEL_SETTINGS
3319 HTTP_PROXY
20 HTTPS_PROXY
21 NO_PROXY
22 SNAP_HTTP_PROXY
23 SNAP_HTTPS_PROXY
3424
35[testenv:lint]25[testenv:lint]
36commands = flake826commands =
27 flake8
28#TODO black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
37deps =29deps =
30 black
38 flake831 flake8
39 flake8-docstrings32#TODO flake8-docstrings
40 flake8-import-order33#TODO flake8-import-order
41 pep8-naming34#TODO pep8-naming
42 flake8-colors35 flake8-colors
4336
44[flake8]37[flake8]
45ignore = D100,D103 # Missing docstring in public module/function
46exclude =38exclude =
47 .git,39 .git,
48 __pycache__,40 __pycache__,
49 .tox,41 .tox,
42 charmhelpers,
43 mod,
44 .build
45
50max-line-length = 12046max-line-length = 120
47#TODO max-line-length = 88
51max-complexity = 1048max-complexity = 10
49
50[testenv:black]
51commands =
52 black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
53deps =
54 black
55
56[testenv:unit]
57commands =
58 pytest -v --ignore {toxinidir}/tests/functional \
59 --cov=lib \
60 --cov=reactive \
61 --cov=actions \
62 --cov=hooks \
63 --cov=src \
64 --cov-report=term \
65 --cov-report=annotate:report/annotated \
66 --cov-report=html:report/html
67deps = -r{toxinidir}/tests/unit/requirements.txt
68
69[testenv:func]
70commands = pytest -v --ignore {toxinidir}/tests/unit
71deps = -r{toxinidir}/tests/functional/requirements.txt

Subscribers

People subscribed via source and target branches