| 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,coverage,doctest,spelling} |
| 17 | |
| 18 | labels = |
| 19 | test = py{312,311,310,39,38},py{312,311,310,39,38}-with-yaml,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-yaml,py38-with-sphinx{5,6,7},py38-with-tomli,coverage-all |
| 21 | py3.9 = py39,py39-with-yaml,py39-with-sphinx{5,6,7},py39-with-tomli,coverage-all |
| 22 | py3.10 = py310,py310-with-yaml,py310-with-sphinx{5,6,7},py310-with-tomli,package,coverage-all |
| 23 | py3.11 = py311,py311-with-yaml,py311-with-sphinx{5,6,7},py311-with-tomli,package,coverage-all |
| 24 | py3.12 = py312,py312-with-yaml,py312-with-sphinx{5,6,7},py312-with-tomli,package,coverage-all |
| 25 | docs = docs-test-{html,coverage,doctest} |
| 26 | docs-full = docs-test-{html,linkcheck,coverage,doctest,spelling} |
| 27 | |
| 28 | |
| 29 | [testenv] |
| 30 | description = basic config env |
| 31 | base_python = python3.11 |
| 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 src/rstcheck_core |
| 84 | mypy tests |
| 85 | mypy docs/source/conf.py |
| 86 | mypy prep_release.py |
| 87 | |
| 88 | |
| 89 | [testenv:pylint] |
| 90 | description = run pylint linter |
| 91 | deps = |
| 92 | pylint >= 2.12 |
| 93 | extras = |
| 94 | toml |
| 95 | docs |
| 96 | testing |
| 97 | commands = |
| 98 | pylint src/rstcheck_core tests docs/source/conf.py prep_release.py |
| 99 | |
| 100 | |
| 101 | [testenv:package] |
| 102 | description = check sdist and wheel |
| 103 | skip_install = true |
| 104 | deps = |
| 105 | build >= 1 |
| 106 | twine >= 3.3 |
| 107 | commands = |
| 108 | python -m build |
| 109 | twine check --strict dist/* |
| 110 | |
| 111 | |
| 112 | [testenv:py{312,311,310,39,38}] |
| 113 | description = run tests with {basepython} |
| 114 | pass_env = |
| 115 | {[testenv]pass_env} |
| 116 | PYTEST_* |
| 117 | set_env = |
| 118 | {[testenv]set_env} |
| 119 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 120 | extras = |
| 121 | testing |
| 122 | commands = |
| 123 | pytest \ |
| 124 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 125 | --basetemp {envtmpdir} \ |
| 126 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 127 | --cov-fail-under 0 \ |
| 128 | {tty::-vvv} \ |
| 129 | {posargs:tests} |
| 130 | |
| 131 | |
| 132 | [testenv:py{312,311,310,39,38}-with-yaml] |
| 133 | description = run tests with {basepython} |
| 134 | pass_env = |
| 135 | {[testenv]pass_env} |
| 136 | PYTEST_* |
| 137 | set_env = |
| 138 | {[testenv]set_env} |
| 139 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 140 | extras = |
| 141 | testing |
| 142 | yaml |
| 143 | commands = |
| 144 | pytest \ |
| 145 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 146 | --basetemp {envtmpdir} \ |
| 147 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 148 | --cov-fail-under 0 \ |
| 149 | {tty::-vvv} \ |
| 150 | {posargs:tests} |
| 151 | |
| 152 | |
| 153 | [testenv:py{312,311,310,39,38}-with-sphinx{5,6,7}] |
| 154 | description = run tests with {basepython} and sphinx |
| 155 | pass_env = |
| 156 | {[testenv]pass_env} |
| 157 | PYTEST_* |
| 158 | set_env = |
| 159 | {[testenv]set_env} |
| 160 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 161 | extras = |
| 162 | testing |
| 163 | yaml |
| 164 | deps = |
| 165 | sphinx5: sphinx>=5,<6 |
| 166 | sphinx6: sphinx>=6,<7 |
| 167 | sphinx7: sphinx>=7,<8 |
| 168 | commands = |
| 169 | pytest \ |
| 170 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 171 | --basetemp {envtmpdir} \ |
| 172 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 173 | --cov-fail-under 0 \ |
| 174 | {tty::-vvv} \ |
| 175 | {posargs:tests} |
| 176 | |
| 177 | |
| 178 | [testenv:py{312,311,310,39,38}-with-tomli] |
| 179 | description = run tests with {basepython} and toml |
| 180 | pass_env = |
| 181 | {[testenv]pass_env} |
| 182 | PYTEST_* |
| 183 | set_env = |
| 184 | {[testenv]set_env} |
| 185 | COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}} |
| 186 | extras = |
| 187 | testing |
| 188 | toml |
| 189 | yaml |
| 190 | commands = |
| 191 | pytest \ |
| 192 | {tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \ |
| 193 | --basetemp {envtmpdir} \ |
| 194 | --cov {envsitepackagesdir}/{[tox]package} \ |
| 195 | --cov-fail-under 0 \ |
| 196 | {tty::-vvv} \ |
| 197 | {posargs:tests} |
| 198 | |
| 199 | |
| 200 | [testenv:coverage-{all,merge,report}] |
| 201 | description = |
| 202 | all,merge: combine coverage data and create xml/html reports; |
| 203 | all,report: report total and diff coverage against origin/main (or DIFF_AGAINST) |
| 204 | env_dir = {toxworkdir}/coverage |
| 205 | depends = py{py3,312,311,310,39,38} |
| 206 | pass_env = |
| 207 | {[testenv]pass_env} |
| 208 | all,report: MIN_COVERAGE |
| 209 | all,report: MIN_DIFF_COVERAGE |
| 210 | all,report: DIFF_AGAINST |
| 211 | all,report: DIFF_RANGE_NOTATION |
| 212 | set_env = |
| 213 | {[testenv]set_env} |
| 214 | COVERAGE_FILE={toxinidir}/.coverage_cache/.coverage |
| 215 | skip_install = true |
| 216 | parallel_show_output = true |
| 217 | ignore_errors = true |
| 218 | deps = |
| 219 | diff-cover |
| 220 | coverage[toml] >=6.0 |
| 221 | coverage-conditional-plugin >=0.5 |
| 222 | commands = |
| 223 | all,merge: coverage combine |
| 224 | all,merge: coverage xml -o {toxinidir}/.coverage_cache/coverage.xml |
| 225 | all,merge: coverage html -d {toxinidir}/.coverage_cache/htmlcov |
| 226 | all,report: coverage report -m --fail-under {env:MIN_COVERAGE:0} |
| 227 | all,report: diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} \ |
| 228 | all,report: --ignore-staged --ignore-unstaged \ |
| 229 | all,report: --fail-under {env:MIN_DIFF_COVERAGE:0} \ |
| 230 | all,report: --diff-range-notation {env:DIFF_RANGE_NOTATION:..} \ |
| 231 | all,report: {toxinidir}/.coverage_cache/coverage.xml |
| 232 | |
| 233 | |
| 234 | [testenv:docs{,-auto}] |
| 235 | description = build docs with sphinx |
| 236 | env_dir = {toxworkdir}/docs |
| 237 | set_env = |
| 238 | {[testenv]set_env} |
| 239 | TOXENV_BUILDCMD = sphinx-build {tty:--color:} |
| 240 | auto: TOXENV_BUILDCMD = sphinx-autobuild --re-ignore autoapidoc --watch {toxinidir}/src |
| 241 | extras = |
| 242 | toml |
| 243 | docs |
| 244 | commands = |
| 245 | # Build fresh docs |
| 246 | {env:TOXENV_BUILDCMD} -b html -aE docs/source docs/build/html |
| 247 | # Output link to index.html |
| 248 | python -c \ |
| 249 | 'from pathlib import Path; \ |
| 250 | index_file = Path(r"{toxinidir}")/"docs/build/html/index.html"; \ |
| 251 | print(f"DOCUMENTATION AVAILABLE UNDER: \{index_file.as_uri()\}")' |
| 252 | |
| 253 | |
| 254 | [testenv:docs-test-{html,linkcheck,coverage,doctest,spelling}] |
| 255 | description = Build and check docs with (see env name) sphinx builder |
| 256 | env_dir = {[testenv:docs]env_dir} |
| 257 | set_env = |
| 258 | {[testenv]set_env} |
| 259 | html: TOXENV_BUILDER = html |
| 260 | linkcheck: TOXENV_BUILDER = linkcheck |
| 261 | coverage: TOXENV_BUILDER = coverage |
| 262 | doctest: TOXENV_BUILDER = doctest |
| 263 | spelling: TOXENV_BUILDER = spelling |
| 264 | spelling: SPHINX_SPELLING = true |
| 265 | extras = {[testenv:docs]extras} |
| 266 | commands = |
| 267 | sphinx-build \ |
| 268 | {tty:--color:{env:CI_FORCE_COLORS_SPHINX:}} \ |
| 269 | -b {env:TOXENV_BUILDER} \ |
| 270 | -aE -v -nW --keep-going \ |
| 271 | docs/source docs/build/test/{env:TOXENV_BUILDER} |