mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Configures tox to use a pinned requirements file for deterministic
CI builds, i.e. our CI shouldn't start failing because of an
incompatible upstream release of any of our testing tools:
NOTE: pinned tuf runtime requirements were already were already
used for test builds before (included via `-r
requirements-pinned.txt` in 'requirements-test.txt'). Now they are
explicitly listed in 'requirements-test-pinnned.txt'.
'requirements-test-pinnned.txt' was generated semi-automatically by
running pip-compile over 'requirements-test.txt' for each
supported/tested Python version (see snippet below) and manually
merging the resulting per-Python version requirements files into
one, adding environment markers as needed.
```
for ver in 3.7.12 3.8.12 3.9.9 3.10.0; do
pyenv virtualenv ${ver} tuf-env-${ver}
pyenv activate tuf-env-${ver}
python3 -m pip install -U pip pip-tools
pip-compile --no-header --annotation-style line \
-o requirements-test-pinned-${ver}.txt \
requirements-test.txt
pyenv deactivate
pyenv uninstall -f tuf-env-${ver}
done
```
Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
57 lines
1.8 KiB
INI
57 lines
1.8 KiB
INI
# Tox (https://tox.readthedocs.io/en/latest/) is a tool for running tests
|
|
# in multiple virtualenvs. This configuration file will run the
|
|
# test suite on all supported python versions. To use it, "pip install tox"
|
|
# and then run "tox" from this directory.
|
|
|
|
[tox]
|
|
envlist = lint,docs,py
|
|
skipsdist = true
|
|
|
|
[testenv]
|
|
# TODO: Consider refactoring the tests to not require the aggregation script
|
|
# being invoked from the `tests` directory. This seems to be the convention and
|
|
# would make use of other testing tools such as coverage/coveralls easier.
|
|
changedir = tests
|
|
|
|
commands =
|
|
python3 --version
|
|
python3 -m coverage run aggregate_tests.py
|
|
python3 -m coverage report -m --fail-under 97
|
|
|
|
deps =
|
|
-r{toxinidir}/requirements-test-pinned.txt
|
|
# Install TUF in editable mode, instead of tox default virtual environment
|
|
# installation (see `skipsdist`), to get relative paths in coverage reports
|
|
--editable {toxinidir}
|
|
|
|
install_command = python3 -m pip install {opts} {packages}
|
|
|
|
# Develop test env to run tests against securesystemslib's master branch
|
|
# Must to be invoked explicitly with, e.g. `tox -e with-sslib-master`
|
|
[testenv:with-sslib-master]
|
|
commands_pre =
|
|
python3 -m pip install git+https://github.com/secure-systems-lab/securesystemslib.git@master#egg=securesystemslib[crypto,pynacl]
|
|
|
|
commands =
|
|
python3 -m coverage run aggregate_tests.py
|
|
python3 -m coverage report -m
|
|
|
|
[testenv:lint]
|
|
changedir = {toxinidir}
|
|
lint_dirs = tuf examples tests
|
|
commands =
|
|
black --check --diff {[testenv:lint]lint_dirs}
|
|
isort --check --diff {[testenv:lint]lint_dirs}
|
|
pylint -j 0 --rcfile=pyproject.toml {[testenv:lint]lint_dirs}
|
|
|
|
mypy {[testenv:lint]lint_dirs}
|
|
|
|
bandit -r tuf
|
|
|
|
[testenv:docs]
|
|
deps =
|
|
-r{toxinidir}/requirements-docs.txt
|
|
|
|
changedir = {toxinidir}
|
|
commands =
|
|
sphinx-build -b html docs docs/build/html -W
|