| tierno | 0c01ffa | 2018-11-19 14:39:33 +0100 | [diff] [blame] | 1 | # 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 | |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 16 | |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 17 | [tox] |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 18 | envlist = black, cover, flake8, pylint, safety |
| 19 | |
| 20 | [tox:jenkins] |
| 21 | toxworkdir = /tmp/.tox |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 22 | |
| 23 | [testenv] |
| tierno | 1bfe4e2 | 2019-09-02 16:03:25 +0000 | [diff] [blame] | 24 | usedevelop = True |
| Mark Beierl | 375aeb2 | 2023-05-10 13:55:55 -0400 | [diff] [blame] | 25 | basepython = python3.10 |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 26 | setenv = VIRTUAL_ENV={envdir} |
| 27 | PYTHONDONTWRITEBYTECODE = 1 |
| 28 | deps = -r{toxinidir}/requirements.txt |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 29 | |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 30 | ####################################################################################### |
| 31 | [testenv:black] |
| garciadeblas | bd02208 | 2024-01-29 18:43:30 +0100 | [diff] [blame] | 32 | deps = black==23.12.1 |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 33 | skip_install = true |
| 34 | commands = |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 35 | black --check --diff osm_nbi/ |
| 36 | black --check --diff setup.py |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 37 | |
| 38 | |
| 39 | ####################################################################################### |
| garciadeblas | f417d52 | 2020-02-19 18:11:52 +0100 | [diff] [blame] | 40 | [testenv:cover] |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 41 | deps = {[testenv]deps} |
| 42 | -r{toxinidir}/requirements-dev.txt |
| 43 | -r{toxinidir}/requirements-test.txt |
| garciadeblas | f417d52 | 2020-02-19 18:11:52 +0100 | [diff] [blame] | 44 | commands = |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 45 | 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* |
| garciadeblas | 4cd875d | 2023-02-14 19:05:34 +0100 | [diff] [blame] | 51 | allowlist_externals = sh |
| garciadeblas | f417d52 | 2020-02-19 18:11:52 +0100 | [diff] [blame] | 52 | |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 53 | |
| 54 | ####################################################################################### |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 55 | [testenv:flake8] |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 56 | deps = flake8 |
| garciadeblas | f417d52 | 2020-02-19 18:11:52 +0100 | [diff] [blame] | 57 | commands = |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 58 | flake8 osm_nbi/ setup.py |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 59 | |
| tierno | 0c01ffa | 2018-11-19 14:39:33 +0100 | [diff] [blame] | 60 | |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 61 | ####################################################################################### |
| 62 | [testenv:pylint] |
| 63 | deps = {[testenv]deps} |
| 64 | -r{toxinidir}/requirements-dev.txt |
| 65 | -r{toxinidir}/requirements-test.txt |
| 66 | pylint |
| 67 | commands = |
| garciadeblas | 6e88d9c | 2024-08-15 10:55:04 +0200 | [diff] [blame] | 68 | pylint -E osm_nbi --extension-pkg-allow-list=pyrage |
| tierno | 1bfe4e2 | 2019-09-02 16:03:25 +0000 | [diff] [blame] | 69 | |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 70 | |
| 71 | ####################################################################################### |
| 72 | [testenv:safety] |
| 73 | setenv = |
| 74 | LC_ALL=C.UTF-8 |
| 75 | LANG=C.UTF-8 |
| 76 | deps = {[testenv]deps} |
| 77 | safety |
| 78 | commands = |
| 79 | - safety check --full-report |
| 80 | |
| 81 | |
| 82 | ####################################################################################### |
| 83 | [testenv:pip-compile] |
| garciadeblas | 514b546 | 2023-09-06 10:34:02 +0200 | [diff] [blame] | 84 | deps = pip-tools==6.13.0 |
| beierlm | 0ae051c | 2022-01-13 11:40:06 -0500 | [diff] [blame] | 85 | skip_install = true |
| garciadeblas | 9632c1a | 2023-04-18 14:42:40 +0200 | [diff] [blame] | 86 | allowlist_externals = bash |
| beierlm | 0ae051c | 2022-01-13 11:40:06 -0500 | [diff] [blame] | 87 | [ |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 88 | commands = |
| beierlm | 0ae051c | 2022-01-13 11:40:06 -0500 | [diff] [blame] | 89 | - bash -c "for file in requirements*.in ; do \ |
| 90 | UNSAFE="" ; \ |
| 91 | if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ |
| garciadeblas | 514b546 | 2023-09-06 10:34:02 +0200 | [diff] [blame] | 92 | pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\ |
| beierlm | 0ae051c | 2022-01-13 11:40:06 -0500 | [diff] [blame] | 93 | out=`echo $file | sed 's/.in/.txt/'` ; \ |
| 94 | sed -i -e '1 e head -16 tox.ini' $out ;\ |
| 95 | done" |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 96 | |
| 97 | |
| 98 | ####################################################################################### |
| 99 | [testenv:dist] |
| 100 | deps = {[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 |
| 105 | commands = |
| 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' |
| garciadeblas | 9632c1a | 2023-04-18 14:42:40 +0200 | [diff] [blame] | 110 | allowlist_externals = sh |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 111 | |
| 112 | ####################################################################################### |
| 113 | [flake8] |
| 114 | ignore = |
| 115 | W291, |
| 116 | W293, |
| 117 | W503, |
| 118 | E123, |
| 119 | E125, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 120 | E203, |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 121 | E226, |
| aticig | 2b5e123 | 2022-08-10 17:30:12 +0300 | [diff] [blame] | 122 | E241, |
| 123 | E501 |
| beierlm | a0911d3 | 2021-02-22 14:30:35 -0500 | [diff] [blame] | 124 | exclude = |
| 125 | .git, |
| 126 | __pycache__, |
| 127 | .tox, |
| 128 | test_mznmodels.py |
| 129 | max-line-length = 120 |
| 130 | show-source = True |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 131 | builtins = _ |
| 132 | |