-
Notifications
You must be signed in to change notification settings - Fork 667
tox.ini rework: regroup things in the testenv section #1887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Fabrice Flore-Thebault <[email protected]>
Signed-off-by: Fabrice Flore-Thebault <[email protected]>
Signed-off-by: Fabrice Flore-Thebault <[email protected]>
Hmmm, not sure. I find the separate testenvs more readable? Not willing to stop initiative here if the others find this to be more useful though. Let's see and thanks for the efforts to improve this! |
@decentral1se that is exactly my point: have a discussion on the right direction to take. Experimenting here with "regrouping everything in testenv, tox.ini now under 100 loc". |
functional: pytest test/functional/ {posargs} | ||
lint: flake8 | ||
lint: yamllint -s test/ molecule/ | ||
metadata-validation: python -m setup checkdocs check --metadata --restructuredtext --strict --verbose | ||
metadata-validation: twine check .tox/dist/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that once deps
or commands
for a testenv break out to multiple lines, a dedicated testenv:section
should probably be used. I love all the collapsed one-line dep/command testenvs though.
Signed-off-by: Fabrice Flore-Thebault <[email protected]>
passenv = * | ||
setenv = | ||
PYTHONDONTWRITEBYTECODE=1 | ||
deps = | ||
-rrequirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this line
@@ -1,44 +1,66 @@ | |||
[tox] | |||
minversion = 3.7.0 | |||
envlist = | |||
build-docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a list of envs executed when a user runs tox
without env spec. I'd say that it should be a minimal needed thing for them to verify that a few main things work rather than wait for hours for all of the unneeded things to complete.
So they definitely don't need to check whether docker build works because in 99% cases they won't touch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the focus is on the user here, would it make sense to limit this a little more, e.g.
envlist =
doc
format-check
lint
metadata-validation
py{27,35,36,37}-ansible{25,26,27}-unit
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's re-iterate:
- Do users change docs often? Will they benefit on rebuilding docs all the time? Probably not.
- format-check? It's probably worth it.
- metadata-validation? Do they change packaging all the time? Probably not.
- unit-tests? definitely yes.
- functional tests? I think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on all counts. I left functional testing out because they don't "just work" for me without adding some pytest filtering. Functional testing should probably be in the default list of tests run, but not if those test runs require, say, working credentials for all drivers. I don't know if this is a common problem or only local to me, though.
@@ -1,44 +1,66 @@ | |||
[tox] | |||
minversion = 3.7.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's bump to have the newest bugfixes and a few nice improvements..
minversion = 3.7.0 | |
minversion = 3.8.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a requirement on tox version that was released 60 minutes ago is not safe.
Let things rest before bumping requirements to bleading edge releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's no reason to distrust tox's release standards. Unless there's a specific problem that comes from using 3.8, we should feel free to track the latest tox. tox claims to follow semantic versioning, which we also have no reason to distrust. I'm not generally in favor of upgrading for upgrading's sake, but improvements to parallel testing in 3.8 would likely help get tox .. -p auto
working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, in line with the idea of incremental changes, it makes sense to only bump the tox minimums if tests are updated to require features introduced in higher versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only a patch release which fixed a minor bump. It doesn't matter when it was released, only proves that fixes get released fast.
And yes, tox's standards are high and current maintainers are very responsible.
The reason I want this update is that it ships certain features and bugfixes which I'd like to rely on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To go for readability, we need to specify separate env vars, not dump everything into a single soup env...
Try separating things instead. it just breaks my brain when I try to understand what's going to happen in which cases...
What you've submitted is an antipattern. Check out tox.ini
in tox's own config https://github.com/tox-dev/tox/blob/master/tox.ini or this one https://github.com/pypa/virtualenv/blob/master/tox.ini to get some inspiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many changes inter-combined, making this change hard to review and merge. Lets do them one at a time.
@@ -1,3 +1,4 @@ | |||
-r requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this as an anti-pattern. Test requirements should not also include requirments.
While I find the refactoring of tox.ini very useful, I am afraid that the scope of the refactoring keeps growing and instead we should make smaller incremental improvements on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it's an anti-pattern in general. It depends on the use-case. In this case, it's probably fine for now since I'm going to fix dependency management along with packaging anyway...
@@ -1,44 +1,66 @@ | |||
[tox] | |||
minversion = 3.7.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a requirement on tox version that was released 60 minutes ago is not safe.
Let things rest before bumping requirements to bleading edge releases.
|
||
[testenv:doc] | ||
[doc] | ||
# basepython can't be put in the testenv section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my local testing (using tox >=3.8), this is not true. To have any effect, I need to put basepython
inside the testenv:doc
block for it to have any effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a test with tox 3.7.0 just now, and the basepython appears to be working as expected. The docs seem pretty clear that basepython
belongs in testenv
blocks:
https://tox.readthedocs.io/en/3.7.0/config.html#conf-basepython
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I do not support bumping tox too fast is because tox is a system requirement which means that if a new version of tox is released that breaks its use on one python based project and molecule is forcing me to use that breading-edge new version I may endup with a case where I cannot run tox with both projects.
To avoid this case we only need to be carefult to wait at least two weeks before using a newer version of tox. I am confident about tox is tested well but nobody can guarantee that a new release does not break anything.
The same issue does not apply for most other test requirements because they are installed inside virtualenvironments managed by tox, so no risk of conflict.
Shortly, lets bump it when we need new features but after a cooldown period so we avoid getting burned ;)
I'm going to attempt to sum up what's been discussed so far, please correct me if I missed something.
After applying all of those bullets to the current master tox.ini, here's the diff: diff --git a/tox.ini b/tox.ini
index 3e1a5580..c8ac1c58 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,9 +2,8 @@
minversion = 3.7.0
envlist =
lint
- py{27,35,36,37}-ansible{25,26,27}-{functional,unit}
format-check
- doc
+ py{27,35,36,37}-ansible{25,26,27}-{functional,unit}
skipdist = True
skip_missing_interpreters = True
@@ -34,11 +33,6 @@ extras =
windows
commands_pre =
find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -path '*/__pycache__/*' -name '*.py[c|o]' -delete
-commands =
- unit: pytest test/unit/ --cov={toxinidir}/molecule/ --no-cov-on-fail {posargs}
- functional: pytest test/functional/ {posargs}
- lint: flake8
- lint: yamllint -s test/ molecule/
whitelist_externals =
find
# Enabling sitepackages is needed in order to avoid encountering exceptions
@@ -50,6 +44,9 @@ sitepackages = true
[testenv:lint]
deps =
-rlint-requirements.txt
+commands =
+ flake8
+ yamllint -s test/ molecule/
extras =
skip_install = true
usedevelop = false
@@ -72,7 +69,7 @@ usedevelop = false
[testenv:doc]
# doc requires py3 due to use of f'' strings and using only python3 as
-# basepython risks using python3.4 which is not supported.
+# basepython risks using python3.5, which does not support them.
basepython = python3.7
passenv = *
commands =
@@ -119,3 +116,9 @@ commands =
'
whitelist_externals =
sh
+
+[testenv:unit]
+commands = pytest test/unit/ --cov={toxinidir}/molecule/ --no-cov-on-fail {posargs}
+
+[testenv:functional]
+commands = pytest test/functional/ {posargs} This results in a more focused diff that I think addresses the points discussed here. I did throw in a quick comment change to the doc testenv basepython requirement to better reflect the current situation as I understand it. |
@seandst you've perfectly summarized it. I just want to add that I've got #1895 to merge first which will address some of the concerns like the very existence of |
Merged! |
I guess it's better to close this PR and do a new one with the changes proposed in the wrapup #1887 (comment) |
@seandst are you ready to propose a new PR based on your wrapup, or how should we proceed? |
This is a proposal to tidy up the
tox
configuration.The rationale I followed was following: to avoid duplication of statements, regroup everything that can be regrouped in the
testenv
section. I hope this is also increasing readability of thetox.ini
file.I also moved the call to a second requirement file inside of the
test-requiremenst.txt
file.I am not sure if this approach is consensual among
tox
users, so please tell me if this is going in the right direction, or absolutely not.Signed-off-by: Fabrice Flore-Thebault [email protected]
PR Type