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