blob: e06a8560998010d2fcc6f1b5385a01ac26399514 [file] [log] [blame]
beierlm61bec7d2021-02-11 16:32:17 -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#
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030010# Unless required by applicable law or agreed to in writing, software
beierlm61bec7d2021-02-11 16:32:17 -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#######################################################################################
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030017
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030018[tox]
beierlm61bec7d2021-02-11 16:32:17 -050019envlist = black, cover, flake8, pylint, safety
beierle4a298c2019-08-29 15:57:14 -040020
beierlm61bec7d2021-02-11 16:32:17 -050021[tox:jenkins]
22toxworkdir = /tmp/.tox
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030023
24[testenv]
beierle4a298c2019-08-29 15:57:14 -040025usedevelop = True
beierlm66da5392022-01-13 13:19:43 -050026basepython = python3.8
beierle4a298c2019-08-29 15:57:14 -040027setenv = VIRTUAL_ENV={envdir}
28 PYTHONDONTWRITEBYTECODE = 1
beierlm61bec7d2021-02-11 16:32:17 -050029deps = -r{toxinidir}/requirements.txt
beierle4a298c2019-08-29 15:57:14 -040030
beierlm61bec7d2021-02-11 16:32:17 -050031#######################################################################################
32[testenv:black]
33deps = black
34skip_install = true
35commands =
36 - black --check --diff osm_policy_module/
garciadeblas4584f8e2021-05-14 16:50:06 +020037 - black --check --diff setup.py
beierlm61bec7d2021-02-11 16:32:17 -050038
39
40#######################################################################################
beierle4a298c2019-08-29 15:57:14 -040041[testenv:cover]
beierlm61bec7d2021-02-11 16:32:17 -050042deps = {[testenv]deps}
43 -r{toxinidir}/requirements-dev.txt
44 -r{toxinidir}/requirements-test.txt
beierle4a298c2019-08-29 15:57:14 -040045commands =
beierlm61bec7d2021-02-11 16:32:17 -050046 sh -c 'rm -f nosetests.xml'
47 coverage erase
48 nose2 -C --coverage osm_policy_module
49 coverage report --omit='*tests*'
50 coverage html -d ./cover --omit='*tests*'
51 coverage xml -o coverage.xml --omit=*tests*
52whitelist_externals = sh
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030053
beierlm61bec7d2021-02-11 16:32:17 -050054
55#######################################################################################
56[testenv:flake8]
57deps = flake8
58commands =
59 flake8 osm_policy_module/ setup.py
60
61
62#######################################################################################
Benjamin Diaza13c7e62019-04-11 14:29:14 -030063[testenv:pylint]
beierlm61bec7d2021-02-11 16:32:17 -050064deps = {[testenv]deps}
65 -r{toxinidir}/requirements-dev.txt
66 -r{toxinidir}/requirements-test.txt
67 pylint
Benjamin Diaza13c7e62019-04-11 14:29:14 -030068commands =
69 pylint -E osm_policy_module
70
beierlm61bec7d2021-02-11 16:32:17 -050071
72#######################################################################################
73[testenv:safety]
74setenv =
75 LC_ALL=C.UTF-8
76 LANG=C.UTF-8
77deps = {[testenv]deps}
78 safety
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030079commands =
beierlm61bec7d2021-02-11 16:32:17 -050080 - safety check --full-report
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -030081
beierle4a298c2019-08-29 15:57:14 -040082
beierlm61bec7d2021-02-11 16:32:17 -050083#######################################################################################
84[testenv:pip-compile]
beierlm66da5392022-01-13 13:19:43 -050085deps = pip-tools==6.4.0
86skip_install = true
87whitelist_externals = bash
88 [
beierlm61bec7d2021-02-11 16:32:17 -050089commands =
beierlm66da5392022-01-13 13:19:43 -050090 - bash -c "for file in requirements*.in ; do \
91 UNSAFE="" ; \
92 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
93 pip-compile -rU --no-header $UNSAFE $file ;\
94 out=`echo $file | sed 's/.in/.txt/'` ; \
95 sed -i -e '1 e head -16 tox.ini' $out ;\
96 done"
beierlm61bec7d2021-02-11 16:32:17 -050097
98
99#######################################################################################
100[testenv:dist]
101deps = {[testenv]deps}
102 -r{toxinidir}/requirements-dist.txt
103
104# In the commands, we copy the requirements.txt to be presented as a source file (.py)
105# so it gets included in the .deb package for others to consume
106commands =
107 sh -c 'cp requirements.txt osm_policy_module/requirements.txt'
108 python3 setup.py --command-packages=stdeb.command sdist_dsc
109 sh -c 'cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us'
110 sh -c 'rm osm_policy_module/requirements.txt'
111whitelist_externals = sh
112
113#######################################################################################
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -0300114[flake8]
beierlm61bec7d2021-02-11 16:32:17 -0500115ignore =
116 W291,
117 W293,
118 E123,
119 E125,
120 E226,
121 E241
122exclude =
123 .git,
124 __pycache__,
125 .tox,
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -0300126max-line-length = 120
127show-source = True
Benjamin Diaz7f11ecf2018-09-14 12:03:38 -0300128builtins = _