Merge ~mertkirpici/juju-lint:lp/1989575 into juju-lint:master

Proposed by Mert Kirpici
Status: Merged
Approved by: Eric Chen
Approved revision: 1e67b7a4a726e02e3ac82699562e1db75f8ff6ac
Merged at revision: c05a3913ecaabbc5ba41cf14895ffb7ced946567
Proposed branch: ~mertkirpici/juju-lint:lp/1989575
Merge into: juju-lint:master
Diff against target: 159 lines (+37/-29)
5 files modified
.gitignore (+1/-0)
Makefile (+1/-3)
tests/functional/requirements.txt (+2/-1)
tests/unit/requirements.txt (+1/-12)
tox.ini (+32/-13)
Reviewer Review Type Date Requested Status
Eric Chen Approve
Gabriel Cocenza Approve
Review via email: mp+429879@code.launchpad.net

Commit message

Close LP #1989575

Description of the change

After the renaming process in 30066d3b[1], makefile dev-environment target was overlooked, ending up with the broken target.

To fix this properly, rather than hardcoding tests/unit/requirements.txt into the makefile, we introduce requirements-dev.txt file and point the unittest requirements file to that.

Since this issue[0] is resolved, unpinned the flake8 version.

Also the .venv/ created by dev-environment was not ignored by git, fixed that.

[0] https://github.com/csachs/pyproject-flake8/issues/13
[1] https://git.launchpad.net/juju-lint/commit/?id=30066d3b9d49f4c673cf9766d13054b735c26a30

To post a comment you must log in.
Revision history for this message
Mert Kirpici (mertkirpici) wrote :
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
Eric Chen (eric-chen) wrote :

Please provide functional test log too.

review: Needs Information
Revision history for this message
Mert Kirpici (mertkirpici) wrote :

lint + unittests + functional:
https://pastebin.ubuntu.com/p/tF7CKBwzQz/

Revision history for this message
Gabriel Cocenza (gabrielcocenza) wrote :

I liked the idea of having a single requirements-dev.txt at the "principal" folder of the project.

With that said, is there a specific reason why the functional-tests requirements it's not in the same file?

If we have a single requirements-dev.txt it won't be necessary to have the unit and functional requirements.txt and the [testenv] on the .tox file could be responsible to install all dependencies of the project. With that, I guess we can remove deps from [testenv:func], [testenv:func-smoke], [testenv:func-dev] and [testenv:pre-commit].

review: Needs Information
Revision history for this message
Mert Kirpici (mertkirpici) wrote :

So after giving this some thought and experimenting, I came to a conclusion that having a central dev requirements ends up installing ALL of the dependencies for every tox environment, which is very redundant and takes a lot of time and space.

Therefore I moved away from that idea towards the opposite.
With the second change I pushed, every tox env installs only their own dependencies they need. (Most charms also follow this)

Also another change is that, the virtual env creation in makefile's `dev-environment` target was not being created by tox like all the rest but it was using the package `virtualenv`. I moved away from that also, in favor of using tox for the `dev-environment` creation as well.

Here is a showcase of all current make+tox targets :)
https://pastebin.ubuntu.com/p/ZkxG8mFsWV/

Revision history for this message
Martin Kalcok (martin-kalcok) wrote :

overall LGTM. just a small note. You can make multiple tox environments share the same "virtual environment folder" to cut down on venv duplicity. For example how "format-code" shares "lint" venv in juju-verify [0]. Same could be applied here.

[0] https://github.com/canonical/juju-verify/blob/237fea58fd579279121f476d244bacbd1992355c/tox.ini#L43

Revision history for this message
Gabriel Cocenza (gabrielcocenza) wrote :

Generally this patch LGTM, but the command `make pre-commit` it's not working.

review: Needs Information
Revision history for this message
Mert Kirpici (mertkirpici) wrote :

pushed update to recover the pre-commit target

Revision history for this message
Gabriel Cocenza (gabrielcocenza) wrote :

LGTM. Please provide the logs of tests before merging.

review: Approve
Revision history for this message
Mert Kirpici (mertkirpici) wrote :

updated one last time. changes:
- rebased onto current master.
- squashed commits.
- rewritten commit message

`make test`:
https://pastebin.ubuntu.com/p/WdZ8q9j5nC/

all green. ready to land.

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

