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
1diff --git a/.gitignore b/.gitignore
2index 9f8a821..6f1f367 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -1,32 +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-.unit-state.db
39-src/.unit-state.db
40-
41 # version data
42 repo-info
43+version
44
45+# Python builds
46+deb_dist/
47+dist/
48
49-# reports
50-report/*
51-src/report/*
52-
53-# virtual env
54-venv/*
55+# Snaps
56+*.snap
57
58-# builds
59-builds/*
60\ No newline at end of file
61+# Builds
62+.build/
63\ No newline at end of file
64diff --git a/Makefile b/Makefile
65index a74bb64..dc0b96f 100644
66--- a/Makefile
67+++ b/Makefile
68@@ -1,59 +1,82 @@
69-PROJECTPATH = $(dir $(realpath $(MAKEFILE_LIST)))
70-LAYERS_DIR = $(PROJECTPATH)/layers
71-INTERFACES_DIR = $(PROJECTPATH)/interfaces
72+PYTHON := /usr/bin/python3
73
74+PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
75 ifndef CHARM_BUILD_DIR
76- CHARM_BUILD_DIR := $(PROJECTPATH)
77- $(warning Warning CHARM_BUILD_DIR was not set, defaulting to $(CHARM_BUILD_DIR))
78+ CHARM_BUILD_DIR=${PROJECTPATH}.build
79 endif
80+ifndef CHARM_LAYERS_DIR
81+ CHARM_LAYERS_DIR=${PROJECTPATH}/layers
82+endif
83+ifndef CHARM_INTERFACES_DIR
84+ CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
85+endif
86+METADATA_FILE="src/metadata.yaml"
87+CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
88
89 help:
90 @echo "This project supports the following targets"
91 @echo ""
92 @echo " make help - show this text"
93+ @echo " make clean - remove unneeded files"
94 @echo " make submodules - make sure that the submodules are up-to-date"
95- @echo " make lint - run flake8"
96- @echo " make test - run the functional tests, unittests and lint"
97- @echo " make unittest - run the tests defined in the unittest subdirectory"
98+ @echo " make submodules-update - update submodules to latest changes on remote branch"
99+ @echo " make build - build the charm"
100+ @echo " make release - run clean, submodules, and build targets"
101+ @echo " make lint - run flake8 and black --check"
102+ @echo " make black - run black and reformat files"
103+ @echo " make proof - run charm proof"
104+ @echo " make unittests - run the tests defined in the unittest subdirectory"
105 @echo " make functional - run the tests defined in the functional subdirectory"
106- @echo " make release - build the charm"
107- @echo " make clean - remove unneeded files"
108+ @echo " make test - run lint, proof, unittests and functional targets"
109 @echo ""
110
111+clean:
112+ @echo "Cleaning files"
113+ @git clean -ffXd -e '!.idea'
114+ @echo "Cleaning existing build"
115+ @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
116+
117 submodules:
118- @echo "Cloning submodules"
119- @git submodule update --init --recursive
120+ # @echo "Cloning submodules"
121+ # @git submodule update --init --recursive
122+ @echo "No submodules. Skipping"
123+
124+submodules-update:
125+ # @echo "Pulling latest updates for submodules"
126+ # @git submodule update --init --recursive --remote --merge
127+ @echo "No submodules. Skipping"
128+
129+build:
130+ @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
131+ @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
132+ @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \
133+ TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/
134+
135+release: clean build
136+ @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
137
138 lint:
139- @echo "Running flake8"
140+ @echo "Running lint checks"
141 @cd src && tox -e lint
142
143-test: lint unittest functional
144+black:
145+ @echo "Reformat files with black"
146+ @cd src && tox -e black
147
148-functional: build
149- @cd src && PYTEST_KEEP_MODEL=$(PYTEST_KEEP_MODEL) \
150- PYTEST_CLOUD_NAME=$(PYTEST_CLOUD_NAME) \
151- PYTEST_CLOUD_REGION=$(PYTEST_CLOUD_REGION) \
152- tox -e functional
153+proof:
154+ @echo "Running charm proof"
155+ @charm proof src
156
157-unittest:
158+unittests:
159+ @echo "Running unit tests"
160 @cd src && tox -e unit
161
162-build:
163- @echo "Building charm to base directory $(CHARM_BUILD_DIR)"
164- @-git describe --tags > ./repo-info
165- @CHARM_LAYERS_DIR=$(LAYERS_DIR) CHARM_INTERFACES_DIR=$(INTERFACES_DIR) TERM=linux\
166- charm build --output-dir $(CHARM_BUILD_DIR) $(PROJECTPATH)/src --force
167-
168-release: clean build
169- @echo "Charm is built at $(CHARM_BUILD_DIR)/builds"
170+functional: build
171+ @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
172+ @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
173
174-clean:
175- @echo "Cleaning files"
176- @find $(PROJECTPATH)/src -iname __pycache__ -exec rm -r {} +
177- @if [ -d $(CHARM_BUILD_DIR)/builds ] ; then rm -r $(CHARM_BUILD_DIR)/builds ; fi
178- @if [ -d $(PROJECTPATH)/src/.tox ] ; then rm -r $(PROJECTPATH)/src/.tox ; fi
179- @if [ -d $(PROJECTPATH)/src/.pytest_cache ] ; then rm -r $(PROJECTPATH)/src/.pytest_cache ; fi
180+test: lint proof unittests functional
181+ @echo "Tests completed for charm ${CHARM_NAME}."
182
183 # The targets below don't depend on a file
184-.PHONY: lint test unittest functional build release clean help submodules
185+.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
186diff --git a/src/copyright b/src/copyright
187new file mode 100644
188index 0000000..c80db95
189--- /dev/null
190+++ b/src/copyright
191@@ -0,0 +1,16 @@
192+Format: http://dep.debian.net/deps/dep5/
193+
194+Files: *
195+Copyright: Copyright 2016, Canonical Ltd.
196+License: GPL-3
197+ This program is free software: you can redistribute it and/or modify
198+ it under the terms of the GNU General Public License version 3, as
199+ published by the Free Software Foundation.
200+ .
201+ This program is distributed in the hope that it will be useful,
202+ but WITHOUT ANY WARRANTY; without even the implied warranties of
203+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
204+ PURPOSE. See the GNU General Public License for more details.
205+ .
206+ You should have received a copy of the GNU General Public License
207+ along with this program. If not, see <http://www.gnu.org/licenses/>.
208diff --git a/icon.svg b/src/icon.svg
209similarity index 100%
210rename from icon.svg
211rename to src/icon.svg
212diff --git a/src/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py
213index 84b2cd3..68e4f28 100644
214--- a/src/tests/functional/test_deploy.py
215+++ b/src/tests/functional/test_deploy.py
216@@ -14,10 +14,11 @@ import websockets
217 pytestmark = pytest.mark.asyncio
218
219 charm_build_dir = os.getenv("CHARM_BUILD_DIR", "..").rstrip("/")
220+charm_name = os.getenv("CHARM_NAME", "sysconfig")
221
222 series = ["focal", "bionic", "xenial"]
223
224-sources = [("local", "{}/builds/sysconfig".format(charm_build_dir))]
225+sources = [("local", "{}/{}".format(charm_build_dir, charm_name))]
226
227 TIMEOUT = 600
228 MODEL_ACTIVE_TIMEOUT = 10
229diff --git a/src/tox.ini b/src/tox.ini
230index f932ee3..129eaca 100644
231--- a/src/tox.ini
232+++ b/src/tox.ini
233@@ -1,41 +1,31 @@
234 [tox]
235 skipsdist=True
236-envlist = unit, functional
237 skip_missing_interpreters = True
238+envlist = lint, unit, func
239
240 [testenv]
241 basepython = python3
242 setenv =
243- PYTHONPATH = .
244-
245-[testenv:unit]
246-commands = pytest -v --ignore {toxinidir}/tests/functional \
247- --cov=lib \
248- --cov=reactive \
249- --cov=actions \
250- --cov-report=term \
251- --cov-report=annotate:report/annotated \
252- --cov-report=html:report/html
253-deps = -r{toxinidir}/tests/unit/requirements.txt
254- -r{toxinidir}/requirements.txt
255-setenv = PYTHONPATH={toxinidir}/lib
256-
257-[testenv:functional]
258+ PYTHONPATH = {toxinidir}:{toxinidir}/lib/:{toxinidir}/hooks/
259 passenv =
260 HOME
261- CHARM_BUILD_DIR
262 PATH
263+ CHARM_BUILD_DIR
264 PYTEST_KEEP_MODEL
265 PYTEST_CLOUD_NAME
266 PYTEST_CLOUD_REGION
267-commands = pytest -v --ignore {toxinidir}/tests/unit
268-deps = -r{toxinidir}/tests/functional/requirements.txt
269- -r{toxinidir}/requirements.txt
270+ PYTEST_MODEL
271+ MODEL_SETTINGS
272+ HTTP_PROXY
273+ HTTPS_PROXY
274+ NO_PROXY
275+ SNAP_HTTP_PROXY
276+ SNAP_HTTPS_PROXY
277
278 [testenv:lint]
279 commands =
280- black --check reactive lib tests
281 flake8
282+ black --check --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
283 deps =
284 black
285 flake8
286@@ -45,10 +35,37 @@ deps =
287 flake8-colors
288
289 [flake8]
290-ignore = D100,D103 # Missing docstring in public module/function
291+ignore = D100,D103
292 exclude =
293 .git,
294 __pycache__,
295 .tox,
296+ charmhelpers,
297+ mod,
298+ .build
299+
300 max-line-length = 88
301 max-complexity = 10
302+
303+[testenv:black]
304+commands =
305+ black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" .
306+deps =
307+ black
308+
309+[testenv:unit]
310+commands =
311+ pytest -v --ignore {toxinidir}/tests/functional \
312+ --cov=lib \
313+ --cov=reactive \
314+ --cov=actions \
315+ --cov=hooks \
316+ --cov=src \
317+ --cov-report=term \
318+ --cov-report=annotate:report/annotated \
319+ --cov-report=html:report/html
320+deps = -r{toxinidir}/tests/unit/requirements.txt
321+
322+[testenv:func]
323+commands = pytest -v --ignore {toxinidir}/tests/unit
324+deps = -r{toxinidir}/tests/functional/requirements.txt

Subscribers

People subscribed via source and target branches

to all changes: