blob: 3301d0b4ff41bcacecdc7e96679406fb7a71171c [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]
19envlist = black, flake8
20
21[tox:jenkins]
22toxworkdir = /tmp/.tox
23setenv = XDG_CACHE_HOME=/tmp/.cache
24
25[testenv]
26usedevelop = True
27basepython = python3
28setenv = 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 =
garciadeblasd0671572023-03-27 14:22:09 +020039 black --check --diff src setup.py
garciadeblas66834562022-11-10 14:07:04 +010040
41
42#######################################################################################
43[testenv:cover]
44deps = {[testenv]deps}
45 -r{toxinidir}/requirements-dev.txt
46 -r{toxinidir}/requirements-test.txt
garciadeblas239971d2023-03-23 11:46:36 +010047allowlist_externals = sh
garciadeblas66834562022-11-10 14:07:04 +010048commands =
49 sh -c 'rm -f nosetests.xml'
50 coverage erase
51 nose2 -C --coverage src -s src
52 sh -c 'mv .coverage .coverage_mon'
53 coverage report --omit='*tests*'
54 coverage html -d ./cover --omit='*tests*'
55 coverage xml -o coverage.xml --omit='*tests*'
56
57
58#######################################################################################
59[testenv:flake8]
garciadeblas998ff732022-11-10 14:19:44 +010060deps = flake8==5.0.4
garciadeblas66834562022-11-10 14:07:04 +010061 flake8-import-order
garciadeblas66834562022-11-10 14:07:04 +010062commands =
garciadeblasd0671572023-03-27 14:22:09 +020063 flake8 src setup.py
garciadeblas66834562022-11-10 14:07:04 +010064
65
66#######################################################################################
67[testenv:pylint]
68deps = {[testenv]deps}
69 -r{toxinidir}/requirements-dev.txt
70 -r{toxinidir}/requirements-test.txt
71 pylint
72skip_install = true
73commands =
74 pylint -E src
75
76
77#######################################################################################
78[testenv:safety]
79setenv =
80 LC_ALL=C.UTF-8
81 LANG=C.UTF-8
82deps = {[testenv]deps}
83 safety
84commands =
85 - safety check --full-report
86
87
88#######################################################################################
89[testenv:pip-compile]
90deps = pip-tools==6.6.2
91skip_install = true
garciadeblas239971d2023-03-23 11:46:36 +010092allowlist_externals =
garciadeblas66834562022-11-10 14:07:04 +010093 bash
94 [
95commands =
96 bash -c "for file in requirements*.in ; do \
97 UNSAFE="" ; \
98 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
99 pip-compile -rU --no-header $UNSAFE $file ;\
100 out=`echo $file | sed 's/.in/.txt/'` ; \
101 sed -i -e '1 e head -16 tox.ini' $out ;\
102 done"
103
104
105#######################################################################################
garciadeblas8d41d562022-11-24 14:42:35 +0100106[testenv:dist]
107deps = {[testenv]deps}
108 -r{toxinidir}/requirements-dist.txt
109
110# In the commands, we copy the requirements.txt to be presented as a source file (.py)
111# so it gets included in the .deb package for others to consume
112commands =
113 sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
114 sh -c 'cp README.rst src/osm_ngsa/README.rst'
115 python3 setup.py --command-packages=stdeb.command sdist_dsc
116 sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
117 sh -c 'rm src/osm_ngsa/requirements.txt'
118 sh -c 'rm src/osm_ngsa/README.rst'
garciadeblas239971d2023-03-23 11:46:36 +0100119allowlist_externals = sh
garciadeblas8d41d562022-11-24 14:42:35 +0100120
121
122#######################################################################################
garciadeblas66834562022-11-10 14:07:04 +0100123[flake8]
124ignore =
125 W291,
126 W293,
127 W503,
128 W605,
129 E123,
130 E125,
131 E203,
132 E226,
133 E241,
134 E501,
135exclude =
136 .git,
137 __pycache__,
138 .tox,
139max-line-length = 120
140show-source = True
141builtins = _
142import-order-style = google