Merge ~aluria/charm-sysconfig:makefile-20.08 into charm-sysconfig:master

Proposed by Alvaro Uria
Status: Merged
Approved by: Xav Paice
Approved revision: 00a7650de5200c2e856399dab290deb0a31c1806
Merged at revision: 128b6dbe50e5f5f2d460b05e15c64116a61ec3f0
Proposed branch: ~aluria/charm-sysconfig:makefile-20.08
Merge into: charm-sysconfig:master
Diff against target: 324 lines (+139/-73)
5 files modified
.gitignore (+24/-15)
Makefile (+58/-35)
src/copyright (+16/-0)
src/tests/functional/test_deploy.py (+2/-1)
src/tox.ini (+39/-22)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
Giuseppe Petralia Approve
Review via email: mp+388722@code.launchpad.net

Commit message

Standardize Makefile and tox.ini

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

All tests pass (I run make test). Changes look good. Thanks

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

lgtm.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 128b6dbe50e5f5f2d460b05e15c64116a61ec3f0

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
index 9f8a821..6f1f367 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,32 +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
10.coverage24.idea/
1125
12# vi26# vi
13.*.swp27.*.swp
1428
15# pycharm
16.idea/
17.unit-state.db
18src/.unit-state.db
19
20# version data29# version data
21repo-info30repo-info
31version
2232
33# Python builds
34deb_dist/
35dist/
2336
24# reports37# Snaps
25report/*38*.snap
26src/report/*
27
28# virtual env
29venv/*
3039
31# builds
32builds/*
33\ No newline at end of file40\ No newline at end of file
41# Builds
42.build/
34\ No newline at end of file43\ No newline at end of file
diff --git a/Makefile b/Makefile
index a74bb64..dc0b96f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,59 +1,82 @@
1PROJECTPATH = $(dir $(realpath $(MAKEFILE_LIST)))1PYTHON := /usr/bin/python3
2LAYERS_DIR = $(PROJECTPATH)/layers
3INTERFACES_DIR = $(PROJECTPATH)/interfaces
42
3PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
5ifndef CHARM_BUILD_DIR4ifndef CHARM_BUILD_DIR
6 CHARM_BUILD_DIR := $(PROJECTPATH)5 CHARM_BUILD_DIR=${PROJECTPATH}.build
7 $(warning Warning CHARM_BUILD_DIR was not set, defaulting to $(CHARM_BUILD_DIR))
8endif6endif
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}')
915
10help:16help:
11 @echo "This project supports the following targets"17 @echo "This project supports the following targets"
12 @echo ""18 @echo ""
13 @echo " make help - show this text"19 @echo " make help - show this text"
20 @echo " make clean - remove unneeded files"
14 @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"
15 @echo " make lint - run flake8"22 @echo " make submodules-update - update submodules to latest changes on remote branch"
16 @echo " make test - run the functional tests, unittests and lint"23 @echo " make build - build the charm"
17 @echo " make unittest - run the tests defined in the unittest subdirectory"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"
18 @echo " make functional - run the tests defined in the functional subdirectory"29 @echo " make functional - run the tests defined in the functional subdirectory"
19 @echo " make release - build the charm"30 @echo " make test - run lint, proof, unittests and functional targets"
20 @echo " make clean - remove unneeded files"
21 @echo ""31 @echo ""
2232
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
23submodules:39submodules:
24 @echo "Cloning submodules"40 # @echo "Cloning submodules"
25 @git submodule update --init --recursive41 # @git submodule update --init --recursive
42 @echo "No submodules. Skipping"
43
44submodules-update:
45 # @echo "Pulling latest updates for submodules"
46 # @git submodule update --init --recursive --remote --merge
47 @echo "No submodules. Skipping"
48
49build:
50 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
51 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
52 @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \
53 TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/
54
55release: clean build
56 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
2657
27lint:58lint:
28 @echo "Running flake8"59 @echo "Running lint checks"
29 @cd src && tox -e lint60 @cd src && tox -e lint
3061
31test: lint unittest functional62black:
63 @echo "Reformat files with black"
64 @cd src && tox -e black
3265
33functional: build66proof:
34 @cd src && PYTEST_KEEP_MODEL=$(PYTEST_KEEP_MODEL) \67 @echo "Running charm proof"
35 PYTEST_CLOUD_NAME=$(PYTEST_CLOUD_NAME) \68 @charm proof src
36 PYTEST_CLOUD_REGION=$(PYTEST_CLOUD_REGION) \
37 tox -e functional
3869
39unittest:70unittests:
71 @echo "Running unit tests"
40 @cd src && tox -e unit72 @cd src && tox -e unit
4173
42build:74functional: build
43 @echo "Building charm to base directory $(CHARM_BUILD_DIR)"75 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
44 @-git describe --tags > ./repo-info76 @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
45 @CHARM_LAYERS_DIR=$(LAYERS_DIR) CHARM_INTERFACES_DIR=$(INTERFACES_DIR) TERM=linux\
46 charm build --output-dir $(CHARM_BUILD_DIR) $(PROJECTPATH)/src --force
47
48release: clean build
49 @echo "Charm is built at $(CHARM_BUILD_DIR)/builds"
5077
51clean:78test: lint proof unittests functional
52 @echo "Cleaning files"79 @echo "Tests completed for charm ${CHARM_NAME}."
53 @find $(PROJECTPATH)/src -iname __pycache__ -exec rm -r {} +
54 @if [ -d $(CHARM_BUILD_DIR)/builds ] ; then rm -r $(CHARM_BUILD_DIR)/builds ; fi
55 @if [ -d $(PROJECTPATH)/src/.tox ] ; then rm -r $(PROJECTPATH)/src/.tox ; fi
56 @if [ -d $(PROJECTPATH)/src/.pytest_cache ] ; then rm -r $(PROJECTPATH)/src/.pytest_cache ; fi
5780
58# The targets below don't depend on a file81# The targets below don't depend on a file
59.PHONY: lint test unittest functional build release clean help submodules82.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
diff --git a/src/copyright b/src/copyright
60new file mode 10064483new file mode 100644
index 0000000..c80db95
--- /dev/null
+++ b/src/copyright
@@ -0,0 +1,16 @@
1Format: http://dep.debian.net/deps/dep5/
2
3Files: *
4Copyright: Copyright 2016, Canonical Ltd.
5License: GPL-3
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 3, as
8 published by the Free Software Foundation.
9 .
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14 .
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/icon.svg b/src/icon.svg
0similarity index 100%17similarity index 100%
1rename from icon.svg18rename from icon.svg
2rename to src/icon.svg19rename to src/icon.svg
diff --git a/src/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py
index 84b2cd3..68e4f28 100644
--- a/src/tests/functional/test_deploy.py
+++ b/src/tests/functional/test_deploy.py
@@ -14,10 +14,11 @@ import websockets
14pytestmark = pytest.mark.asyncio14pytestmark = pytest.mark.asyncio
1515
16charm_build_dir = os.getenv("CHARM_BUILD_DIR", "..").rstrip("/")16charm_build_dir = os.getenv("CHARM_BUILD_DIR", "..").rstrip("/")
17charm_name = os.getenv("CHARM_NAME", "sysconfig")
1718
18series = ["focal", "bionic", "xenial"]19series = ["focal", "bionic", "xenial"]
1920
20sources = [("local", "{}/builds/sysconfig".format(charm_build_dir))]21sources = [("local", "{}/{}".format(charm_build_dir, charm_name))]
2122
22TIMEOUT = 60023TIMEOUT = 600
23MODEL_ACTIVE_TIMEOUT = 1024MODEL_ACTIVE_TIMEOUT = 10
diff --git a/src/tox.ini b/src/tox.ini
index f932ee3..129eaca 100644
--- a/src/tox.ini
+++ b/src/tox.ini
@@ -1,41 +1,31 @@
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 -r{toxinidir}/requirements.txt
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
33 -r{toxinidir}/requirements.txt19 HTTP_PROXY
20 HTTPS_PROXY
21 NO_PROXY
22 SNAP_HTTP_PROXY
23 SNAP_HTTPS_PROXY
3424
35[testenv:lint]25[testenv:lint]
36commands =26commands =
37 black --check reactive lib tests
38 flake827 flake8
28 black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
39deps =29deps =
40 black30 black
41 flake831 flake8
@@ -45,10 +35,37 @@ deps =
45 flake8-colors35 flake8-colors
4636
47[flake8]37[flake8]
48ignore = D100,D103 # Missing docstring in public module/function38ignore = D100,D103
49exclude =39exclude =
50 .git,40 .git,
51 __pycache__,41 __pycache__,
52 .tox,42 .tox,
43 charmhelpers,
44 mod,
45 .build
46
53max-line-length = 8847max-line-length = 88
54max-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

to all changes: