summaryrefslogtreecommitdiff
path: root/tox.ini
blob: 7724b5c36d6175e2c3edb6d379335e50e8f21dd0 (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
[tox]
envlist = py27,pep8,cover
minversion = 2.7
skipsdist = True

[testenv]
setenv =
    VIRTUAL_ENV={envdir}
    OS_TEST_PATH=monasca_api/tests
passenv = *_proxy
          *_PROXY
usedevelop = True
install_command = pip install {opts} {packages}
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
  .[influxdb,cassandra]
whitelist_externals = bash
                      find
                      rm
commands =
  find . -type f -name "*.pyc" -delete
  stestr run {posargs}

[testenv:cover]
basepython = python3
commands =
  coverage erase
  python setup.py test --coverage --testr-args='{posargs}' \
    --coverage-package-name=monasca_api --omit=monasca_api/hacking/*
  coverage report

[testenv:debug]
basepython = python3
commands =
  oslo_debug_helper -t ./monasca_api/tests {posargs}

[testenv:flake8]
basepython = python3
skip_install = True
usedevelop = False
commands =
  flake8 monasca_api

[testenv:bandit]
basepython = python3
skip_install = True
usedevelop = False
commands =
  # B101(assert_ussed) - API uses asserts because of performance reasons
  # B303 - Fingerprint class uses SHA1 to map fingerprints to alembic revisions.
  bandit -r monasca_api -n5 -s B101,B303 -x monasca_api/tests

[testenv:bashate]
basepython = python3
skip_install = True
usedevelop = False
commands = bash {toxinidir}/tools/bashate.sh

[testenv:pep8]
basepython = python3
commands =
  {[testenv:flake8]commands}
  {[testenv:bandit]commands}
  {[testenv:bashate]commands}
  {[testenv:checkniceness]commands}

[testenv:docs]
basepython = python3
description = Builds api-ref, api-guide, releasenotes and devdocs
commands =
  {[testenv:devdocs]commands}
  {[testenv:api-ref]commands}
  {[testenv:releasenotes]commands}

[testenv:api-ref]
basepython = python3
description = Called from CI scripts to test and publish the API Ref
commands =
  rm -rf api-ref/build
  {[testenv:checkjson]commands}
  sphinx-build -W -b html -d api-ref/build/doctrees \
    api-ref/source api-ref/build/html

[testenv:releasenotes]
basepython = python3
description = Called from CI script to test and publish the Release Notes
commands =
  rm -rf releasenotes/build
  sphinx-build -a -E -W -d releasenotes/build/doctrees -b html \
    releasenotes/source releasenotes/build/html

[testenv:devdocs]
basepython = python3
description = Builds developer documentation
commands =
  rm -rf doc/build doc/source/contributor/api
  {[testenv:checkjson]commands}
  python setup.py build_sphinx

[testenv:checkniceness]
basepython = python3
skip_install = True
usedevelop = False
description = Validates (pep-like) documenation
commands =
  rm -rf {toxinidir}/doc/source/contributor/api {toxinidir}/doc/build \
    {toxinidir}/api-ref/build {toxinidir}/releasenotes/build
  doc8 --file-encoding utf-8 {toxinidir}/doc
  doc8 --file-encoding utf-8 {toxinidir}/api-ref
  doc8 --file-encoding utf-8 {toxinidir}/releasenotes

[testenv:checkjson]
basepython = python3
description = Validates all json samples inside doc folder
deps =
skip_install = True
usedevelop = False
whitelist_externals =
  python
  bash
commands =
  bash -c "! find doc/ -type f -name *.json | xargs grep -U -n $'\r'"
  bash -c '! find doc/ -type f -name *.json | \
    xargs -t -n1 python -m json.tool 2>&1 > /dev/null | grep -B1 -v ^python'

[testenv:genconfig]
basepython = python3
description = Generates sample configuration file for monasca-api
commands = oslo-config-generator --config-file=config-generator/monasca-api.conf

[testenv:genpolicy]
basepython = python3
description = Generates sample policy.json file for monasca-api
commands = oslopolicy-sample-generator --config-file=config-generator/policy.conf

[testenv:venv]
basepython = python3
commands = {posargs}

[testenv:bindep]
basepython = python3
deps = bindep
commands = bindep test

[flake8]
# TODO: ignored checks should be enabled in the future
# H201  no 'except:' at least use 'except Exception:'
# H302  import only modules
# H405  multi line docstring summary not separated with an empty line
ignore = F821,H201,H302,H405
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality.
# H205: Use assert(Greater|Less)(Equal) for comparison.
enable-extensions=H106,H203,H204,H205
max-complexity = 50
max-line-length = 100
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,build
show-source = True

[hacking]
local-check-factory = monasca_api.hacking.checks.factory
import_exceptions =
  six.moves

[testenv:lower-constraints]
basepython = python3
deps =
  -c{toxinidir}/lower-constraints.txt
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
  .[influxdb,cassandra]