From cd052b20a71bec0d605151eeb6b7ac87fbeb3e4a Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 18 Sep 2023 03:26:38 -0400 Subject: [PATCH 1/4] Start setting up tox It is not completely working yet. --- .gitignore | 1 - requirements-dev.txt | 3 --- tox.ini | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 0bd307639..139bf8ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,3 @@ nbproject .pytest_cache/ monkeytype.sqlite3 output.txt -tox.ini diff --git a/requirements-dev.txt b/requirements-dev.txt index f6705341c..e3030c597 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,6 +7,3 @@ flake8-type-checking;python_version>="3.8" # checks for TYPE_CHECKING only pytest-icdiff # pytest-profiling - - -tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..0b5591139 --- /dev/null +++ b/tox.ini @@ -0,0 +1,24 @@ +[tox] +requires = tox>=4 +env_list = py{37,38,39,310,311,312}, lint, mypy, black + +[testenv] +description = Run unit tests +package = wheel +extras = test +commands = pytest --color=yes {posargs} + +[testenv:lint] +description = Lint via pre-commit +basepython = py39 +commands = pre-commit run --all-files + +[testenv:mypy] +description = Typecheck with mypy +basepython = py39 +commands = mypy -p git + +[testenv:black] +description = Check style with black +basepython = py39 +commands = black --check --diff git From 2cc2db77574b8197cce215ab703c9d383ea645c1 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 18 Sep 2023 19:49:00 -0400 Subject: [PATCH 2/4] Pass through SSH_ env vars to tox envs This fixes a problem where the tests for fetching a nonexistent ref prompt like "Enter passphrase for key '/home/USERNAME/.ssh/id_rsa':" and block, if the repository on the machine where the tests are being run has the remote set up using an SSH URL. This passes through all environment variables whose names start with SSH_, even though it should be enough to pass SSH_AGENT_PID and SSH_AUTH_SOCK through, at least for this particular issue. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 0b5591139..9b918f560 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ env_list = py{37,38,39,310,311,312}, lint, mypy, black description = Run unit tests package = wheel extras = test +pass_env = SSH_* commands = pytest --color=yes {posargs} [testenv:lint] From 4bea7cf4cfdbb9d69f24a245bdc8a7e0638524a2 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 18 Sep 2023 20:36:31 -0400 Subject: [PATCH 3/4] Don't have mypy failure fail the whole tox run Other environments would still be run even after mypy has failed, but to avoid having tox runs be unnecessarily inconsistent with the mypy step in the pythonpackage.yml CI workflow, and also because GitPython is not currently expected to pass mypy checks, this keeps mypy errors from causing the whole tox run to be reported as failed. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 9b918f560..a81cd2b45 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ commands = pre-commit run --all-files description = Typecheck with mypy basepython = py39 commands = mypy -p git +ignore_outcome = true [testenv:black] description = Check style with black From e6ec6c87b8ed66e30f7addbd109ab6ec5d74326c Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 18 Sep 2023 22:58:58 -0400 Subject: [PATCH 4/4] Add tox environment to build HTML documentation The main use of this, similar to the step at the end of pythonpackage.yml, is to find errors produced by building. However, actual documentation *is* built, and unlike other tox environments, running this one actually writes outside the .tox/ directory, creating the documentation in the usual target location. For that reason, this environment is omitted from the env_list, so that it does not run by default and unexpectedly overwrite documentation that may recently have been built before changes are made that could cause generated documentation to be different. --- tox.ini | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index a81cd2b45..8d64b929b 100644 --- a/tox.ini +++ b/tox.ini @@ -11,16 +11,25 @@ commands = pytest --color=yes {posargs} [testenv:lint] description = Lint via pre-commit -basepython = py39 +base_python = py39 commands = pre-commit run --all-files [testenv:mypy] description = Typecheck with mypy -basepython = py39 +base_python = py39 commands = mypy -p git ignore_outcome = true [testenv:black] description = Check style with black -basepython = py39 +base_python = py39 commands = black --check --diff git + +# Run "tox -e html" for this. It is deliberately excluded from env_list, as +# unlike the other environments, this one writes outside the .tox/ directory. +[testenv:html] +description = Build HTML documentation +base_python = py39 +deps = -r doc/requirements.txt +allowlist_externals = make +commands = make -C doc html