From 98823e01e3fdc7a66e0d4e2cb3d553939036c7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Mon, 15 Jul 2024 15:31:46 +0200 Subject: [PATCH] Simplify tox.ini file and split it into sections for easier reading --- tox.ini | 78 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/tox.ini b/tox.ini index f7965d604..d650e3cf0 100644 --- a/tox.ini +++ b/tox.ini @@ -8,25 +8,14 @@ envlist = migrations # Use the Tox at least 4.16. If not available it will be auto-provisioned. minversion = 4.16 - -# Configure special Tox environment used for isolated building of the source -# package. -[testenv:.package] -# Use the default Python 3 version available on the system. -# NOTE: This makes it portable to CI systems where only one particular Python 3 -# version is installed. -basepython = python3 - -# Use setuptools suitable for google storage connectors. - +# Make it possible to override the base python with the environment name. +ignore_base_python_conflict = true [testenv] -allowlist_externals = - bash -basepython = - py311{,-storage-credentials}: python3.11 - py312{,-storage-credentials}: python3.12 - docs,linters,packaging,migrations: python3.12 +# Use python 3.12 if it cannot be infered from the environment. +# See https://tox.wiki/en/latest/user_guide.html#test-environments for rules +# how basepython is selected from the environment name. +basepython = python3.12 extras = # Always include storage extras or connectors related tests will fail. py3{11,12}{,-storage-credentials}: @@ -56,37 +45,46 @@ ignore_errors = # Run all linters to see their output even if one of them fails. linters: true +[testenv:py3{11,12}{,-storage-credentials}] commands = # General tests commands: # Print the environment and run tests. - py3{11,12}{,-storage-credentials}: coverage run tests/manage.py test {env:TEST_SUITE:resolwe} \ - py3{11,12}-storage-credentials: --pattern storage_credentials_test_*.py \ - py3{11,12}{,-storage-credentials}: --noinput --verbosity=2 --parallel - py3{11,12}{,-storage-credentials}: coverage combine + coverage run tests/manage.py test {env:TEST_SUITE:resolwe} \ + storage-credentials: --pattern storage_credentials_test_*.py \ + --noinput --verbosity=2 --parallel + coverage combine - # Docs commands: - # Build documentation. - docs: sphinx-build ./docs/ build/sphinx/html --fail-on-warning --fresh-env +[testenv:migrations] +allowlist_externals = + bash + psql +commands = + python tests/manage.py migrate + bash -c '[[ $(./tests/manage.py makemigrations --dry-run) = '\ + '"No changes detected" ]] || exit 1' + +[testenv:packaging] +commands = + # Confirm that items checked into git are in sdist. + check-manifest + # Verify package metadata and confirm the long_description will render + # correctly on PyPI. + python -m build + python -m twine check --strict dist/* +[testenv:linters] +commands = # Linter commands: # Check code formating with black. - linters: black --check resolwe + black --check resolwe # Check order of imports. - linters: isort --check-only --diff resolwe + isort --check-only --diff resolwe # Run PyFlakes and Ned Batchelder's McCabe script. - linters: flake8 resolwe + flake8 resolwe # Check documentation formatting (PEP 257). - linters: pydocstyle resolwe --match='(?!test[_s]).*\.py' + pydocstyle resolwe --match='(?!test[_s]).*\.py' - # Packaging commands: - # Confirm that items checked into git are in sdist. - packaging: check-manifest - # Verify package metadata and confirm the long_description will render - # correctly on PyPI. - packaging: python -m build - packaging: python -m twine check --strict dist/* - - # Migrations commands: - migrations: python tests/manage.py migrate - migrations: bash -c '[[ $(./tests/manage.py makemigrations --dry-run) = '\ - migrations: '"No changes detected" ]] || exit 1' +[testenv:docs] +commands = + # Build documentation. + sphinx-build ./docs/ build/sphinx/html --fail-on-warning --fresh-env