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 (community) 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
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c327de3..dbf6054 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,10 @@
1# This is a template `.pre-commit-config.yaml` file for snaps
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual snap repos. https://launchpad.net/bootstack-charms-spec
4
1repos:5repos:
2 - repo: https://github.com/pre-commit/pre-commit-hooks6 - repo: https://github.com/pre-commit/pre-commit-hooks
3 rev: v4.0.17 rev: v4.3.0
4 hooks:8 hooks:
5 - id: check-executables-have-shebangs9 - id: check-executables-have-shebangs
6 - id: check-merge-conflict10 - id: check-merge-conflict
@@ -8,12 +12,15 @@ repos:
8 - id: trailing-whitespace12 - id: trailing-whitespace
9 - id: check-added-large-files13 - id: check-added-large-files
10 - id: check-json14 - id: check-json
15 # Note(sudeephb): Using `--unsafe` with check-yaml to allow using `!include`.
16 # More info about `--unsafe`:
17 # https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md?plain=1#L85
11 - id: check-yaml18 - id: check-yaml
12 args: ["--unsafe"]19 args: ["--unsafe"]
13 - repo: local20 - repo: local
14 hooks:21 hooks:
15 - id: lint22 - id: lint
16 name: lint23 name: lint
17 entry: tox -e lint24 entry: make lint
18 language: system25 language: system
19 types: [ python ]26 types: [ python ]
diff --git a/Makefile b/Makefile
index 7c33d38..887786e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,9 @@
1# This is a template `Makefile` file for snaps
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual snap repos. https://launchpad.net/bootstack-charms-spec
4
5PYTHON := /usr/bin/python3
6
1PROJECTPATH=$(dir $(realpath ${MAKEFILE_LIST}))7PROJECTPATH=$(dir $(realpath ${MAKEFILE_LIST}))
2SNAP_NAME=$(shell cat ${PROJECTPATH}/snap/snapcraft.yaml | grep -E '^name:' | awk '{print $$2}')8SNAP_NAME=$(shell cat ${PROJECTPATH}/snap/snapcraft.yaml | grep -E '^name:' | awk '{print $$2}')
3SNAP_FILE=${PROJECTPATH}/${SNAP_NAME}.snap9SNAP_FILE=${PROJECTPATH}/${SNAP_NAME}.snap
@@ -41,7 +47,7 @@ clean:
41 @echo "Cleaning snap"47 @echo "Cleaning snap"
42 @snapcraft clean --use-lxd48 @snapcraft clean --use-lxd
43 @echo "Cleaning existing snap builds"49 @echo "Cleaning existing snap builds"
44 @find . -name "*.snap" -delete50 @rm -rf ${SNAP_FILE}
4551
46dev-environment:52dev-environment:
47 @echo "Creating virtualenv and installing pre-commit"53 @echo "Creating virtualenv and installing pre-commit"
@@ -49,7 +55,7 @@ dev-environment:
4955
50functional: build56functional: build
51 @echo "Executing functional tests using built snap"57 @echo "Executing functional tests using built snap"
52 @JUJULINT_TEST_SNAP=${SNAP_FILE} tox -e func -- ${FUNC_ARGS}58 @TEST_SNAP=${SNAP_FILE} tox -e func -- ${FUNC_ARGS}
5359
54pre-commit:60pre-commit:
55 @tox -e pre-commit61 @tox -e pre-commit
diff --git a/pyproject.toml b/pyproject.toml
56new file mode 10064462new file mode 100644
index 0000000..c58e8e6
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,35 @@
1# This is a template `pyproject.toml` file for snaps
2# This file is managed by bootstack-charms-spec and should not be modified
3# within individual snap repos. https://launchpad.net/bootstack-charms-spec
4
5[tool.flake8]
6ignore = ["C901", "D100", "D101", "D102", "D103", "W503", "W504"]
7exclude = ['.eggs', '.git', '.tox', '.venv', '.build', 'report']
8max-line-length = 120
9max-complexity = 10
10
11[tool.black]
12line-length = 88
13exclude = '''
14/(
15 | .eggs
16 | .git
17 | .tox
18 | .venv
19 | .build
20 | report
21)/
22'''
23
24[tool.isort]
25profile = "black"
26skip_glob = '''
27/(
28 | .eggs
29 | .git
30 | .tox
31 | .venv
32 | .build
33 | report
34)/
35'''
diff --git a/rename.sh b/rename.sh
index f7316d0..6d645e1 100755
--- a/rename.sh
+++ b/rename.sh
@@ -1,4 +1,8 @@
1#!/bin/bash1#!/bin/bash
2# This is a template `rename.sh` file for snaps
3# This file is managed by bootstack-charms-spec and should not be modified
4# within individual snap repos. https://launchpad.net/bootstack-charms-spec
5
2snap=$(grep -E "^name:" snap/snapcraft.yaml | awk '{print $2}')6snap=$(grep -E "^name:" snap/snapcraft.yaml | awk '{print $2}')
3echo "renaming ${snap}_*.snap to ${snap}.snap"7echo "renaming ${snap}_*.snap to ${snap}.snap"
4echo -n "pwd: "8echo -n "pwd: "
@@ -9,5 +13,5 @@ if [[ -e "${snap}.snap" ]];
9then13then
10 rm "${snap}.snap"14 rm "${snap}.snap"
11fi15fi
12echo "Renaming charm here."16echo "Renaming snap here."
13mv ${snap}_*.snap ${snap}.snap17mv ${snap}_*.snap ${snap}.snap
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 7c215c1..fdbd012 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -20,10 +20,10 @@ def pytest_configure(config):
20def install_package():20def install_package():
21 """Install the package to the system and cleanup afterwards.21 """Install the package to the system and cleanup afterwards.
2222
23 Depending on the environment variable JUJULINT_TEST_SNAP,23 Depending on the environment variable TEST_SNAP,
24 it will install the snap or the python package.24 it will install the snap or the python package.
25 """25 """
26 jujulint_test_snap = os.environ.get("JUJULINT_TEST_SNAP", None)26 jujulint_test_snap = os.environ.get("TEST_SNAP", None)
27 if jujulint_test_snap:27 if jujulint_test_snap:
28 logging.info(f"Installing {jujulint_test_snap}")28 logging.info(f"Installing {jujulint_test_snap}")
29 assert os.path.isfile(jujulint_test_snap)29 assert os.path.isfile(jujulint_test_snap)
@@ -63,7 +63,7 @@ def basedir():
63 This will ease testing the rules files that we ship63 This will ease testing the rules files that we ship
64 with the juju-lint snap.64 with the juju-lint snap.
65 """65 """
66 if os.environ.get("JUJULINT_TEST_SNAP", None):66 if os.environ.get("TEST_SNAP", None):
67 basedir = "/snap/juju-lint/current/"67 basedir = "/snap/juju-lint/current/"
68 else:68 else:
69 basedir = os.getcwd()69 basedir = os.getcwd()
diff --git a/tox.ini b/tox.ini
index 08183e2..db766fe 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,14 +1,6 @@
1[flake8]1# This is a template `tox.ini` file for snaps
2exclude =2# This file is managed by bootstack-charms-spec and should not be modified
3 .git,3# within individual snap repos. https://launchpad.net/bootstack-charms-spec
4 __pycache__,
5 .tox,
6 .eggs,
7 .venv,
8 venv,
9max-line-length = 120
10max-complexity = 10
11ignore = D100, D103, C901, W503
124
13[tox]5[tox]
14skipsdist=True6skipsdist=True
@@ -18,107 +10,55 @@ skip_missing_interpreters = True
18[testenv]10[testenv]
19basepython = python311basepython = python3
2012
21[testenv:unit]13[testenv:dev-environment]
22deps =14envdir = {toxinidir}/.venv
23 -r{toxinidir}/requirements.txt
24 -r{toxinidir}/tests/unit/requirements.txt
25commands =
26 pytest -vv \
27 --cov=jujulint \
28 --new-first \
29 --last-failed \
30 --last-failed-no-failures all \
31 --cov-fail-under=100 \
32 --cov-report=term-missing \
33 --cov-report=annotate:tests/unit/report/coverage-annotated \
34 --cov-report=html:tests/unit/report/coverage-html \
35 --html=tests/unit/report/index.html \
36 --junitxml=tests/unit/report/junit.xml \
37 --ignore={toxinidir}/tests/functional
38setenv = PYTHONPATH={toxinidir}
39
40[testenv:func]
41deps = -r{toxinidir}/tests/functional/requirements.txt
42passenv =
43 JUJULINT_TEST_*
44commands =
45 pytest -v \
46 --log-cli-level=WARNING \
47 --ignore={toxinidir}/tests/unit \
48 {posargs}
49
50[testenv:func-smoke]
51deps =15deps =
16 pre-commit
17 {[testenv:lint]deps}
18 {[testenv:unit]deps}
52 {[testenv:func]deps}19 {[testenv:func]deps}
53 -r{toxinidir}/requirements.txt
54commands =20commands =
55 pytest -v \21 pre-commit install
56 --log-cli-level=WARNING \
57 --ignore={toxinidir}/tests/unit \
58 -m smoke
5922
60[testenv:func-dev]23[testenv:pre-commit]
61deps =24envdir = {[testenv:dev-environment]envdir}
62 {[testenv:func]deps}25deps = {[testenv:dev-environment]deps} # ensure that dev-environment is installed
63 -r{toxinidir}/requirements.txt26commands = pre-commit run --all-files
64commands =
65 pytest -v \
66 --log-cli-level=WARNING \
67 --ignore={toxinidir}/tests/unit
6827
69[testenv:lint]28[testenv:lint]
29commands =
30 pflake8
31 black --check --diff --color .
32 isort --check --diff --color .
70deps =33deps =
71 black34 black
72 colorama
73 flake835 flake8
74 flake8-colors36 pyproject-flake8
75 flake8-docstrings37 flake8-docstrings
76 flake8-html
77 isort
78 pep8-naming38 pep8-naming
79 pyflakes39 flake8-colors
8040 colorama
81commands =41 isort
82 flake8 --color always
83 black --check --diff --color .
84 isort --check-only --diff --color .
8542
86[testenv:reformat]43[testenv:reformat]
87deps = {[testenv:lint]deps}44envdir = {toxworkdir}/lint
88commands =45commands =
89 black .46 black .
90 isort .47 isort .
48deps = {[testenv:lint]deps}
9149
92[pytest]50[testenv:unit]
93filterwarnings =51commands = pytest {toxinidir}/tests/unit
94 ignore::DeprecationWarning
95
96[isort]
97profile = black
98skip_glob =
99 .eggs,
100 __pycache__,
101 .git,
102 .tox,
103 .venv,
104 .build,
105 venv,
106 dist,
107 mod,
108 build,
109
110[testenv:dev-environment]
111deps =52deps =
112 pre-commit53 -r {toxinidir}/requirements.txt
113 {[testenv:lint]deps}54 -r {toxinidir}/tests/unit/requirements.txt
114 {[testenv:unit]deps}55 pytest
115 {[testenv:func]deps}56 pytest-cov
116envdir = {toxinidir}/.venv57setenv = PYTHONPATH={toxinidir}
117commands =
118 pre-commit install
11958
120[testenv:pre-commit]59[testenv:func]
121deps = {[testenv:dev-environment]deps}60deps = -r{toxinidir}/tests/functional/requirements.txt
122envdir = {[testenv:dev-environment]envdir}61passenv =
62 TEST_*
123commands =63commands =
124 pre-commit run -a64 pytest {toxinidir}/tests/functional {posargs:-v}

Subscribers

People subscribed via source and target branches