blob: 2f842309ff5796d2d1a967695ddbe92da22a7035 [file] [log] [blame]
garciadeblas66834562022-11-10 14:07:04 +01001#######################################################################################
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]
garciadeblas02f71cd2023-05-23 21:57:36 +020019envlist = black, flake8, pylint, pylint-webhook
garciadeblas66834562022-11-10 14:07:04 +010020
21[tox:jenkins]
22toxworkdir = /tmp/.tox
23setenv = XDG_CACHE_HOME=/tmp/.cache
24
25[testenv]
26usedevelop = True
garciadeblas4e365052023-03-23 13:25:27 +010027basepython = python3.10
garciadeblas66834562022-11-10 14:07:04 +010028setenv = VIRTUAL_ENV={envdir}
29 PYTHONDONTWRITEBYTECODE = 1
30deps = -r{toxinidir}/requirements.txt
31parallel_show_output = true
32
33
34#######################################################################################
35[testenv:black]
garciadeblasce867de2026-01-20 12:40:18 +010036deps = black==25.12.0
garciadeblas66834562022-11-10 14:07:04 +010037skip_install = true
38commands =
garciadeblasd0671572023-03-27 14:22:09 +020039 black --check --diff src setup.py
garciadeblas9cbad102023-04-05 11:09:19 +020040 black --check --diff osm_webhook_translator
garciadeblas66834562022-11-10 14:07:04 +010041
42
43#######################################################################################
44[testenv:cover]
45deps = {[testenv]deps}
46 -r{toxinidir}/requirements-dev.txt
47 -r{toxinidir}/requirements-test.txt
garciadeblas239971d2023-03-23 11:46:36 +010048allowlist_externals = sh
garciadeblas66834562022-11-10 14:07:04 +010049commands =
50 sh -c 'rm -f nosetests.xml'
51 coverage erase
52 nose2 -C --coverage src -s src
garciadeblas9cbad102023-04-05 11:09:19 +020053 sh -c 'mv .coverage .coverage_ngsa'
54 nose2 -C --coverage osm_webhook_translator -s osm_webhook_translator
55 sh -c 'mv .coverage .coverage_webhook_translator'
garciadeblas66834562022-11-10 14:07:04 +010056 coverage report --omit='*tests*'
57 coverage html -d ./cover --omit='*tests*'
58 coverage xml -o coverage.xml --omit='*tests*'
59
60
61#######################################################################################
62[testenv:flake8]
garciadeblas998ff732022-11-10 14:19:44 +010063deps = flake8==5.0.4
garciadeblas66834562022-11-10 14:07:04 +010064 flake8-import-order
garciadeblas38e3eb52025-03-04 12:10:26 +010065 setuptools>=61
66 setuptools_scm==8.0.4
garciadeblas66834562022-11-10 14:07:04 +010067commands =
garciadeblasd0671572023-03-27 14:22:09 +020068 flake8 src setup.py
garciadeblas9cbad102023-04-05 11:09:19 +020069 flake8 osm_webhook_translator
garciadeblas66834562022-11-10 14:07:04 +010070
71
72#######################################################################################
73[testenv:pylint]
74deps = {[testenv]deps}
75 -r{toxinidir}/requirements-dev.txt
76 -r{toxinidir}/requirements-test.txt
77 pylint
78skip_install = true
79commands =
aguilardf6357af2023-10-31 13:03:12 +000080 pylint -E src setup.py --disable=E0401 --disable=E1111
garciadeblas02f71cd2023-05-23 21:57:36 +020081
82
83[testenv:pylint-webhook]
84changedir = {toxinidir}/osm_webhook_translator
85deps = -r{toxinidir}/osm_webhook_translator/requirements.txt
86 pylint
87skip_install = true
88commands =
89 pylint -E src setup.py
garciadeblas66834562022-11-10 14:07:04 +010090
91
92#######################################################################################
93[testenv:safety]
94setenv =
95 LC_ALL=C.UTF-8
96 LANG=C.UTF-8
97deps = {[testenv]deps}
98 safety
99commands =
100 - safety check --full-report
101
102
103#######################################################################################
104[testenv:pip-compile]
garciadeblascc9870f2023-05-10 11:03:41 +0200105deps = pip-tools==6.13.0
garciadeblas66834562022-11-10 14:07:04 +0100106skip_install = true
garciadeblas239971d2023-03-23 11:46:36 +0100107allowlist_externals =
garciadeblas66834562022-11-10 14:07:04 +0100108 bash
109 [
110commands =
111 bash -c "for file in requirements*.in ; do \
112 UNSAFE="" ; \
113 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
garciadeblascc9870f2023-05-10 11:03:41 +0200114 pip-compile -rU --resolver=backtracking --no-header $UNSAFE $file ;\
garciadeblas66834562022-11-10 14:07:04 +0100115 out=`echo $file | sed 's/.in/.txt/'` ; \
116 sed -i -e '1 e head -16 tox.ini' $out ;\
117 done"
garciadeblas9cbad102023-04-05 11:09:19 +0200118 bash -c "for file in osm_webhook_translator/requirements*.in ; do \
119 UNSAFE="" ; \
120 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
garciadeblas4e365052023-03-23 13:25:27 +0100121 pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\
garciadeblas9cbad102023-04-05 11:09:19 +0200122 out=`echo $file | sed 's/.in/.txt/'` ; \
123 sed -i -e '1 e head -16 tox.ini' $out ;\
124 done"
garciadeblas66834562022-11-10 14:07:04 +0100125
126
127#######################################################################################
garciadeblas9cbad102023-04-05 11:09:19 +0200128[testenv:dist_ng_sa]
garciadeblas8d41d562022-11-24 14:42:35 +0100129deps = {[testenv]deps}
130 -r{toxinidir}/requirements-dist.txt
garciadeblas9cbad102023-04-05 11:09:19 +0200131allowlist_externals = sh
garciadeblas8d41d562022-11-24 14:42:35 +0100132commands =
133 sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
134 sh -c 'cp README.rst src/osm_ngsa/README.rst'
135 python3 setup.py --command-packages=stdeb.command sdist_dsc
136 sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
137 sh -c 'rm src/osm_ngsa/requirements.txt'
138 sh -c 'rm src/osm_ngsa/README.rst'
garciadeblas9cbad102023-04-05 11:09:19 +0200139
140
141#######################################################################################
142[testenv:dist_webhook_translator]
143deps = -r{toxinidir}/osm_webhook_translator/requirements.txt
144 -r{toxinidir}/osm_webhook_translator/requirements-dist.txt
garciadeblas239971d2023-03-23 11:46:36 +0100145allowlist_externals = sh
garciadeblas9cbad102023-04-05 11:09:19 +0200146commands =
147 sh -c 'cp src/osm_ngsa/_version.py osm_webhook_translator/src/osm_webhook_translator/_version.py'
148 sh -c 'cd osm_webhook_translator && cp requirements.txt src/osm_webhook_translator/requirements.txt'
149 sh -c 'cd osm_webhook_translator && cp README.rst src/osm_webhook_translator/README.rst'
150 sh -c 'cd osm_webhook_translator && python3 setup.py --command-packages=stdeb.command sdist_dsc'
151 sh -c 'cd osm_webhook_translator/deb_dist/osm-webhook-translator*/ && dpkg-buildpackage -rfakeroot -uc -us'
152 sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/requirements.txt'
153 sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/README.rst'
garciadeblas8d41d562022-11-24 14:42:35 +0100154
155
156#######################################################################################
garciadeblas66834562022-11-10 14:07:04 +0100157[flake8]
158ignore =
159 W291,
160 W293,
161 W503,
162 W605,
163 E123,
164 E125,
165 E203,
166 E226,
167 E241,
168 E501,
169exclude =
170 .git,
171 __pycache__,
172 .tox,
173max-line-length = 120
174show-source = True
175builtins = _
176import-order-style = google