Change successfully merged at revision c05a3913ecaabbc5ba41cf14895ffb7ced946567

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2index 764c99f..b095e7e 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -31,3 +31,4 @@ output/
6
7 # venv
8 /venv
9+.venv
10diff --git a/Makefile b/Makefile
11index 4857f3f..7c33d38 100644
12--- a/Makefile
13+++ b/Makefile
14@@ -45,9 +45,7 @@ clean:
15
16 dev-environment:
17 @echo "Creating virtualenv and installing pre-commit"
18- @virtualenv -p python3 .venv
19- @.venv/bin/pip install -r tests/requirements.txt
20- @.venv/bin/pre-commit install
21+ @tox -r -e dev-environment
22
23 functional: build
24 @echo "Executing functional tests using built snap"
25diff --git a/tests/functional/requirements.txt b/tests/functional/requirements.txt
26index 2220b6c..f7fed82 100644
27--- a/tests/functional/requirements.txt
28+++ b/tests/functional/requirements.txt
29@@ -1 +1,2 @@
30-pytest-operator
31\ No newline at end of file
32+pytest
33+pytest-operator
34diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt
35index ce434c0..0710dca 100644
36--- a/tests/unit/requirements.txt
37+++ b/tests/unit/requirements.txt
38@@ -1,16 +1,5 @@
39-# Module requirements
40-black
41-colorama
42-flake8<5.0 # some flake8 plugins seem to be currently broken with version 5.0+
43-flake8-colors
44-flake8-docstrings
45-flake8-html
46-isort
47-mock
48-pep8-naming
49-pyflakes
50 pytest
51 pytest-cov
52 pytest-html
53 pytest-mock
54-pre-commit
55+mock
56diff --git a/tox.ini b/tox.ini
57index a89fd0b..ba747d8 100644
58--- a/tox.ini
59+++ b/tox.ini
60@@ -17,11 +17,11 @@ skip_missing_interpreters = True
61
62 [testenv]
63 basepython = python3.8
64-deps =
65- -r{toxinidir}/tests/unit/requirements.txt
66- -r{toxinidir}/requirements.txt
67
68 [testenv:unit]
69+deps =
70+ -r{toxinidir}/requirements.txt
71+ -r{toxinidir}/tests/unit/requirements.txt
72 commands =
73 pytest -v \
74 --cov=jujulint \
75@@ -38,11 +38,9 @@ commands =
76 setenv = PYTHONPATH={toxinidir}
77
78 [testenv:func]
79+deps = -r{toxinidir}/tests/functional/requirements.txt
80 passenv =
81 JUJULINT_TEST_*
82-deps =
83- {[testenv]deps}
84- -r{toxinidir}/tests/functional/requirements.txt
85 commands =
86 pytest -v \
87 --log-cli-level=WARNING \
88@@ -51,8 +49,8 @@ commands =
89
90 [testenv:func-smoke]
91 deps =
92- {[testenv]deps}
93- -r{toxinidir}/tests/functional/requirements.txt
94+ {[testenv:func]deps}
95+ -r{toxinidir}/requirements.txt
96 commands =
97 pytest -v \
98 --log-cli-level=WARNING \
99@@ -61,26 +59,36 @@ commands =
100
101 [testenv:func-dev]
102 deps =
103- {[testenv]deps}
104- -r{toxinidir}/tests/functional/requirements.txt
105+ {[testenv:func]deps}
106+ -r{toxinidir}/requirements.txt
107 commands =
108 pytest -v \
109 --log-cli-level=WARNING \
110 --ignore={toxinidir}/tests/unit
111
112 [testenv:lint]
113+deps =
114+ black
115+ colorama
116+ flake8
117+ flake8-colors
118+ flake8-docstrings
119+ flake8-html
120+ isort
121+ pep8-naming
122+ pyflakes
123+
124 commands =
125 flake8 --color always
126 black --check --diff --color .
127 isort --check-only --diff --color .
128
129-
130 [testenv:reformat]
131+deps = {[testenv:lint]deps}
132 commands =
133 black .
134 isort .
135
136-
137 [pytest]
138 filterwarnings =
139 ignore::DeprecationWarning
140@@ -99,7 +107,18 @@ skip_glob =
141 mod,
142 build,
143
144+[testenv:dev-environment]
145+deps =
146+ pre-commit
147+ {[testenv:lint]deps}
148+ {[testenv:unit]deps}
149+ {[testenv:func]deps}
150+envdir = {toxinidir}/.venv
151+commands =
152+ pre-commit install
153+
154 [testenv:pre-commit]
155-deps = pre-commit
156+deps = {[testenv:dev-environment]deps}
157+envdir = {[testenv:dev-environment]envdir}
158 commands =
159 pre-commit run -a

Subscribers

People subscribed via source and target branches