Merge ~sudeephb/juju-lint:snap-template into juju-lint:master

Proposed by Sudeep Bhandari
Status: Merged
Approved by: Robert Gildein
Approved revision: 358294dcdf02eb2619dfd3d06a316d55b4695daf
Merged at revision: 18b22675080effa4ee7b2962a1edf0370ad3bf5e
Proposed branch: ~sudeephb/juju-lint:snap-template
Merge into: juju-lint:master
Diff against target: 314 lines (+95/-103)
6 files modified
.pre-commit-config.yaml (+9/-2)
Makefile (+8/-2)
pyproject.toml (+35/-0)
rename.sh (+5/-1)
tests/functional/conftest.py (+3/-3)
tox.ini (+35/-95)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack continuous-integration Approve
Robert Gildein Approve
Eric Chen Approve
BootStack Reviewers Pending
Review via email: mp+432609@code.launchpad.net

Commit message

Apply snap template from bootstack-charms-spec

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
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eric Chen (eric-chen) :
review: Needs Information
Revision history for this message
Eric Chen (eric-chen) wrote :

LGTM, just a little question inline

review: Needs Information
Revision history for this message
Sudeep Bhandari (sudeephb) wrote :

> LGTM, just a little question inline
I have addressed the comment. The indentations are now consistent.

Revision history for this message
Eric Chen (eric-chen) :
review: Approve
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Gildein (rgildein) wrote :

I tested the Makefile and tox.ini. LGTM

