Added XDG_CACHE_HOME env variable to jenkins tox env
[osm/common.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, cover, flake8, pylint, safety
20
21 [tox:jenkins]
22 toxworkdir = /tmp/.tox
23 setenv = XDG_CACHE_HOME=/tmp/.cache
24
25 [testenv]
26 usedevelop = True
27 basepython = python3.8
28 setenv = VIRTUAL_ENV={envdir}
29 PYTHONDONTWRITEBYTECODE = 1
30 deps = -r{toxinidir}/requirements.txt
31
32
33 #######################################################################################
34 [testenv:black]
35 deps = black
36 skip_install = true
37 commands =
38 black --check --diff osm_common/
39 black --check --diff setup.py
40
41 #######################################################################################
42 [testenv:cover]
43 deps = {[testenv]deps}
44 -r{toxinidir}/requirements-test.txt
45 commands =
46 sh -c 'rm -f nosetests.xml'
47 coverage erase
48 nose2 -C --coverage osm_common -s osm_common/tests
49 coverage report --omit='*tests*'
50 coverage html -d ./cover --omit='*tests*'
51 coverage xml -o coverage.xml --omit=*tests*
52 whitelist_externals = sh
53
54 #######################################################################################
55 [testenv:flake8]
56 deps =
57 flake8==5.0.4
58 flake8-import-order
59 commands =
60 flake8 osm_common/ setup.py
61
62 #######################################################################################
63 [testenv:pylint]
64 deps = {[testenv]deps}
65 -r{toxinidir}/requirements-test.txt
66 pylint
67 commands =
68 pylint -E osm_common
69
70 #######################################################################################
71 [testenv:safety]
72 setenv =
73 LC_ALL=C.UTF-8
74 LANG=C.UTF-8
75 deps = {[testenv]deps}
76 safety
77 commands =
78 - safety check --full-report
79
80 #######################################################################################
81 [testenv:pip-compile]
82 deps = pip-tools==6.6.2
83 skip_install = true
84 whitelist_externals = bash
85 [
86 commands =
87 - bash -c "for file in requirements*.in ; do \
88 UNSAFE="" ; \
89 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
90 pip-compile -rU --no-header $UNSAFE $file ;\
91 out=`echo $file | sed 's/.in/.txt/'` ; \
92 sed -i -e '1 e head -16 tox.ini' $out ;\
93 done"
94
95 #######################################################################################
96 [testenv:dist]
97 deps = {[testenv]deps}
98 -r{toxinidir}/requirements-dist.txt
99
100 # In the commands, we copy the requirements.txt to be presented as a source file (.py)
101 # so it gets included in the .deb package for others to consume
102 commands =
103 sh -c 'cp requirements.txt osm_common/requirements.txt'
104 python3 setup.py --command-packages=stdeb.command sdist_dsc
105 sh -c 'cd deb_dist/osm-common*/ && dpkg-buildpackage -rfakeroot -uc -us'
106 sh -c 'rm osm_common/requirements.txt'
107 whitelist_externals = sh
108
109 #######################################################################################
110 [testenv:release_notes]
111 deps = reno
112 skip_install = true
113 whitelist_externals = bash
114 commands =
115 reno new {posargs:new_feature}
116 bash -c "sed -i -e '1 e head -16 tox.ini' releasenotes/notes/{posargs:new_feature}*.yaml"
117
118 #######################################################################################
119 [flake8]
120 ignore =
121 W291,
122 W293,
123 W503,
124 E123,
125 E125,
126 E203,
127 E226,
128 E241
129 exclude =
130 .git,
131 __pycache__,
132 .tox,
133 max-line-length = 120
134 show-source = True
135 builtins = _
136 import-order-style = google