blob: 66467c7325b15defbb967e27d7046fd4221eaa86 [file] [log] [blame]
beierlmb483b922021-02-11 14:57:14 -05001#######################################################################################
2# Copyright ETSI Contributors and Others.
tierno87858ca2018-10-08 16:30:15 +02003#
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.
beierlmb483b922021-02-11 14:57:14 -050016#######################################################################################
tierno87858ca2018-10-08 16:30:15 +020017
tierno5c012612018-04-19 16:01:59 +020018[tox]
beierlmb483b922021-02-11 14:57:14 -050019envlist = black, cover, flake8, pylint, safety
20
21[tox:jenkins]
22toxworkdir = /tmp/.tox
garciadeblas9703a082023-04-04 17:09:40 +020023setenv = XDG_CACHE_HOME=/tmp/.cache
garciadeblasa8747992020-07-03 10:59:34 +000024
25[testenv]
26usedevelop = True
beierlmb0291ff2022-01-13 11:37:31 -050027basepython = python3.8
beierlmb483b922021-02-11 14:57:14 -050028setenv = VIRTUAL_ENV={envdir}
29 PYTHONDONTWRITEBYTECODE = 1
30deps = -r{toxinidir}/requirements.txt
garciadeblasa8747992020-07-03 10:59:34 +000031
garciadeblasa8747992020-07-03 10:59:34 +000032
beierlmb483b922021-02-11 14:57:14 -050033#######################################################################################
34[testenv:black]
garciadeblasc9512e22024-01-29 19:26:17 +010035deps = black==23.12.1
beierlmb483b922021-02-11 14:57:14 -050036skip_install = true
garciadeblasa8747992020-07-03 10:59:34 +000037commands =
garciadeblas2644b762021-03-24 09:21:01 +010038 black --check --diff osm_common/
39 black --check --diff setup.py
tierno5c012612018-04-19 16:01:59 +020040
beierlmb483b922021-02-11 14:57:14 -050041#######################################################################################
42[testenv:cover]
43deps = {[testenv]deps}
44 -r{toxinidir}/requirements-test.txt
45commands =
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*
52whitelist_externals = sh
tierno5c012612018-04-19 16:01:59 +020053
beierlmb483b922021-02-11 14:57:14 -050054#######################################################################################
tierno5c012612018-04-19 16:01:59 +020055[testenv:flake8]
aticig3dd0db62022-03-04 19:35:45 +030056deps =
Mark Beierleef25c02022-11-28 06:29:24 -050057 flake8==5.0.4
aticig3dd0db62022-03-04 19:35:45 +030058 flake8-import-order
tierno5c012612018-04-19 16:01:59 +020059commands =
beierlmb483b922021-02-11 14:57:14 -050060 flake8 osm_common/ setup.py
tierno5c012612018-04-19 16:01:59 +020061
beierlmb483b922021-02-11 14:57:14 -050062#######################################################################################
63[testenv:pylint]
64deps = {[testenv]deps}
65 -r{toxinidir}/requirements-test.txt
66 pylint
67commands =
garciadeblas2644b762021-03-24 09:21:01 +010068 pylint -E osm_common
tierno136f2952018-10-19 13:01:03 +020069
beierlmb483b922021-02-11 14:57:14 -050070#######################################################################################
71[testenv:safety]
72setenv =
73 LC_ALL=C.UTF-8
74 LANG=C.UTF-8
75deps = {[testenv]deps}
76 safety
77commands =
78 - safety check --full-report
garciadeblasa8747992020-07-03 10:59:34 +000079
beierlmb483b922021-02-11 14:57:14 -050080#######################################################################################
81[testenv:pip-compile]
garciadeblas22cd57a2022-06-24 17:35:34 +020082deps = pip-tools==6.6.2
beierlmb0291ff2022-01-13 11:37:31 -050083skip_install = true
84whitelist_externals = bash
85 [
beierlmb483b922021-02-11 14:57:14 -050086commands =
beierlmb0291ff2022-01-13 11:37:31 -050087 - 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"
beierlmb483b922021-02-11 14:57:14 -050094
95#######################################################################################
96[testenv:dist]
97deps = {[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
102commands =
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'
107whitelist_externals = sh
108
109#######################################################################################
aticig3dd0db62022-03-04 19:35:45 +0300110[testenv:release_notes]
111deps = reno
112skip_install = true
113whitelist_externals = bash
114commands =
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#######################################################################################
beierlmb483b922021-02-11 14:57:14 -0500119[flake8]
120ignore =
121 W291,
122 W293,
garciadeblas2644b762021-03-24 09:21:01 +0100123 W503,
beierlmb483b922021-02-11 14:57:14 -0500124 E123,
125 E125,
garciadeblas2644b762021-03-24 09:21:01 +0100126 E203,
beierlmb483b922021-02-11 14:57:14 -0500127 E226,
128 E241
129exclude =
130 .git,
131 __pycache__,
132 .tox,
133max-line-length = 120
134show-source = True
135builtins = _
aticig3dd0db62022-03-04 19:35:45 +0300136import-order-style = google