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
Migration: use tox to run unit tests and linting #650
Conversation
…tions workflow into tox.ini
… for darwin (regex: darwin, environment name: py-darwin)
types-requests >= 2.28.10 | ||
commands = | ||
black --check . | ||
flake8 --count . |
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.
Note: this is a like-for-like migration of the existing flake8
behaviour (count only). To help people out in future though, we could/should probably run it without arguments so that it produces output when it detects problems.
Todo: figure out how to combine this neatly with |
I'll admit, I'm not sure what value tox adds here. Is it the ability to run a cross platform command that runs all the checks we have or is it something else? How exactly does it help prevent #641? |
Without So without When running with (#641 was a case where the |
Some thoughts at the moment:
|
Ah, and it looks like I totally broke the |
After your description I'm on board with using |
Thanks @bfcarpio. I do believe that this will be an improvement for our test infrastructure. That said, after further consideration, I think it's possible to do this without requiring all of our developers to use |
@@ -0,0 +1,29 @@ | |||
[testenv] | |||
deps = |
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.
Note-to-self: tox.ini
's deps
directive supports requirements.txt
-format files.
We may be able to update testenv
and/or lint
to read those from a shared location.
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.
Use cases I'm aware of:
- GitHub Actions unit tests: run isolated tests using
tox
-- install package & dependencies frompyproject.toml
, but without any other dependencies - Run unit tests locally: with or without package installed via
pyproject.toml
-- run tests usingunittest-parallel
, orpython -m unittest
directly; requires package dependencies installed, preferably into a virtualenv - Run GitHub Actions lint checks: run isolated linting using
tox
-- install lint tools - Run pre-commit checks locally: ideally using an isolated virtualenv (confirm: does pre-commit do this by default?), run
flake8
,black
, etc
It's possible that items (3) and (4) can be consolidated.
Developers should be able to choose to run (2) and (4) if they like locally - (1) and (3) will help them to identify problems if they don't (it's personal - and sometimes situational - preference about whether to be strict locally and/or use cloud compute to detect problems, especially bearing in mind multi-platform support)
At the moment as of this branch at 58ad0d2, the linting dependency list is duplicated between tox.ini
(tox lint), requirements-dev.txt
, and .pre-commit-config.yaml
- all slightly divergent.
Could we remove that duplication? Yep: linting/checking behaviours should be isolated. And pre-commit
seems designed for that purpose; so perhaps tox
should run/install pre-commit
to achieve lint checks (both in continuous integration and locally).
Regardless: tox
itself seems like a unit testing improvement in terms of test isolation, so let's begin using it for continuous integration.
Moving ahead with this change; figuring out how to do linting sensibly without duplication seems most likely to require a bit more exploration/research. |
The motivation behind this is primarily that it would have caught issue #641 (a bad
import
hidden by the installation of our dev-dependencies). It's also kinda relevant to #617.I'm not 100% sure whether removing the typing-related dependencies from the distributed package is fine. I think it is - as far as I know, they're only required when we run
mypy
checks, not when the library itself is installed / run as a dependency.