summaryrefslogtreecommitdiffstats
path: root/tox.ini
blob: 959905507ca9ae6989556d2e7e28c38000dfe04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
[tox]
minversion = 3.16.1
envlist = lint,py{38,37,36}-ansible{29,28,210,devel}
isolated_build = true
requires =
  setuptools >= 41.4.0
  pip >= 19.3.0
skip_missing_interpreters = True
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false

[testenv]
description =
  Run the tests with pytest under {basepython}
deps =
  ansible28: ansible>=2.8,<2.9
  ansible29: ansible>=2.9,<2.10
  ansible210: ansible>=2.10.0a1,<2.11
  # Be sure we do not install old ansible from default deps
  # https://github.com/ansible/ansible/issues/70705
  ansibledevel: ansible>=2.10.0a1,<2.11
  ansibledevel: ansible-base @ git+https://github.com/ansible/ansible.git
  -r test-requirements.in
  -c test-requirements.txt
commands =
  # safety measure to assure we do not accidentaly run tests with broken dependencies
  python -m pip check
  {envpython} -m pytest \
  --cov "{envsitepackagesdir}/ansiblelint" \
  --junitxml "{toxworkdir}/junit.{envname}.xml" \
  {posargs:}
install_command =
  {envpython} -m \
    pip install \
    {opts} \
    {packages}
passenv =
  CURL_CA_BUNDLE  # https proxies, https://github.com/tox-dev/tox/issues/1437
  HOME
  REQUESTS_CA_BUNDLE  # https proxies
  SSL_CERT_FILE  # https proxies
# recreate = True
setenv =
  ANSIBLE_COLLECTIONS_PATHS = {envtmpdir}
  COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
  PIP_DISABLE_PIP_VERSION_CHECK = 1
whitelist_externals =
  ansibledevel: sh

[testenv:.dev-env]
#basepython = python3
basepython = /home/wk/.pyenv/versions/ansible-lint-py3.8.0-pyenv-venv/bin/python3
#{[testenv]deps}
deps =
#  virtualenv >= 16
#  setuptools >= 45.0.0
isolated_build = false
skip_install = true
recreate = false
usedevelop = false

[testenv:build-dists]
basepython = python3
description =
  Build dists with PEP 517 and save them in the dist/ dir
skip_install = true
deps =
  pep517 >= 0.7.0
commands =
  {envpython} -c 'import os.path, shutil, sys; \
  dist_dir = os.path.join("{toxinidir}", "dist"); \
  os.path.isdir(dist_dir) or sys.exit(0); \
  print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \
  shutil.rmtree(dist_dir)'
  {envpython} -m pep517.build \
    --source \
    --binary \
    --out-dir {toxinidir}/dist/ \
    {toxinidir}

# deprecated: use more generic 'lint' instead
[testenv:flake8]
deps = {[testenv:lint]deps}
envdir = {toxworkdir}/lint
skip_install = true
commands =
  python -m pre_commit run --all-files flake8

[testenv:lint]
basepython = python3
deps =
  pre-commit>=2.6.0
skip_install = true
commands =
  python -m pre_commit run {posargs:--all-files --hook-stage manual -v}
passenv =
  {[testenv]passenv}
  PRE_COMMIT_HOME

[testenv:docs]
basepython = python3
deps =
  -r{toxinidir}/docs/requirements.in
  -c{toxinidir}/docs/requirements.txt
commands =
  # Build the html docs with Sphinx:
  {envpython} -m sphinx \
    -j auto \
    -b html \
    --color \
    -a \
    -n \
    -W \
    -d "{temp_dir}/.doctrees" \
    . \
    "{envdir}/html"

  # Print out the output docs dir and a way to serve html:
  -{envpython} -c \
  'import pathlib; docs_dir = pathlib.Path(r"{envdir}") / "html"; index_file = docs_dir / "index.html"; '\
  'print("\n" + "=" * 120 + f"\n\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n\n" + "=" * 120)'
changedir = {toxinidir}/docs

[testenv:metadata-validation]
basepython = python3
description =
  Verify that dists under the dist/ dir have valid metadata
depends = build-dists
deps =
  twine
skip_install = true
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands =
  twine check {toxinidir}/dist/*