review: Approve
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 18b22675080effa4ee7b2962a1edf0370ad3bf5e

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
2index c327de3..dbf6054 100644
3--- a/.pre-commit-config.yaml
4+++ b/.pre-commit-config.yaml
5@@ -1,6 +1,10 @@
6+# This is a template `.pre-commit-config.yaml` file for snaps
7+# This file is managed by bootstack-charms-spec and should not be modified
8+# within individual snap repos. https://launchpad.net/bootstack-charms-spec
9+
10 repos:
11 - repo: https://github.com/pre-commit/pre-commit-hooks
12- rev: v4.0.1
13+ rev: v4.3.0
14 hooks:
15 - id: check-executables-have-shebangs
16 - id: check-merge-conflict
17@@ -8,12 +12,15 @@ repos:
18 - id: trailing-whitespace
19 - id: check-added-large-files
20 - id: check-json
21+ # Note(sudeephb): Using `--unsafe` with check-yaml to allow using `!include`.
22+ # More info about `--unsafe`:
23+ # https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md?plain=1#L85
24 - id: check-yaml
25 args: ["--unsafe"]
26 - repo: local
27 hooks:
28 - id: lint
29 name: lint
30- entry: tox -e lint
31+ entry: make lint
32 language: system
33 types: [ python ]
34diff --git a/Makefile b/Makefile
35index 7c33d38..887786e 100644
36--- a/Makefile
37+++ b/Makefile
38@@ -1,3 +1,9 @@
39+# This is a template `Makefile` file for snaps
40+# This file is managed by bootstack-charms-spec and should not be modified
41+# within individual snap repos. https://launchpad.net/bootstack-charms-spec
42+
43+PYTHON := /usr/bin/python3
44+
45 PROJECTPATH=$(dir $(realpath ${MAKEFILE_LIST}))
46 SNAP_NAME=$(shell cat ${PROJECTPATH}/snap/snapcraft.yaml | grep -E '^name:' | awk '{print $$2}')
47 SNAP_FILE=${PROJECTPATH}/${SNAP_NAME}.snap
48@@ -41,7 +47,7 @@ clean:
49 @echo "Cleaning snap"
50 @snapcraft clean --use-lxd
51 @echo "Cleaning existing snap builds"
52- @find . -name "*.snap" -delete
53+ @rm -rf ${SNAP_FILE}
54
55 dev-environment:
56 @echo "Creating virtualenv and installing pre-commit"
57@@ -49,7 +55,7 @@ dev-environment:
58
59 functional: build
60 @echo "Executing functional tests using built snap"
61- @JUJULINT_TEST_SNAP=${SNAP_FILE} tox -e func -- ${FUNC_ARGS}
62+ @TEST_SNAP=${SNAP_FILE} tox -e func -- ${FUNC_ARGS}
63
64 pre-commit:
65 @tox -e pre-commit
66diff --git a/pyproject.toml b/pyproject.toml
67new file mode 100644
68index 0000000..c58e8e6
69--- /dev/null
70+++ b/pyproject.toml
71@@ -0,0 +1,35 @@
72+# This is a template `pyproject.toml` file for snaps
73+# This file is managed by bootstack-charms-spec and should not be modified
74+# within individual snap repos. https://launchpad.net/bootstack-charms-spec
75+
76+[tool.flake8]
77+ignore = ["C901", "D100", "D101", "D102", "D103", "W503", "W504"]
78+exclude = ['.eggs', '.git', '.tox', '.venv', '.build', 'report']
79+max-line-length = 120
80+max-complexity = 10
81+
82+[tool.black]
83+line-length = 88
84+exclude = '''
85+/(
86+ | .eggs
87+ | .git
88+ | .tox
89+ | .venv
90+ | .build
91+ | report
92+)/
93+'''
94+
95+[tool.isort]
96+profile = "black"
97+skip_glob = '''
98+/(
99+ | .eggs
100+ | .git
101+ | .tox
102+ | .venv
103+ | .build
104+ | report
105+)/
106+'''
107diff --git a/rename.sh b/rename.sh
108index f7316d0..6d645e1 100755
109--- a/rename.sh
110+++ b/rename.sh
111@@ -1,4 +1,8 @@
112 #!/bin/bash
113+# This is a template `rename.sh` file for snaps
114+# This file is managed by bootstack-charms-spec and should not be modified
115+# within individual snap repos. https://launchpad.net/bootstack-charms-spec
116+
117 snap=$(grep -E "^name:" snap/snapcraft.yaml | awk '{print $2}')
118 echo "renaming ${snap}_*.snap to ${snap}.snap"
119 echo -n "pwd: "
120@@ -9,5 +13,5 @@ if [[ -e "${snap}.snap" ]];
121 then
122 rm "${snap}.snap"
123 fi
124-echo "Renaming charm here."
125+echo "Renaming snap here."
126 mv ${snap}_*.snap ${snap}.snap
127diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
128index 7c215c1..fdbd012 100644
129--- a/tests/functional/conftest.py
130+++ b/tests/functional/conftest.py
131@@ -20,10 +20,10 @@ def pytest_configure(config):
132 def install_package():
133 """Install the package to the system and cleanup afterwards.
134
135- Depending on the environment variable JUJULINT_TEST_SNAP,
136+ Depending on the environment variable TEST_SNAP,
137 it will install the snap or the python package.
138 """
139- jujulint_test_snap = os.environ.get("JUJULINT_TEST_SNAP", None)
140+ jujulint_test_snap = os.environ.get("TEST_SNAP", None)
141 if jujulint_test_snap:
142 logging.info(f"Installing {jujulint_test_snap}")
143 assert os.path.isfile(jujulint_test_snap)
144@@ -63,7 +63,7 @@ def basedir():
145 This will ease testing the rules files that we ship
146 with the juju-lint snap.
147 """
148- if os.environ.get("JUJULINT_TEST_SNAP", None):
149+ if os.environ.get("TEST_SNAP", None):
150 basedir = "/snap/juju-lint/current/"
151 else:
152 basedir = os.getcwd()
153diff --git a/tox.ini b/tox.ini
154index 08183e2..db766fe 100644
155--- a/tox.ini
156+++ b/tox.ini
157@@ -1,14 +1,6 @@
158-[flake8]
159-exclude =
160- .git,
161- __pycache__,
162- .tox,
163- .eggs,
164- .venv,
165- venv,
166-max-line-length = 120
167-max-complexity = 10
168-ignore = D100, D103, C901, W503
169+# This is a template `tox.ini` file for snaps
170+# This file is managed by bootstack-charms-spec and should not be modified
171+# within individual snap repos. https://launchpad.net/bootstack-charms-spec
172
173 [tox]
174 skipsdist=True
175@@ -18,107 +10,55 @@ skip_missing_interpreters = True
176 [testenv]
177 basepython = python3
178
179-[testenv:unit]
180-deps =
181- -r{toxinidir}/requirements.txt
182- -r{toxinidir}/tests/unit/requirements.txt
183-commands =
184- pytest -vv \
185- --cov=jujulint \
186- --new-first \
187- --last-failed \
188- --last-failed-no-failures all \
189- --cov-fail-under=100 \
190- --cov-report=term-missing \
191- --cov-report=annotate:tests/unit/report/coverage-annotated \
192- --cov-report=html:tests/unit/report/coverage-html \
193- --html=tests/unit/report/index.html \
194- --junitxml=tests/unit/report/junit.xml \
195- --ignore={toxinidir}/tests/functional
196-setenv = PYTHONPATH={toxinidir}
197-
198-[testenv:func]
199-deps = -r{toxinidir}/tests/functional/requirements.txt
200-passenv =
201- JUJULINT_TEST_*
202-commands =
203- pytest -v \
204- --log-cli-level=WARNING \
205- --ignore={toxinidir}/tests/unit \
206- {posargs}
207-
208-[testenv:func-smoke]
209+[testenv:dev-environment]
210+envdir = {toxinidir}/.venv
211 deps =
212+ pre-commit
213+ {[testenv:lint]deps}
214+ {[testenv:unit]deps}
215 {[testenv:func]deps}
216- -r{toxinidir}/requirements.txt
217 commands =
218- pytest -v \
219- --log-cli-level=WARNING \
220- --ignore={toxinidir}/tests/unit \
221- -m smoke
222+ pre-commit install
223
224-[testenv:func-dev]
225-deps =
226- {[testenv:func]deps}
227- -r{toxinidir}/requirements.txt
228-commands =
229- pytest -v \
230- --log-cli-level=WARNING \
231- --ignore={toxinidir}/tests/unit
232+[testenv:pre-commit]
233+envdir = {[testenv:dev-environment]envdir}
234+deps = {[testenv:dev-environment]deps} # ensure that dev-environment is installed
235+commands = pre-commit run --all-files
236
237 [testenv:lint]
238+commands =
239+ pflake8
240+ black --check --diff --color .
241+ isort --check --diff --color .
242 deps =
243 black
244- colorama
245 flake8
246- flake8-colors
247+ pyproject-flake8
248 flake8-docstrings
249- flake8-html
250- isort
251 pep8-naming
252- pyflakes
253-
254-commands =
255- flake8 --color always
256- black --check --diff --color .
257- isort --check-only --diff --color .
258+ flake8-colors
259+ colorama
260+ isort
261
262 [testenv:reformat]
263-deps = {[testenv:lint]deps}
264+envdir = {toxworkdir}/lint
265 commands =
266 black .
267 isort .
268+deps = {[testenv:lint]deps}
269
270-[pytest]
271-filterwarnings =
272- ignore::DeprecationWarning
273-
274-[isort]
275-profile = black
276-skip_glob =
277- .eggs,
278- __pycache__,
279- .git,
280- .tox,
281- .venv,
282- .build,
283- venv,
284- dist,
285- mod,
286- build,
287-
288-[testenv:dev-environment]
289+[testenv:unit]
290+commands = pytest {toxinidir}/tests/unit
291 deps =
292- pre-commit
293- {[testenv:lint]deps}
294- {[testenv:unit]deps}
295- {[testenv:func]deps}
296-envdir = {toxinidir}/.venv
297-commands =
298- pre-commit install
299+ -r {toxinidir}/requirements.txt
300+ -r {toxinidir}/tests/unit/requirements.txt
301+ pytest
302+ pytest-cov
303+setenv = PYTHONPATH={toxinidir}
304
305-[testenv:pre-commit]
306-deps = {[testenv:dev-environment]deps}
307-envdir = {[testenv:dev-environment]envdir}
308+[testenv:func]
309+deps = -r{toxinidir}/tests/functional/requirements.txt
310+passenv =
311+ TEST_*
312 commands =
313- pre-commit run -a
314+ pytest {toxinidir}/tests/functional {posargs:-v}

Subscribers

People subscribed via source and target branches