summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/tox.ini
blob: 47756e946e125facafcecb6d2d94917317ff81df (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
[tox]
envlist =
    py3,
    lint,
    fix,
    check,
    run,
    openapi-{check, fix, doc}
skipsdist = true
minversion = 2.9.1

[pytest]
addopts =
    --cov --cov-append --cov-report=term
    --doctest-modules
    --ignore=frontend/ --ignore=module.py
    --instafail

[base]
deps =
    -rrequirements.txt
    -cconstraints.txt

[base-test]
deps =
    -rrequirements-test.txt

[base-lint]
deps =
    -rrequirements-lint.txt

[testenv]
basepython=python3
deps =
    {[base]deps}
    {[base-test]deps}
    -rrequirements-extra.txt
passenv =
    PYTHONPATH
setenv =
    PYTHONPATH=$PYTHONPATH:../..
    CFLAGS = -DXMLSEC_NO_SIZE_T
    PYTHONUNBUFFERED=1
    PYTHONDONTWRITEBYTECODE=1
    UNITTEST = true
    WEBTEST_INTERACTIVE = false
commands =
    pytest {posargs}

[testenv:run]
deps =
    {[base]deps}
    {[base-test]deps}
    {[base-lint]deps}
allowlist_externals = *
commands = {posargs}

[flake8]
max-line-length = 100
ignore = E226 E402 W503 F812
exclude =
    .tox,
    .git,
    __pycache__,
    build,
    dist,
    *.egg-info,
    .cache,
    *.pyc,
    .eggs,
    venv,
    frontend,
statistics = True
#TODO: Uncomment and refactor (https://tracker.ceph.com/issues/41221)
#max-complexity = 10
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s

[isort]
atomic = true
multi_line_output = 2
line_length = 100
wrap_length = 80

[pylint]
# Allow similarity/code duplication detection
jobs = 1
dirs = . api controllers plugins services tests ../../../../qa/tasks/mgr/dashboard
addopts = -rn --rcfile=.pylintrc --jobs={[pylint]jobs}

[rstlint]
dirs = README.rst HACKING.rst

[base-pylint]
commands =
    pylint {[pylint]addopts} {[pylint]dirs}

[base-rst]
commands =
    rstcheck --report info --debug -- {[rstlint]dirs}

[testenv:lint]
deps =
    {[base]deps}
    {[base-lint]deps}
commands =
    flake8
    flake8 --config=tox.ini ../../../../qa/tasks/mgr/dashboard
    isort . --check
    isort ../../../../qa/tasks/mgr/dashboard --check
    {[base-pylint]commands}
    {[base-rst]commands}

[testenv:flake8]
deps = {[base-lint]deps}
commands =
    flake8 --config=tox.ini {posargs}

[testenv:pylint]
deps =
    {[base]deps}
    {[base-lint]deps}
commands =
    pylint {[pylint]addopts} {posargs:{[pylint]dirs}}

[testenv:rst]
deps = {[base-lint]deps}
commands =
    rstcheck --report info --debug -- {posargs:{[rstlint]dirs}}

[autopep8]
addopts =
    --max-line-length {[flake8]max-line-length}
    --exclude "{[flake8]exclude}"
    --in-place
    --recursive
# TODO: we should progressively increase the level of compliance with PEP8
#    --aggressive
#    --aggressive

[testenv:fix]
deps =
    {[base-lint]deps}
commands =
    python --version
    autopep8 {[autopep8]addopts} {posargs:. ../../../../qa/tasks/mgr/dashboard}
    isort .
    isort ../../../../qa/tasks/mgr/dashboard

[testenv:check]
commands =
    python ci/check_grafana_dashboards.py frontend/src/app ../../../../monitoring/ceph-mixin/dashboards_out

[testenv:openapi-{check,fix}]
allowlist_externals = diff
description =
    check: Ensure that auto-generated OpenAPI Specification matches the current version
    fix: Update auto-generated OpenAPI Specification with the latest changes
deps =
    {[base]deps}
    {[base-test]deps}
passenv =
    PYTHONPATH
setenv =
    UNITTEST = true
    PYTHONPATH=$PYTHONPATH:..:../..
    OPENAPI_FILE=openapi.yaml
    check: OPENAPI_FILE_TMP={envtmpdir}/{env:OPENAPI_FILE}
commands =
     python3 -m dashboard.controllers.docs {env:OPENAPI_FILE_TMP:{env:OPENAPI_FILE}}
     check: diff {env:OPENAPI_FILE} {env:OPENAPI_FILE_TMP}

[testenv:openapi-doc]
description = Generate Sphinx documentation from OpenAPI specification
deps = -r../../../../admin/doc-requirements.txt
changedir = ../../../../doc
commands = sphinx-build -W -b html -c . -D suppress_warnings=ref.* -d {envtmpdir}/doctrees mgr/ceph_api {envtmpdir}/html