Skip to content

Commit

Permalink
Simplify tox.ini file
Browse files Browse the repository at this point in the history
and split it into sections for easier reading
  • Loading branch information
gregorjerse committed Jul 17, 2024
1 parent 67b9a57 commit 98823e0
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}:
Expand Down Expand Up @@ -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

0 comments on commit 98823e0

Please sign in to comment.