| 1 | [tox] |
| 2 | package = rstcheck_core |
| 3 | |
| 4 | minversion = 4 |
| 5 | skip_missing_interpreters = true |
| 6 | ignore_base_python_conflict = true |
| 7 | no_package = false |
| 8 | |
| 9 | env_list = |
| 10 | package |
| 11 | pre-commit-run |
| 12 | py{312,311,310,39,38} |
| 13 | py{312,311,310,39,38}-with-sphinx{5,6,7} |
| 14 | py{312,311,310,39,38}-with-tomli |
| 15 | coverage-all |
| 16 | docs-test-{html,linkcheck,doctest,spelling} |
| 17 | |
| 18 | labels = |
| 19 | test = py{312,311,310,39,38},py{312,311,310,39,38}-with-sphinx{5,6,7},py{312,311,310,39,38}-with-tomli,coverage-all |
| 20 | py3.8 = py38,py38-with-sphinx{5,6,7},py38-with-tomli,coverage-all |
| 21 | py3.9 = py39,py39-with-sphinx{5,6,7},py39-with-tomli,coverage-all |
| 22 | py3.10 = py310,py310-with-sphinx{5,6,7},py310-with-tomli,package,coverage-all |
| 23 | py3.11 = py311,py311-with-sphinx{5,6,7},py311-with-tomli,package,coverage-all |
| 24 | py3.12 = py312,py312-with-sphinx{5,6,7},py312-with-tomli,package,coverage-all |
| 25 | docs = docs-test-{html,doctest} |
| 26 | docs-full = docs-test-{html,linkcheck,doctest,spelling} |
| 27 | |
| 28 | |
| 29 | [testenv] |
| 30 | description = basic config env |
| 31 | base_python = python3.12 |
| 32 | pass_env = |
| 33 | HOME |
| 34 | CI |
| 35 | CI_FORCE_COLORS_PRE_COMMIT |
| 36 | CI_FORCE_COLORS_PYTEST |
| 37 | CI_FORCE_COLORS_SPHINX |
| 38 | set_env = |
| 39 | PIP_DISABLE_VERSION_CHECK = 1 |
| 40 | download = true |
| 41 | commands = |
| 42 | echo "Please use available tox envs" |
| 43 | exit 1 |
| 44 | |
| 45 | |
| 46 | [testenv:pre-commit] |
| 47 | description = format and check the code |
| 48 | env_dir = {toxworkdir}/pre-commit |
| 49 | pass_env = |
| 50 | {[testenv]pass_env} |
| 51 | SSH_AUTH_SOCK |
| 52 | SKIP |
| 53 | set_env = |
| 54 | {[testenv]set_env} |
| 55 | SKIP = {tty:identity:},{env:SKIP:} |
| 56 | skip_install = true |
| 57 | deps = pre-commit >= 2.17 |
| 58 | commands = |
| 59 | pre-commit {posargs:--help} |
| 60 | |
| 61 | |
| 62 | [testenv:pre-commit-run] |
| 63 | description = install pre-commit as git hook from the tox env |
| 64 | env_dir = {[testenv:pre-commit]env_dir} |
| 65 | skip_install = {[testenv:pre-commit]skip_install} |
| 66 | deps = {[testenv:pre-commit]deps} |
| 67 | commands = |
| 68 | pre-commit run {posargs} \ |
| 69 | --all-files \ |
| 70 | {tty::--show-diff-on-failure} \ |
| 71 | {tty:--color always:{env:CI_FORCE_COLORS_PRE_COMMIT:}} |
| 72 | |
| 73 | |
| 74 | [testenv:mypy] |
| 75 | description = run mypy type checker |
| 76 | extras = |
| 77 | toml |
| 78 | type_check |
| 79 | docs |
| 80 | testing |
| 81 | ignore_errors = true |
| 82 | commands = |
| 83 | mypy \ |
| 84 | --config-file {toxinidir}/pyproject.toml \ |
| 85 | src/rstcheck \ |
| 86 | tests \ |
| 87 | docs/source/conf.py \ |
| 88 | prep_release.py |
| 89 | |
| 90 | |
| 91 | [testenv:package] |
| 92 | description = check sdist and wheel |
| 93 | skip_install = true |
| 94 | deps = |
| 95 | build >= 1 |
| 96 | twine >= 3.3 |
| 97 | commands = |
| 98 | python -m build |
| 99 | twine check --strict dist/* |
| 100 | |
| 101 | |
| 102 | [testenv:py{312,311,310,39,38}] |
| 103 | description = run tests with {basepython} |
| 104 | pass_env = |
| 105 | {[testenv]pass_env} |
| 106 | PYTEST_* |
| 107 | set_env = |
| 108 | {[testenv]set_env} |
| 109 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 110 | extras = |
| 111 | testing |
| 112 | commands = |
| 113 | pytest \ |
| 114 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 115 | --basetemp {envtmpdir} \ |
| 116 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 117 | --cov-fail-under 0 \ |
| 118 | {tty::-vvv} \ |
| 119 | {posargs:tests} |
| 120 | |
| 121 | |
| 122 | [testenv:py{312,311,310,39,38}-with-sphinx{5,6,7}] |
| 123 | description = run tests with {basepython} and sphinx |
| 124 | pass_env = |
| 125 | {[testenv]pass_env} |
| 126 | PYTEST_* |
| 127 | set_env = |
| 128 | {[testenv]set_env} |
| 129 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 130 | extras = |
| 131 | testing |
| 132 | deps = |
| 133 | sphinx5: sphinx>=5,<6 |
| 134 | sphinx6: sphinx>=6,<7 |
| 135 | sphinx7: sphinx>=7,<8 |
| 136 | commands = |
| 137 | pytest \ |
| 138 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 139 | --basetemp {envtmpdir} \ |
| 140 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 141 | --cov-fail-under 0 \ |
| 142 | {tty::-vvv} \ |
| 143 | {posargs:tests} |
| 144 | |
| 145 | |
| 146 | [testenv:py{312,311,310,39,38}-with-tomli] |
| 147 | description = run tests with {basepython} and toml |
| 148 | pass_env = |
| 149 | {[testenv]pass_env} |
| 150 | PYTEST_* |
| 151 | set_env = |
| 152 | {[testenv]set_env} |
| 153 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 154 | extras = |
| 155 | toml |
| 156 | testing |
| 157 | commands = |
| 158 | pytest \ |
| 159 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 160 | --basetemp {envtmpdir} \ |
| 161 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 162 | --cov-fail-under 0 \ |
| 163 | {tty::-vvv} \ |
| 164 | {posargs:tests} |
| 165 | |
| 166 | |
| 167 | [testenv:coverage-{all,merge,report}] |
| 168 | description = |
| 169 | all,merge: combine coverage data and create xml/html reports; |
| 170 | all,report: report total and diff coverage against origin/main (or DIFF_AGAINST) |
| 171 | env_dir = {toxworkdir}/coverage |
| 172 | depends = py{py3,312,311,310,39,38} |
| 173 | pass_env = |
| 174 | {[testenv]pass_env} |
| 175 | all,report: MIN_COVERAGE |
| 176 | all,report: MIN_DIFF_COVERAGE |
| 177 | all,report: DIFF_AGAINST |
| 178 | all,report: DIFF_RANGE_NOTATION |
| 179 | set_env = |
| 180 | {[testenv]set_env} |
| 181 | COVERAGE_FILE={toxinidir}/.coverage_cache/.coverage |
| 182 | skip_install = true |
| 183 | parallel_show_output = true |
| 184 | ignore_errors = true |
| 185 | deps = |
| 186 | diff-cover |
| 187 | coverage[toml] >=6.0 |
| 188 | coverage-conditional-plugin >=0.5 |
| 189 | commands = |
| 190 | all,merge: coverage combine |
| 191 | all,merge: coverage xml -o {toxinidir}/.coverage_cache/coverage.xml |
| 192 | all,merge: coverage html -d {toxinidir}/.coverage_cache/htmlcov |
| 193 | all,report: coverage report -m --fail-under {env:MIN_COVERAGE:0} |
| 194 | all,report: diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} \ |
| 195 | all,report: --ignore-staged --ignore-unstaged \ |
| 196 | all,report: --fail-under {env:MIN_DIFF_COVERAGE:0} \ |
| 197 | all,report: --diff-range-notation {env:DIFF_RANGE_NOTATION:..} \ |
| 198 | all,report: {toxinidir}/.coverage_cache/coverage.xml |
| 199 | |
| 200 | |
| 201 | [testenv:docs{,-auto}] |
| 202 | description = build docs with sphinx |
| 203 | env_dir = {toxworkdir}/docs |
| 204 | set_env = |
| 205 | {[testenv]set_env} |
| 206 | TOXENV_BUILDCMD = sphinx-build {tty:--color:} |
| 207 | auto: TOXENV_BUILDCMD = sphinx-autobuild --re-ignore autoapidoc --watch {toxinidir}/src |
| 208 | extras = |
| 209 | toml |
| 210 | docs |
| 211 | commands = |
| 212 | # Build fresh docs |
| 213 | {env:TOXENV_BUILDCMD} -b html -aE docs/source docs/build/html |
| 214 | # Output link to index.html |
| 215 | python -c \ |
| 216 | 'from pathlib import Path; \ |
| 217 | index_file = Path(r"{toxinidir}")/"docs/build/html/index.html"; \ |
| 218 | print(f"DOCUMENTATION AVAILABLE UNDER: \{index_file.as_uri()\}")' |
| 219 | |
| 220 | |
| 221 | [testenv:docs-test-{html,linkcheck,doctest,spelling}] |
| 222 | description = Build and check docs with (see env name) sphinx builder |
| 223 | env_dir = {[testenv:docs]env_dir} |
| 224 | set_env = |
| 225 | {[testenv]set_env} |
| 226 | html: TOXENV_BUILDER = html |
| 227 | linkcheck: TOXENV_BUILDER = linkcheck |
| 228 | doctest: TOXENV_BUILDER = doctest |
| 229 | spelling: TOXENV_BUILDER = spelling |
| 230 | spelling: SPHINX_SPELLING = true |
| 231 | extras = {[testenv:docs]extras} |
| 232 | commands = |
| 233 | sphinx-build \ |
| 234 | {tty:--color:{env:CI_FORCE_COLORS_SPHINX:}} \ |
| 235 | -b {env:TOXENV_BUILDER} \ |
| 236 | -aE -v -nW --keep-going \ |
| 237 | docs/source docs/build/test/{env:TOXENV_BUILDER} |