blob: d6ce5d5906138edc2912c4e93fcfc75dc91ffdcb [file] [log] [blame]
beierlm5b3f4b62021-02-17 07:22:20 -05001#######################################################################################
2# Copyright ETSI Contributors and Others.
3#
garciaale76f6a622020-11-19 17:57:42 -03004# 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
madavic0a1f692020-01-16 17:51:43 +05307#
garciaale76f6a622020-11-19 17:57:42 -03008# http://www.apache.org/licenses/LICENSE-2.0
madavic0a1f692020-01-16 17:51:43 +05309#
garciaale76f6a622020-11-19 17:57:42 -030010# 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.
beierlm5b3f4b62021-02-17 07:22:20 -050016#######################################################################################
garciaale76f6a622020-11-19 17:57:42 -030017
Mike Marchetti94b645e2017-08-04 14:33:54 -040018[tox]
beierlm5b3f4b62021-02-17 07:22:20 -050019envlist = black, cover, flake8, pylint, safety
20
21[tox:jenkins]
22toxworkdir = /tmp/.tox
Mike Marchetti94b645e2017-08-04 14:33:54 -040023
24[testenv]
beierlm5b3f4b62021-02-17 07:22:20 -050025usedevelop = True
garciadeblas9a620072023-04-25 01:14:45 +020026basepython = python3.10
beierlm5b3f4b62021-02-17 07:22:20 -050027setenv = VIRTUAL_ENV={envdir}
28 PYTHONDONTWRITEBYTECODE = 1
29passenv = HOME
30deps = -r{toxinidir}/requirements.txt
beierlmd8fdecc2021-04-20 12:18:52 -040031skip_install = true
garciadeblasb6023a82023-04-25 09:27:34 +020032parallel_show_output = true
beierlm5b3f4b62021-02-17 07:22:20 -050033
34
35#######################################################################################
36[testenv:black]
37commands = python3 -c 'print("Skipping due to generated code")'
38
39
40#######################################################################################
41[testenv:cover]
beierlmd8fdecc2021-04-20 12:18:52 -040042skip_install = false
beierlm5b3f4b62021-02-17 07:22:20 -050043deps = {[testenv]deps}
44 -r{toxinidir}/requirements-test.txt
Mike Marchetti94b645e2017-08-04 14:33:54 -040045commands =
garciadeblas9a620072023-04-25 01:14:45 +020046 sh -c "patch {toxworkdir}/cover/lib/python3.10/site-packages/pyangbind/lib/yangtypes.py < pyangbind.patch"
beierlm5b3f4b62021-02-17 07:22:20 -050047 sh -c 'make clean'
48 sh -c 'make models Q=""'
49 sh -c 'rm -f nosetests.xml'
50 coverage erase
51 nose2 -C --coverage osm_im -s tests
52 coverage report --omit='*tests*'
53 coverage html -d ./cover --omit='*tests*'
54 coverage xml -o coverage.xml --omit=*tests*
garciadeblasa91e2252023-04-18 16:04:20 +020055allowlist_externals = sh
Mike Marchetti94b645e2017-08-04 14:33:54 -040056
Mike Marchettice4a73d2018-08-29 15:40:41 -040057
beierlm5b3f4b62021-02-17 07:22:20 -050058#######################################################################################
59[testenv:flake8]
60commands = python3 -c 'print("Skipping due to generated code")'
61
62
63#######################################################################################
64[testenv:pylint]
65commands = python3 -c 'print("Skipping due to generated code")'
66
67
68#######################################################################################
69[testenv:safety]
70setenv =
71 LC_ALL=C.UTF-8
72 LANG=C.UTF-8
73deps = {[testenv]deps}
74 safety
75commands =
76 - safety check --full-report
77
78
79#######################################################################################
80[testenv:pip-compile]
garciadeblasbeff3a12023-05-10 17:41:51 +020081deps = pip-tools==6.13.0
beierlm024959e2022-01-13 11:39:43 -050082skip_install = true
garciadeblasa91e2252023-04-18 16:04:20 +020083allowlist_externals = bash
beierlm024959e2022-01-13 11:39:43 -050084 [
beierlm5b3f4b62021-02-17 07:22:20 -050085commands =
beierlm024959e2022-01-13 11:39:43 -050086 - bash -c "for file in requirements*.in ; do \
87 UNSAFE="" ; \
88 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
garciadeblasbeff3a12023-05-10 17:41:51 +020089 pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\
beierlm024959e2022-01-13 11:39:43 -050090 out=`echo $file | sed 's/.in/.txt/'` ; \
91 sed -i -e '1 e head -16 tox.ini' $out ;\
92 done"
beierlm5b3f4b62021-02-17 07:22:20 -050093
94
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 =
garciadeblas9a620072023-04-25 01:14:45 +0200103 sh -c "patch {toxworkdir}/dist/lib/python3.10/site-packages/pyangbind/lib/yangtypes.py < pyangbind.patch"
beierlm5b3f4b62021-02-17 07:22:20 -0500104 sh -c 'make clean'
105 sh -c 'make Q=""'
106 sh -c 'cp requirements.txt osm_im/requirements.txt'
107 python3 setup.py --command-packages=stdeb.command sdist_dsc
108 sh -c 'cd deb_dist/osm-im*/ && dpkg-buildpackage -rfakeroot -uc -us'
109 sh -c 'rm osm_im/requirements.txt'
garciadeblasa91e2252023-04-18 16:04:20 +0200110allowlist_externals = sh
beierlm5b3f4b62021-02-17 07:22:20 -0500111
112#######################################################################################
113[flake8]
114ignore =
115 W291,
116 W293,
117 E123,
118 E125,
119 E226,
120 E241
121exclude =
122 .git,
123 __pycache__,
124 .tox,
125max-line-length = 120
126show-source = True
127builtins = _