blob: 0d7fe8c48a3357d94fc2d9153cbb3399c8ee8ced [file] [log] [blame]
tierno0c01ffa2018-11-19 14:39:33 +01001# 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
beierlma0911d32021-02-22 14:30:35 -050016
tiernoc94c3df2018-02-09 15:38:54 +010017[tox]
beierlma0911d32021-02-22 14:30:35 -050018envlist = black, cover, flake8, pylint, safety
19
20[tox:jenkins]
21toxworkdir = /tmp/.tox
tiernoc94c3df2018-02-09 15:38:54 +010022
23[testenv]
tierno1bfe4e22019-09-02 16:03:25 +000024usedevelop = True
Mark Beierl375aeb22023-05-10 13:55:55 -040025basepython = python3.10
beierlma0911d32021-02-22 14:30:35 -050026setenv = VIRTUAL_ENV={envdir}
27 PYTHONDONTWRITEBYTECODE = 1
28deps = -r{toxinidir}/requirements.txt
tiernoc94c3df2018-02-09 15:38:54 +010029
beierlma0911d32021-02-22 14:30:35 -050030#######################################################################################
31[testenv:black]
garciadeblasbd022082024-01-29 18:43:30 +010032deps = black==23.12.1
beierlma0911d32021-02-22 14:30:35 -050033skip_install = true
34commands =
garciadeblasf2af4a12023-01-24 16:56:54 +010035 black --check --diff osm_nbi/
36 black --check --diff setup.py
beierlma0911d32021-02-22 14:30:35 -050037
38
39#######################################################################################
garciadeblasf417d522020-02-19 18:11:52 +010040[testenv:cover]
beierlma0911d32021-02-22 14:30:35 -050041deps = {[testenv]deps}
42 -r{toxinidir}/requirements-dev.txt
43 -r{toxinidir}/requirements-test.txt
garciadeblasf417d522020-02-19 18:11:52 +010044commands =
beierlma0911d32021-02-22 14:30:35 -050045 sh -c 'rm -f nosetests.xml'
46 coverage erase
47 nose2 -C --coverage osm_nbi -s osm_nbi/tests
48 coverage report --omit='*tests*'
49 coverage html -d ./cover --omit='*tests*'
50 coverage xml -o coverage.xml --omit=*tests*
garciadeblas4cd875d2023-02-14 19:05:34 +010051allowlist_externals = sh
garciadeblasf417d522020-02-19 18:11:52 +010052
beierlma0911d32021-02-22 14:30:35 -050053
54#######################################################################################
tiernoc94c3df2018-02-09 15:38:54 +010055[testenv:flake8]
beierlma0911d32021-02-22 14:30:35 -050056deps = flake8
garciadeblasf417d522020-02-19 18:11:52 +010057commands =
garciadeblasf2af4a12023-01-24 16:56:54 +010058 flake8 osm_nbi/ setup.py
tiernoc94c3df2018-02-09 15:38:54 +010059
tierno0c01ffa2018-11-19 14:39:33 +010060
beierlma0911d32021-02-22 14:30:35 -050061#######################################################################################
62[testenv:pylint]
63deps = {[testenv]deps}
64 -r{toxinidir}/requirements-dev.txt
65 -r{toxinidir}/requirements-test.txt
66 pylint
67commands =
garciadeblas6e88d9c2024-08-15 10:55:04 +020068 pylint -E osm_nbi --extension-pkg-allow-list=pyrage
tierno1bfe4e22019-09-02 16:03:25 +000069
beierlma0911d32021-02-22 14:30:35 -050070
71#######################################################################################
72[testenv:safety]
73setenv =
74 LC_ALL=C.UTF-8
75 LANG=C.UTF-8
76deps = {[testenv]deps}
77 safety
78commands =
79 - safety check --full-report
80
81
82#######################################################################################
83[testenv:pip-compile]
garciadeblas514b5462023-09-06 10:34:02 +020084deps = pip-tools==6.13.0
beierlm0ae051c2022-01-13 11:40:06 -050085skip_install = true
garciadeblas9632c1a2023-04-18 14:42:40 +020086allowlist_externals = bash
beierlm0ae051c2022-01-13 11:40:06 -050087 [
beierlma0911d32021-02-22 14:30:35 -050088commands =
beierlm0ae051c2022-01-13 11:40:06 -050089 - bash -c "for file in requirements*.in ; do \
90 UNSAFE="" ; \
91 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
garciadeblas514b5462023-09-06 10:34:02 +020092 pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\
beierlm0ae051c2022-01-13 11:40:06 -050093 out=`echo $file | sed 's/.in/.txt/'` ; \
94 sed -i -e '1 e head -16 tox.ini' $out ;\
95 done"
beierlma0911d32021-02-22 14:30:35 -050096
97
98#######################################################################################
99[testenv:dist]
100deps = {[testenv]deps}
101 -r{toxinidir}/requirements-dist.txt
102
103# In the commands, we copy the requirements.txt to be presented as a source file (.py)
104# so it gets included in the .deb package for others to consume
105commands =
106 sh -c 'cp requirements.txt osm_nbi/requirements.txt'
107 python3 setup.py --command-packages=stdeb.command sdist_dsc
108 sh -c 'cd deb_dist/osm-nbi*/ && dpkg-buildpackage -rfakeroot -uc -us'
109 sh -c 'rm osm_nbi/requirements.txt'
garciadeblas9632c1a2023-04-18 14:42:40 +0200110allowlist_externals = sh
beierlma0911d32021-02-22 14:30:35 -0500111
112#######################################################################################
113[flake8]
114ignore =
115 W291,
116 W293,
117 W503,
118 E123,
119 E125,
garciadeblasf2af4a12023-01-24 16:56:54 +0100120 E203,
beierlma0911d32021-02-22 14:30:35 -0500121 E226,
aticig2b5e1232022-08-10 17:30:12 +0300122 E241,
123 E501
beierlma0911d32021-02-22 14:30:35 -0500124exclude =
125 .git,
126 __pycache__,
127 .tox,
128 test_mznmodels.py
129max-line-length = 120
130show-source = True
garciadeblas4568a372021-03-24 09:19:48 +0100131builtins = _
132