]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/tox.ini
47756e946e125facafcecb6d2d94917317ff81df
[ceph.git] / ceph / src / pybind / mgr / dashboard / tox.ini
1 [tox]
2 envlist =
3 py3,
4 lint,
5 fix,
6 check,
7 run,
8 openapi-{check, fix, doc}
9 skipsdist = true
10 minversion = 2.9.1
11
12 [pytest]
13 addopts =
14 --cov --cov-append --cov-report=term
15 --doctest-modules
16 --ignore=frontend/ --ignore=module.py
17 --instafail
18
19 [base]
20 deps =
21 -rrequirements.txt
22 -cconstraints.txt
23
24 [base-test]
25 deps =
26 -rrequirements-test.txt
27
28 [base-lint]
29 deps =
30 -rrequirements-lint.txt
31
32 [testenv]
33 basepython=python3
34 deps =
35 {[base]deps}
36 {[base-test]deps}
37 -rrequirements-extra.txt
38 passenv =
39 PYTHONPATH
40 setenv =
41 PYTHONPATH=$PYTHONPATH:../..
42 CFLAGS = -DXMLSEC_NO_SIZE_T
43 PYTHONUNBUFFERED=1
44 PYTHONDONTWRITEBYTECODE=1
45 UNITTEST = true
46 WEBTEST_INTERACTIVE = false
47 commands =
48 pytest {posargs}
49
50 [testenv:run]
51 deps =
52 {[base]deps}
53 {[base-test]deps}
54 {[base-lint]deps}
55 allowlist_externals = *
56 commands = {posargs}
57
58 [flake8]
59 max-line-length = 100
60 ignore = E226 E402 W503 F812
61 exclude =
62 .tox,
63 .git,
64 __pycache__,
65 build,
66 dist,
67 *.egg-info,
68 .cache,
69 *.pyc,
70 .eggs,
71 venv,
72 frontend,
73 statistics = True
74 #TODO: Uncomment and refactor (https://tracker.ceph.com/issues/41221)
75 #max-complexity = 10
76 format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
77
78 [isort]
79 atomic = true
80 multi_line_output = 2
81 line_length = 100
82 wrap_length = 80
83
84 [pylint]
85 # Allow similarity/code duplication detection
86 jobs = 1
87 dirs = . api controllers plugins services tests ../../../../qa/tasks/mgr/dashboard
88 addopts = -rn --rcfile=.pylintrc --jobs={[pylint]jobs}
89
90 [rstlint]
91 dirs = README.rst HACKING.rst
92
93 [base-pylint]
94 commands =
95 pylint {[pylint]addopts} {[pylint]dirs}
96
97 [base-rst]
98 commands =
99 rstcheck --report info --debug -- {[rstlint]dirs}
100
101 [testenv:lint]
102 deps =
103 {[base]deps}
104 {[base-lint]deps}
105 commands =
106 flake8
107 flake8 --config=tox.ini ../../../../qa/tasks/mgr/dashboard
108 isort . --check
109 isort ../../../../qa/tasks/mgr/dashboard --check
110 {[base-pylint]commands}
111 {[base-rst]commands}
112
113 [testenv:flake8]
114 deps = {[base-lint]deps}
115 commands =
116 flake8 --config=tox.ini {posargs}
117
118 [testenv:pylint]
119 deps =
120 {[base]deps}
121 {[base-lint]deps}
122 commands =
123 pylint {[pylint]addopts} {posargs:{[pylint]dirs}}
124
125 [testenv:rst]
126 deps = {[base-lint]deps}
127 commands =
128 rstcheck --report info --debug -- {posargs:{[rstlint]dirs}}
129
130 [autopep8]
131 addopts =
132 --max-line-length {[flake8]max-line-length}
133 --exclude "{[flake8]exclude}"
134 --in-place
135 --recursive
136 # TODO: we should progressively increase the level of compliance with PEP8
137 # --aggressive
138 # --aggressive
139
140 [testenv:fix]
141 deps =
142 {[base-lint]deps}
143 commands =
144 python --version
145 autopep8 {[autopep8]addopts} {posargs:. ../../../../qa/tasks/mgr/dashboard}
146 isort .
147 isort ../../../../qa/tasks/mgr/dashboard
148
149 [testenv:check]
150 commands =
151 python ci/check_grafana_dashboards.py frontend/src/app ../../../../monitoring/ceph-mixin/dashboards_out
152
153 [testenv:openapi-{check,fix}]
154 allowlist_externals = diff
155 description =
156 check: Ensure that auto-generated OpenAPI Specification matches the current version
157 fix: Update auto-generated OpenAPI Specification with the latest changes
158 deps =
159 {[base]deps}
160 {[base-test]deps}
161 passenv =
162 PYTHONPATH
163 setenv =
164 UNITTEST = true
165 PYTHONPATH=$PYTHONPATH:..:../..
166 OPENAPI_FILE=openapi.yaml
167 check: OPENAPI_FILE_TMP={envtmpdir}/{env:OPENAPI_FILE}
168 commands =
169 python3 -m dashboard.controllers.docs {env:OPENAPI_FILE_TMP:{env:OPENAPI_FILE}}
170 check: diff {env:OPENAPI_FILE} {env:OPENAPI_FILE_TMP}
171
172 [testenv:openapi-doc]
173 description = Generate Sphinx documentation from OpenAPI specification
174 deps = -r../../../../admin/doc-requirements.txt
175 changedir = ../../../../doc
176 commands = sphinx-build -W -b html -c . -D suppress_warnings=ref.* -d {envtmpdir}/doctrees mgr/ceph_api {envtmpdir}/html