Merge ~vultaire/charm-prometheus-blackbox-exporter:makefile-20.08 into charm-prometheus-blackbox-exporter:master

Proposed by Paul Goins
Status: Merged
Merged at revision: c541de54c0543f7614ff067ba0a39cfadf6fc729
Proposed branch: ~vultaire/charm-prometheus-blackbox-exporter:makefile-20.08
Merge into: charm-prometheus-blackbox-exporter:master
Diff against target: 388 lines (+153/-99)
5 files modified
.gitignore (+26/-9)
Makefile (+57/-25)
dev/null (+0/-65)
src/tests/unit/requirements.txt (+1/-0)
src/tox.ini (+69/-0)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
Review via email: mp+388595@code.launchpad.net

Commit message

Updated Makefile/tox.ini/.gitignore and made related changes

Description of the change

Note: this charm lacked any unit tests, so while I fixed things so the unit tests would pass if there were any to test, the "make unittests" target _does_ fail since there are no tests (and thus no coverage data).

I could add a dummy test if strongly desired, but I feel like that could unintentionally "cover up" that this charm has no unit tests. At the very least I want to call this out so we can decide what to do here.

To post a comment you must log in.
Revision history for this message
Paul Goins (vultaire) wrote :

Also note that the 'Fixed "make lint"' commit is a combination of tox.ini tweaks and running black, and nothing more.

Revision history for this message
Paul Goins (vultaire) wrote :

Re-pushed... Fixed "make lint" to _not_ run black (as that would kind of defeat the point of having a separate black commit)

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

