blob: 416f6f914b1daeefb189b829b0bb8098e0c4b3d2 [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]
Dario Faccin89e04842023-05-24 16:53:58 +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
Dario Faccin89e04842023-05-24 16:53:58 +020027basepython = 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]
36deps = black
37skip_install = true
38commands =
Mark Beierl9ed3fa42023-03-01 18:51:34 +000039 black --check --diff src setup.py
40 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
Mark Beierl9ed3fa42023-03-01 18:51:34 +000048allowlist_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
Mark Beierl9ed3fa42023-03-01 18:51:34 +000053 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
garciadeblas66834562022-11-10 14:07:04 +010065commands =
Mark Beierl9ed3fa42023-03-01 18:51:34 +000066 flake8 src setup.py
67 flake8 osm_webhook_translator
garciadeblas66834562022-11-10 14:07:04 +010068
69
70#######################################################################################
71[testenv:pylint]
72deps = {[testenv]deps}
73 -r{toxinidir}/requirements-dev.txt
74 -r{toxinidir}/requirements-test.txt
75 pylint
76skip_install = true
77commands =
Dario Faccin89e04842023-05-24 16:53:58 +020078 pylint -E src setup.py --disable=E0401
79
80
81[testenv:pylint-webhook]
82changedir = {toxinidir}/osm_webhook_translator
83deps = -r{toxinidir}/osm_webhook_translator/requirements.txt
84 pylint
85skip_install = true
86commands =
87 pylint -E src setup.py
garciadeblas66834562022-11-10 14:07:04 +010088
89
90#######################################################################################
91[testenv:safety]
92setenv =
93 LC_ALL=C.UTF-8
94 LANG=C.UTF-8
95deps = {[testenv]deps}
96 safety
97commands =
98 - safety check --full-report
99
100
101#######################################################################################
102[testenv:pip-compile]
Dario Faccin89e04842023-05-24 16:53:58 +0200103deps = pip-tools==6.13.0
garciadeblas66834562022-11-10 14:07:04 +0100104skip_install = true
Mark Beierl9ed3fa42023-03-01 18:51:34 +0000105allowlist_externals =
garciadeblas66834562022-11-10 14:07:04 +0100106 bash
107 [
108commands =
109 bash -c "for file in requirements*.in ; do \
110 UNSAFE="" ; \
111 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
Dario Faccin89e04842023-05-24 16:53:58 +0200112 pip-compile -rU --resolver=backtracking --no-header $UNSAFE $file ;\
113 out=`echo $file | sed 's/.in/.txt/'` ; \
114 sed -i -e '1 e head -16 tox.ini' $out ;\
115 done"
116 bash -c "for file in osm_webhook_translator/requirements*.in ; do \
117 UNSAFE="" ; \
118 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
119 pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\
garciadeblas66834562022-11-10 14:07:04 +0100120 out=`echo $file | sed 's/.in/.txt/'` ; \
121 sed -i -e '1 e head -16 tox.ini' $out ;\
122 done"
Mark Beierl9ed3fa42023-03-01 18:51:34 +0000123 bash -c "for file in osm_webhook_translator/requirements*.in ; do \
124 UNSAFE="" ; \
125 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
126 pip-compile -rU --no-header $UNSAFE $file ;\
127 out=`echo $file | sed 's/.in/.txt/'` ; \
128 sed -i -e '1 e head -16 tox.ini' $out ;\
129 done"
garciadeblas66834562022-11-10 14:07:04 +0100130
131
132#######################################################################################
Mark Beierl9ed3fa42023-03-01 18:51:34 +0000133[testenv:dist_ng_sa]
garciadeblas8d41d562022-11-24 14:42:35 +0100134deps = {[testenv]deps}
135 -r{toxinidir}/requirements-dist.txt
Mark Beierl9ed3fa42023-03-01 18:51:34 +0000136allowlist_externals = sh
garciadeblas8d41d562022-11-24 14:42:35 +0100137commands =
138 sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
139 sh -c 'cp README.rst src/osm_ngsa/README.rst'
140 python3 setup.py --command-packages=stdeb.command sdist_dsc
141 sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
142 sh -c 'rm src/osm_ngsa/requirements.txt'
143 sh -c 'rm src/osm_ngsa/README.rst'
Mark Beierl9ed3fa42023-03-01 18:51:34 +0000144
145
146#######################################################################################
147[testenv:dist_webhook_translator]
148deps = -r{toxinidir}/osm_webhook_translator/requirements.txt
149 -r{toxinidir}/osm_webhook_translator/requirements-dist.txt
150allowlist_externals = sh
151commands =
152 sh -c 'cp src/osm_ngsa/_version.py osm_webhook_translator/src/osm_webhook_translator/_version.py'
153 sh -c 'cd osm_webhook_translator && cp requirements.txt src/osm_webhook_translator/requirements.txt'
154 sh -c 'cd osm_webhook_translator && cp README.rst src/osm_webhook_translator/README.rst'
155 sh -c 'cd osm_webhook_translator && python3 setup.py --command-packages=stdeb.command sdist_dsc'
156 sh -c 'cd osm_webhook_translator/deb_dist/osm-webhook-translator*/ && dpkg-buildpackage -rfakeroot -uc -us'
157 sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/requirements.txt'
158 sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/README.rst'
garciadeblas8d41d562022-11-24 14:42:35 +0100159
160
161#######################################################################################
garciadeblas66834562022-11-10 14:07:04 +0100162[flake8]
163ignore =
164 W291,
165 W293,
166 W503,
167 W605,
168 E123,
169 E125,
170 E203,
171 E226,
172 E241,
173 E501,
174exclude =
175 .git,
176 __pycache__,
177 .tox,
178max-line-length = 120
179show-source = True
180builtins = _
181import-order-style = google