Minor change in tox.ini related to flake8 env
[osm/NG-SA.git] / tox.ini
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 [tox]
19 envlist = black, flake8
20
21 [tox:jenkins]
22 toxworkdir = /tmp/.tox
23 setenv = XDG_CACHE_HOME=/tmp/.cache
24
25 [testenv]
26 usedevelop = True
27 basepython = python3
28 setenv = VIRTUAL_ENV={envdir}
29 PYTHONDONTWRITEBYTECODE = 1
30 deps = -r{toxinidir}/requirements.txt
31 parallel_show_output = true
32
33
34 #######################################################################################
35 [testenv:black]
36 deps = black
37 skip_install = true
38 commands =
39 black --check --diff src
40
41
42 #######################################################################################
43 [testenv:cover]
44 deps = {[testenv]deps}
45 -r{toxinidir}/requirements-dev.txt
46 -r{toxinidir}/requirements-test.txt
47 allowlist_externals = sh
48 commands =
49 sh -c 'rm -f nosetests.xml'
50 coverage erase
51 nose2 -C --coverage src -s src
52 sh -c 'mv .coverage .coverage_mon'
53 coverage report --omit='*tests*'
54 coverage html -d ./cover --omit='*tests*'
55 coverage xml -o coverage.xml --omit='*tests*'
56
57
58 #######################################################################################
59 [testenv:flake8]
60 deps = flake8==5.0.4
61 flake8-import-order
62 commands =
63 flake8 src/
64
65
66 #######################################################################################
67 [testenv:pylint]
68 deps = {[testenv]deps}
69 -r{toxinidir}/requirements-dev.txt
70 -r{toxinidir}/requirements-test.txt
71 pylint
72 skip_install = true
73 commands =
74 pylint -E src
75
76
77 #######################################################################################
78 [testenv:safety]
79 setenv =
80 LC_ALL=C.UTF-8
81 LANG=C.UTF-8
82 deps = {[testenv]deps}
83 safety
84 commands =
85 - safety check --full-report
86
87
88 #######################################################################################
89 [testenv:pip-compile]
90 deps = pip-tools==6.6.2
91 skip_install = true
92 allowlist_externals =
93 bash
94 [
95 commands =
96 bash -c "for file in requirements*.in ; do \
97 UNSAFE="" ; \
98 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
99 pip-compile -rU --no-header $UNSAFE $file ;\
100 out=`echo $file | sed 's/.in/.txt/'` ; \
101 sed -i -e '1 e head -16 tox.ini' $out ;\
102 done"
103
104
105 #######################################################################################
106 [testenv:dist]
107 deps = {[testenv]deps}
108 -r{toxinidir}/requirements-dist.txt
109
110 # In the commands, we copy the requirements.txt to be presented as a source file (.py)
111 # so it gets included in the .deb package for others to consume
112 commands =
113 sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
114 sh -c 'cp README.rst src/osm_ngsa/README.rst'
115 python3 setup.py --command-packages=stdeb.command sdist_dsc
116 sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
117 sh -c 'rm src/osm_ngsa/requirements.txt'
118 sh -c 'rm src/osm_ngsa/README.rst'
119 allowlist_externals = sh
120
121
122 #######################################################################################
123 [flake8]
124 ignore =
125 W291,
126 W293,
127 W503,
128 W605,
129 E123,
130 E125,
131 E203,
132 E226,
133 E241,
134 E501,
135 exclude =
136 .git,
137 __pycache__,
138 .tox,
139 max-line-length = 120
140 show-source = True
141 builtins = _
142 import-order-style = google