LGTM

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 2dc89c9..6f1f367 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,24 +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
6# Log files13# Tests files and dir
7*.log14.pytest_cache/
8.tox/
9.coverage15.coverage
16.tox
17report/
18htmlcov/
1019
11# vi20# Log files
12.*.swp21*.log
1322
14# pycharm23# pycharm
15.idea/24.idea/
1625
26# vi
27.*.swp
28
17# version data29# version data
18repo-info30repo-info
31version
32
33# Python builds
34deb_dist/
35dist/
1936
20# reports37# Snaps
21report/*38*.snap
2239
23# layers
24layers/*
25\ No newline at end of file40\ No newline at end of file
41# Builds
42.build/
26\ No newline at end of file43\ No newline at end of file
diff --git a/Makefile b/Makefile
index 949713b..647cacd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,48 +1,80 @@
1PYTHON := /usr/bin/python3
2
3PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
1ifndef CHARM_BUILD_DIR4ifndef CHARM_BUILD_DIR
2 CHARM_BUILD_DIR=/tmp/builds5 CHARM_BUILD_DIR=${PROJECTPATH}.build
6endif
7ifndef CHARM_LAYERS_DIR
8 CHARM_LAYERS_DIR=${PROJECTPATH}/layers
9endif
10ifndef CHARM_INTERFACES_DIR
11 CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
3endif12endif
13METADATA_FILE="src/metadata.yaml"
14CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
415
5help:16help:
6 @echo "This project supports the following targets"17 @echo "This project supports the following targets"
7 @echo ""18 @echo ""
8 @echo " make help - show this text"19 @echo " make help - show this text"
20 @echo " make clean - remove unneeded files"
9 @echo " make submodules - make sure that the submodules are up-to-date"21 @echo " make submodules - make sure that the submodules are up-to-date"
10 @echo " make lint - run flake8"22 @echo " make submodules-update - update submodules to latest changes on remote branch"
11 @echo " make test - run the functional tests and lint"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"
12 @echo " make functional - run the tests defined in the functional subdirectory"29 @echo " make functional - run the tests defined in the functional subdirectory"
13 @echo " make release - build the charm"30 @echo " make test - run lint, proof, unittests and functional targets"
14 @echo " make clean - remove unneeded files"
15 @echo ""31 @echo ""
1632
33clean:
34 @echo "Cleaning files"
35 @git clean -ffXd -e '!.idea'
36 @echo "Cleaning existing build"
37 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
38
17submodules:39submodules:
18 @echo "Cloning submodules"40 @echo "Cloning submodules"
19 @git submodule update --init --recursive41 @git submodule update --init --recursive
2042
43submodules-update:
44 @echo "Pulling latest updates for submodules"
45 @git submodule update --init --recursive --remote --merge
46
47build:
48 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
49 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
50 @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \
51 TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/
52
53release: clean build
54 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
55
21lint:56lint:
22 @mkdir -p report/lint/57 @echo "Running lint checks"
23 @echo "Running flake8"58 @cd src && tox -e lint
24 @tox -e lint
2559
26test: lint functional60black:
61 @echo "Reformat files with black"
62 @cd src && tox -e black
2763
28functional: build64proof:
29 @echo Executing with: CHARM_BUILD_DIR=$(CHARM_BUILD_DIR) tox -e func65 @echo "Running charm proof"
30 @CHARM_BUILD_DIR=$(CHARM_BUILD_DIR) tox -e func66 @charm proof src
3167
32build:68unittests:
33 @echo "Building charm to base directory $(CHARM_BUILD_DIR)"69 @echo "Running unit tests"
34 @-git describe --tags > ./repo-info70 @cd src && tox -e unit
35 @CHARM_LAYERS_DIR=./layers CHARM_INTERFACES_DIR=./interfaces TERM=linux \
36 CHARM_BUILD_DIR=$(CHARM_BUILD_DIR) charm build . --force
3771
38release: clean build72functional: build
39 @echo "Charm is built at $(CHARM_BUILD_DIR)/prometheus-blackbox-exporter"73 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
74 @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
4075
41clean:76test: lint proof unittests functional
42 @echo "Cleaning files"77 @echo "Tests completed for charm ${CHARM_NAME}."
43 @if [ -d .tox ] ; then rm -r .tox ; fi
44 @if [ -d .pytest_cache ] ; then rm -r .pytest_cache ; fi
45 @find . -iname __pycache__ -exec rm -r {} +
4678
47# The targets below don't depend on a file79# The targets below don't depend on a file
48.PHONY: lint test functional build release clean help submodules80.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
diff --git a/README.md b/src/README.md
49similarity index 100%81similarity index 100%
50rename from README.md82rename from README.md
51rename to src/README.md83rename to src/README.md
diff --git a/config.yaml b/src/config.yaml
52similarity index 100%84similarity index 100%
53rename from config.yaml85rename from config.yaml
54rename to src/config.yaml86rename to src/config.yaml
diff --git a/copyright b/src/copyright
55similarity index 100%87similarity index 100%
56rename from copyright88rename from copyright
57rename to src/copyright89rename to src/copyright
diff --git a/icon.svg b/src/icon.svg
58similarity index 100%90similarity index 100%
59rename from icon.svg91rename from icon.svg
60rename to src/icon.svg92rename to src/icon.svg
diff --git a/layer.yaml b/src/layer.yaml
61similarity index 100%93similarity index 100%
62rename from layer.yaml94rename from layer.yaml
63rename to src/layer.yaml95rename to src/layer.yaml
diff --git a/metadata.yaml b/src/metadata.yaml
64similarity index 100%96similarity index 100%
65rename from metadata.yaml97rename from metadata.yaml
66rename to src/metadata.yaml98rename to src/metadata.yaml
diff --git a/reactive/prometheus_blackbox_exporter.py b/src/reactive/prometheus_blackbox_exporter.py
67similarity index 100%99similarity index 100%
68rename from reactive/prometheus_blackbox_exporter.py100rename from reactive/prometheus_blackbox_exporter.py
69rename to src/reactive/prometheus_blackbox_exporter.py101rename to src/reactive/prometheus_blackbox_exporter.py
diff --git a/requirements.txt b/src/requirements.txt
70similarity index 100%102similarity index 100%
71rename from requirements.txt103rename from requirements.txt
72rename to src/requirements.txt104rename to src/requirements.txt
diff --git a/templates/blackbox.yaml.j2 b/src/templates/blackbox.yaml.j2
73similarity index 100%105similarity index 100%
74rename from templates/blackbox.yaml.j2106rename from templates/blackbox.yaml.j2
75rename to src/templates/blackbox.yaml.j2107rename to src/templates/blackbox.yaml.j2
diff --git a/tests/functional/requirements.txt b/src/tests/functional/requirements.txt
76similarity index 100%108similarity index 100%
77rename from tests/functional/requirements.txt109rename from tests/functional/requirements.txt
78rename to src/tests/functional/requirements.txt110rename to src/tests/functional/requirements.txt
diff --git a/tests/functional/tests/__init__.py b/src/tests/functional/tests/__init__.py
79similarity index 100%111similarity index 100%
80rename from tests/functional/tests/__init__.py112rename from tests/functional/tests/__init__.py
81rename to src/tests/functional/tests/__init__.py113rename to src/tests/functional/tests/__init__.py
diff --git a/tests/functional/tests/bundles/bionic.yaml b/src/tests/functional/tests/bundles/bionic.yaml
82similarity index 100%114similarity index 100%
83rename from tests/functional/tests/bundles/bionic.yaml115rename from tests/functional/tests/bundles/bionic.yaml
84rename to src/tests/functional/tests/bundles/bionic.yaml116rename to src/tests/functional/tests/bundles/bionic.yaml
diff --git a/tests/functional/tests/bundles/focal.yaml b/src/tests/functional/tests/bundles/focal.yaml
85similarity index 100%117similarity index 100%
86rename from tests/functional/tests/bundles/focal.yaml118rename from tests/functional/tests/bundles/focal.yaml
87rename to src/tests/functional/tests/bundles/focal.yaml119rename to src/tests/functional/tests/bundles/focal.yaml
diff --git a/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
88similarity index 100%120similarity index 100%
89rename from tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2121rename from tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
90rename to src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2122rename to src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
diff --git a/tests/functional/tests/bundles/xenial.yaml b/src/tests/functional/tests/bundles/xenial.yaml
91similarity index 100%123similarity index 100%
92rename from tests/functional/tests/bundles/xenial.yaml124rename from tests/functional/tests/bundles/xenial.yaml
93rename to src/tests/functional/tests/bundles/xenial.yaml125rename to src/tests/functional/tests/bundles/xenial.yaml
diff --git a/tests/functional/tests/test_prometheus_blackbox_exporter.py b/src/tests/functional/tests/test_prometheus_blackbox_exporter.py
94similarity index 100%126similarity index 100%
95rename from tests/functional/tests/test_prometheus_blackbox_exporter.py127rename from tests/functional/tests/test_prometheus_blackbox_exporter.py
96rename to src/tests/functional/tests/test_prometheus_blackbox_exporter.py128rename to src/tests/functional/tests/test_prometheus_blackbox_exporter.py
diff --git a/tests/functional/tests/tests.yaml b/src/tests/functional/tests/tests.yaml
97similarity index 100%129similarity index 100%
98rename from tests/functional/tests/tests.yaml130rename from tests/functional/tests/tests.yaml
99rename to src/tests/functional/tests/tests.yaml131rename to src/tests/functional/tests/tests.yaml
diff --git a/src/tests/unit/requirements.txt b/src/tests/unit/requirements.txt
100new file mode 100644132new file mode 100644
index 0000000..4ebc8ae
--- /dev/null
+++ b/src/tests/unit/requirements.txt
@@ -0,0 +1 @@
1coverage
diff --git a/src/tox.ini b/src/tox.ini
0new file mode 1006442new file mode 100644
index 0000000..9cd7d44
--- /dev/null
+++ b/src/tox.ini
@@ -0,0 +1,69 @@
1[tox]
2skipsdist=True
3skip_missing_interpreters = True
4envlist = lint, unit, func
5
6[testenv]
7basepython = python3
8setenv =
9 PYTHONPATH = {toxinidir}:{toxinidir}/lib/:{toxinidir}/hooks/
10passenv =
11 HOME
12 PATH
13 CHARM_BUILD_DIR
14 PYTEST_KEEP_MODEL
15 PYTEST_CLOUD_NAME
16 PYTEST_CLOUD_REGION
17 PYTEST_MODEL
18 MODEL_SETTINGS
19 HTTP_PROXY
20 HTTPS_PROXY
21 NO_PROXY
22 SNAP_HTTP_PROXY
23 SNAP_HTTPS_PROXY
24
25[testenv:lint]
26commands =
27 flake8
28#TODO black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
29deps =
30 black
31 flake8
32 flake8-docstrings
33 flake8-import-order
34 pep8-naming
35 flake8-colors
36
37[flake8]
38exclude =
39 .git,
40 __pycache__,
41 .tox,
42 charmhelpers,
43 mod,
44 .build
45
46#max-line-length = 88
47max-complexity = 10
48
49# From previous tox.ini
50max-line-length = 120
51import-order-style = google
52
53[testenv:black]
54commands =
55 black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
56deps =
57 black
58
59[testenv:unit]
60commands =
61 coverage run -m unittest discover -s {toxinidir}/tests/unit -v
62 coverage report --omit tests/*,mod/*,.tox/*
63 coverage html --omit tests/*,mod/*,.tox/*
64deps = -r{toxinidir}/tests/unit/requirements.txt
65
66[testenv:func]
67changedir = {toxinidir}/tests/functional
68commands = functest-run-suite {posargs}
69deps = -r{toxinidir}/tests/functional/requirements.txt
diff --git a/tox.ini b/tox.ini
0deleted file mode 10064470deleted file mode 100644
index 1859695..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,65 +0,0 @@
1[tox]
2skipsdist=True
3envlist = unit, functional
4skip_missing_interpreters = True
5
6[testenv]
7basepython = python3
8setenv =
9 PYTHONPATH = .
10passenv =
11 HOME
12 CHARM_BUILD_DIR
13 MODEL_SETTINGS
14
15[testenv:unit]
16commands = pytest -v \
17 --ignore {toxinidir}/tests/ \
18 --ignore {toxinidir}/interfaces \
19 --ignore {toxinidir}/layers \
20 --cov=lib \
21 --cov=actions \
22 --cov-report=term \
23 --cov-report=annotate:report/unit/coverage-annotated \
24 --cov-report=html:report/unit/coverage-html \
25 --html=report/unit/tests/index.html \
26 --junitxml=report/unit/junit.xml
27deps = -r{toxinidir}/tests/unit_tests/requirements.txt
28 -r{toxinidir}/tests/requirements.txt
29setenv = PYTHONPATH={toxinidir}/lib
30
31[testenv:func]
32changedir = {toxinidir}/tests/functional
33commands = functest-run-suite --keep-model
34deps = -r{toxinidir}/tests/functional/requirements.txt
35
36[testenv:lint]
37commands = flake8 --tee
38deps =
39 flake8
40 flake8-colors
41 flake8-docstrings
42 flake8-import-order
43 pep8-naming
44
45[flake8]
46exclude =
47 .git,
48 __pycache__,
49 .tox,
50 layers,
51 interfaces,
52max-line-length = 120
53max-complexity = 10
54import-order-style = google
55
56[isort]
57order_by_type = true
58from_first = true
59line_length = 120
60
61[pytest]
62markers =
63 deploy: mark deployment tests to allow running w/o redeploy
64filterwarnings =
65 ignore::DeprecationWarning

Subscribers

People subscribed via source and target branches

to all changes: