blob: ab29e201ea867432f4055b86c478fd4559605597 [file] [log] [blame]
beierlmbb0f2a32021-02-16 13:30:35 -05001#######################################################################################
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#
Helena McGough95b92b32017-10-01 12:03:53 +010010# Unless required by applicable law or agreed to in writing, software
beierlmbb0f2a32021-02-16 13:30:35 -050011# 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#######################################################################################
Helena McGough95b92b32017-10-01 12:03:53 +010017
Helena McGough95b92b32017-10-01 12:03:53 +010018[tox]
beierlmbb0f2a32021-02-16 13:30:35 -050019envlist = black, cover, flake8, pylint, safety
beierl2329b922019-07-12 11:55:36 -040020
beierlmbb0f2a32021-02-16 13:30:35 -050021[tox:jenkins]
22toxworkdir = /tmp/.tox
Helena McGough95b92b32017-10-01 12:03:53 +010023
24[testenv]
beierl2329b922019-07-12 11:55:36 -040025usedevelop = True
Mark Beierl072b0bd2023-05-10 15:43:03 -040026basepython = python3.10
beierl2329b922019-07-12 11:55:36 -040027setenv = VIRTUAL_ENV={envdir}
28 PYTHONDONTWRITEBYTECODE = 1
beierlmbb0f2a32021-02-16 13:30:35 -050029deps = -r{toxinidir}/requirements.txt
garciadeblase11d5662022-11-14 00:07:17 +010030parallel_show_output = true
beierl2329b922019-07-12 11:55:36 -040031
beierlmbb0f2a32021-02-16 13:30:35 -050032#######################################################################################
33[testenv:black]
garciadeblas7810b7c2024-01-29 18:22:09 +010034deps = black==23.12.1
beierlmbb0f2a32021-02-16 13:30:35 -050035skip_install = true
36commands =
garciadeblase11d5662022-11-14 00:07:17 +010037 black --check --diff osm_mon/
38 black --check --diff setup.py
beierlmbb0f2a32021-02-16 13:30:35 -050039
40
41#######################################################################################
beierl2329b922019-07-12 11:55:36 -040042[testenv:cover]
beierlmbb0f2a32021-02-16 13:30:35 -050043deps = {[testenv]deps}
44 -r{toxinidir}/requirements-dev.txt
45 -r{toxinidir}/requirements-test.txt
beierl2329b922019-07-12 11:55:36 -040046commands =
beierlmbb0f2a32021-02-16 13:30:35 -050047 sh -c 'rm -f nosetests.xml'
48 coverage erase
49 nose2 -C --coverage osm_mon
50 coverage report --omit='*tests*'
51 coverage html -d ./cover --omit='*tests*'
52 coverage xml -o coverage.xml --omit=*tests*
garciadeblasca2fd222023-04-04 15:26:09 +020053allowlist_externals = sh
Helena McGough95b92b32017-10-01 12:03:53 +010054
beierlmbb0f2a32021-02-16 13:30:35 -050055
56#######################################################################################
Benjamin Diazb7261612018-05-11 18:00:16 -030057[testenv:flake8]
Benjamin Diazb7261612018-05-11 18:00:16 -030058deps = flake8
59commands =
beierlmbb0f2a32021-02-16 13:30:35 -050060 flake8 osm_mon/ setup.py
Helena McGough95b92b32017-10-01 12:03:53 +010061
Helena McGough95b92b32017-10-01 12:03:53 +010062
beierlmbb0f2a32021-02-16 13:30:35 -050063#######################################################################################
64[testenv:pylint]
65deps = {[testenv]deps}
66 -r{toxinidir}/requirements-dev.txt
67 -r{toxinidir}/requirements-test.txt
68 pylint
69commands =
garciadeblase11d5662022-11-14 00:07:17 +010070 pylint -E osm_mon
beierlmbb0f2a32021-02-16 13:30:35 -050071
72
73#######################################################################################
74[testenv:safety]
75setenv =
76 LC_ALL=C.UTF-8
77 LANG=C.UTF-8
78deps = {[testenv]deps}
79 safety
80commands =
81 - safety check --full-report
82
83
84#######################################################################################
85[testenv:pip-compile]
garciadeblas63dc6482023-09-29 08:04:39 +020086deps = pip-tools==6.13.0
beierlmf3c0ac42022-01-13 11:43:03 -050087skip_install = true
garciadeblasca2fd222023-04-04 15:26:09 +020088allowlist_externals = bash
beierlmf3c0ac42022-01-13 11:43:03 -050089 [
beierlmbb0f2a32021-02-16 13:30:35 -050090commands =
beierlmf3c0ac42022-01-13 11:43:03 -050091 - bash -c "for file in requirements*.in ; do \
92 UNSAFE="" ; \
93 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
garciadeblas63dc6482023-09-29 08:04:39 +020094 pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\
beierlmf3c0ac42022-01-13 11:43:03 -050095 out=`echo $file | sed 's/.in/.txt/'` ; \
96 sed -i -e '1 e head -16 tox.ini' $out ;\
97 done"
beierlmbb0f2a32021-02-16 13:30:35 -050098
99
100#######################################################################################
101[testenv:dist]
102deps = {[testenv]deps}
103 -r{toxinidir}/requirements-dist.txt
garciadeblasca2fd222023-04-04 15:26:09 +0200104allowlist_externals = sh
beierlmbb0f2a32021-02-16 13:30:35 -0500105# 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
107commands =
108 sh -c 'cp requirements.txt osm_mon/requirements.txt'
109 python3 setup.py --command-packages=stdeb.command sdist_dsc
110 sh -c 'cd deb_dist/osm-mon*/ && dpkg-buildpackage -rfakeroot -uc -us'
111 sh -c 'rm osm_mon/requirements.txt'
beierlmbb0f2a32021-02-16 13:30:35 -0500112
113#######################################################################################
Helena McGough95b92b32017-10-01 12:03:53 +0100114[flake8]
beierlmbb0f2a32021-02-16 13:30:35 -0500115ignore =
116 W291,
117 W293,
118 W503,
119 E123,
120 E125,
121 E226,
122 E241
123exclude =
124 .git,
125 __pycache__,
126 .tox,
Benjamin Diazb7261612018-05-11 18:00:16 -0300127max-line-length = 120
Helena McGough95b92b32017-10-01 12:03:53 +0100128show-source = True
Helena McGough95b92b32017-10-01 12:03:53 +0100129builtins = _