-
Notifications
You must be signed in to change notification settings - Fork 28
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
Replace tox.ini and Makefile for noxfile.py #731
Conversation
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.
@slimreaper35 this is a very shallow top-level review I've done without trying it locally myself, but from the first look it looks fine, definitely doesn't hinder readability when compared to the declarative tox.ini config, so from that POV seems like a solid alternative to what we have today.
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 looks so neat!
6c0616a
to
aad2d24
Compare
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.
A couple small questions, but LGTM overall.
"""Run mypy on cachi2 and tests directories""" | ||
install_requirements(session) | ||
cmd = "mypy --install-types --non-interactive cachi2 tests" | ||
session.run(*cmd.split(), *session.posargs, silent=True) |
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.
Obligatory [non-blocking] tag.
Would this be too much of generalization?
@nox.session()
def mypy(session: Session) -> None:
"""Run mypy on cachi2 and tests directories"""
run_cmd_for(session, "mypy --install-types --non-interactive cachi2 tests")
def run_cmd_for(session, cmd, loud=False):
install_requirements(session)
session.run(*cmd.split(), *session.posargs, silent=not loud)
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 know, to me it feels like an unnecessary wrapper around each command.
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.
Given that all of the commands are exactly the same, maintainability would be increased by
def run_cmd(cmd, session):
install_requirements(session)
session.run(*cmd.split(), *session.posargs, silent=True)
called from the individual sessions as run_cmd(cmd, session)
.
Why? I realize that it seems excessive, but:
- It actually reduces the amount of repetition. If we need to change the options to
session.run
, we can do it in ONE place instead of ten - If we do have one specific session which needs to have a slightly different
session.run
, we can callsession.run
directly from that specific session, i.e. ignoring our "wrapper". As it stands, if one out the many sessions has different options, it's really hard to see.
761d02b
to
ad91366
Compare
I'm not advocating for keeping these, but they must be documented somewhere. I can't even remember the complete list of what "clean" takes care of, much less how to refresh the mock data 😆 ... |
I've never used |
All the more reason to document them, before the last person who actually did run them gets hit by a bus 😁 |
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.
What I'm missing in this PR:
- adding
.nox
to.gitignore
- making the final switch to nox from tox/Makefile, i.e. dropping latter
- docs changes
This LGTM, it only needs the changes that Erik pointed out. With these changes, the only reason to create a venv outside of |
We already set a precedense to have all configuration options for linters,formatters etc. inside one file - pyproject.toml. The pytest.ini options are still inside tox.ini. Since tox.ini might be replaced in the future, let's move the options to pyproject.toml for consistency and to avoid test failures later on. `testpaths` option was dropped completely - not relevant for us Signed-off-by: Michal Šoltis <[email protected]>
The commit follows the same reasoning as the previous one with moving configuration options to one location. `exclude` option is not relevant for us - we run flake8 on specific targets flake8 on its own does not support pyproject.toml as a configuration file [1] -> install flak8-pyproject package and regenarete requirements files --- [1]: https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations Signed-off-by: Michal Šoltis <[email protected]>
gitpython is already defined as regular dependency (no need to regenerate requirements files) Signed-off-by: Michal Šoltis <[email protected]>
1ab601b
to
c7cb752
Compare
24c07b4
to
d1b770f
Compare
How about just documenting it? ;) Having a shortcut command for |
|
||
[project] | ||
name = "cachi2" | ||
license = {text = "GPLv3+"} | ||
license = { text = "GPLv3+" } |
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.
unrelated change
"setuptools", | ||
"setuptools-scm", | ||
] | ||
requires = ["setuptools", "setuptools-scm"] |
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.
unrelated change
dynamic = [ | ||
"version", | ||
] | ||
dynamic = ["version"] |
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.
unrelated change
1a9abd9
to
26e883a
Compare
Nox is a command-line tool that automates testing in multiple Python environments, similar to tox. Unlike tox, nox uses a standard Python file for configuration (noxfile.py). The file can be easily used as a replacement for tox.ini and Makefile. The patch adds configuration options for mypy (because nox will check type annotations in noxfile.py as well). `nox.*` notation is a wildcard pattern that matches all modules and submodules under the nox namespace and `noxfile` notation matches only noxfile.py. Signed-off-by: Michal Šoltis <[email protected]>
Signed-off-by: Michal Šoltis <[email protected]>
Signed-off-by: Michal Šoltis <[email protected]>
Since noxfile.py is fully integrated to GH actions, we can safely drop both files. Signed-off-by: Michal Šoltis <[email protected]>
The hints, how to create custom cachi2 image, are already well described inside CONTRIBUTING.md document [1]. --- [1]: https://github.com/containerbuildsystem/cachi2/blob/main/CONTRIBUTING.md#running-integration-tests Signed-off-by: Michal Šoltis <[email protected]>
Remove all mentions of `make` or `tox` commands that are no longer relevant after removal of Makefile and tox.ini. Signed-off-by: Michal Šoltis <[email protected]>
https://nox.thea.codes/en/stable
Notes
@nox.session
decoratorreuse_venv=True
is used to speed up the execution of sessions by reusing the existing venvnox -l, --list
too*session.posargs
is used to pass additional arguments to the commandsilent=True
argument is used to suppress the output of the command only if the command was successfulexternal=True
argument in thesession.run()
method(it should work without the
external=True
argument, but it's better to be explicit and silence the warning)make venv
(it probably doesn't make sense to have a session for that, it would require contributors to install
nox
first)pytest
commands to make them more readable and cleanMaintainers will complete the following section
Note: if the contribution is external (not from an organization member), the CI
pipeline will not run automatically. After verifying that the CI is safe to run:
/ok-to-test
(as is the standard for Pipelines as Code)