| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 1 | ####################################################################################### |
| 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 Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 10 | # Unless required by applicable law or agreed to in writing, software |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 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 | ####################################################################################### |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 17 | |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 18 | [tox] |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 19 | envlist = black, cover, flake8, pylint, safety |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 20 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 21 | [tox:jenkins] |
| 22 | toxworkdir = /tmp/.tox |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 23 | |
| 24 | [testenv] |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 25 | usedevelop = True |
| Mark Beierl | d37c54c | 2023-05-10 11:15:10 -0400 | [diff] [blame] | 26 | basepython = python3.10 |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 27 | setenv = VIRTUAL_ENV={envdir} |
| 28 | PYTHONDONTWRITEBYTECODE = 1 |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 29 | deps = -r{toxinidir}/requirements.txt |
| garciadeblas | be42d54 | 2022-11-14 00:29:47 +0100 | [diff] [blame] | 30 | parallel_show_output = true |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 31 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 32 | ####################################################################################### |
| 33 | [testenv:black] |
| 34 | deps = black |
| 35 | skip_install = true |
| 36 | commands = |
| garciadeblas | be42d54 | 2022-11-14 00:29:47 +0100 | [diff] [blame] | 37 | black --check --diff osm_policy_module/ |
| 38 | black --check --diff setup.py |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 39 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 40 | ####################################################################################### |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 41 | [testenv:cover] |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 42 | deps = {[testenv]deps} |
| 43 | -r{toxinidir}/requirements-dev.txt |
| 44 | -r{toxinidir}/requirements-test.txt |
| garciadeblas | f0b82fc | 2023-04-04 15:29:01 +0200 | [diff] [blame] | 45 | allowlist_externals = sh |
| beierl | e4a298c | 2019-08-29 15:57:14 -0400 | [diff] [blame] | 46 | commands = |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 47 | sh -c 'rm -f nosetests.xml' |
| 48 | coverage erase |
| 49 | nose2 -C --coverage osm_policy_module |
| 50 | coverage report --omit='*tests*' |
| 51 | coverage html -d ./cover --omit='*tests*' |
| 52 | coverage xml -o coverage.xml --omit=*tests* |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 53 | |
| 54 | ####################################################################################### |
| 55 | [testenv:flake8] |
| 56 | deps = flake8 |
| 57 | commands = |
| 58 | flake8 osm_policy_module/ setup.py |
| 59 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 60 | ####################################################################################### |
| Benjamin Diaz | a13c7e6 | 2019-04-11 14:29:14 -0300 | [diff] [blame] | 61 | [testenv:pylint] |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 62 | deps = {[testenv]deps} |
| 63 | -r{toxinidir}/requirements-dev.txt |
| 64 | -r{toxinidir}/requirements-test.txt |
| garciadeblas | 0aea5ea | 2024-08-07 02:00:53 +0200 | [diff] [blame] | 65 | pylint==3.2.2 |
| Benjamin Diaz | a13c7e6 | 2019-04-11 14:29:14 -0300 | [diff] [blame] | 66 | commands = |
| garciadeblas | c72b9d5 | 2023-01-17 16:46:55 +0100 | [diff] [blame] | 67 | pylint -E osm_policy_module |
| Benjamin Diaz | a13c7e6 | 2019-04-11 14:29:14 -0300 | [diff] [blame] | 68 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 69 | ####################################################################################### |
| 70 | [testenv:safety] |
| 71 | setenv = |
| 72 | LC_ALL=C.UTF-8 |
| 73 | LANG=C.UTF-8 |
| 74 | deps = {[testenv]deps} |
| 75 | safety |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 76 | commands = |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 77 | - safety check --full-report |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 78 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 79 | ####################################################################################### |
| 80 | [testenv:pip-compile] |
| garciadeblas | 4f56632 | 2023-09-28 23:44:19 +0200 | [diff] [blame] | 81 | deps = pip-tools==6.13.0 |
| beierlm | a50fbeb | 2022-01-13 13:19:43 -0500 | [diff] [blame] | 82 | skip_install = true |
| garciadeblas | f0b82fc | 2023-04-04 15:29:01 +0200 | [diff] [blame] | 83 | allowlist_externals = bash |
| beierlm | a50fbeb | 2022-01-13 13:19:43 -0500 | [diff] [blame] | 84 | [ |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 85 | commands = |
| beierlm | a50fbeb | 2022-01-13 13:19:43 -0500 | [diff] [blame] | 86 | - bash -c "for file in requirements*.in ; do \ |
| 87 | UNSAFE="" ; \ |
| 88 | if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ |
| garciadeblas | 4f56632 | 2023-09-28 23:44:19 +0200 | [diff] [blame] | 89 | pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\ |
| beierlm | a50fbeb | 2022-01-13 13:19:43 -0500 | [diff] [blame] | 90 | out=`echo $file | sed 's/.in/.txt/'` ; \ |
| 91 | sed -i -e '1 e head -16 tox.ini' $out ;\ |
| 92 | done" |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 93 | |
| 94 | |
| 95 | ####################################################################################### |
| 96 | [testenv:dist] |
| 97 | deps = {[testenv]deps} |
| 98 | -r{toxinidir}/requirements-dist.txt |
| garciadeblas | f0b82fc | 2023-04-04 15:29:01 +0200 | [diff] [blame] | 99 | allowlist_externals = sh |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 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 |
| 102 | commands = |
| 103 | sh -c 'cp requirements.txt osm_policy_module/requirements.txt' |
| 104 | python3 setup.py --command-packages=stdeb.command sdist_dsc |
| 105 | sh -c 'cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us' |
| 106 | sh -c 'rm osm_policy_module/requirements.txt' |
| garciadeblas | f0b82fc | 2023-04-04 15:29:01 +0200 | [diff] [blame] | 107 | |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 108 | |
| 109 | ####################################################################################### |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 110 | [flake8] |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 111 | ignore = |
| 112 | W291, |
| 113 | W293, |
| garciadeblas | be42d54 | 2022-11-14 00:29:47 +0100 | [diff] [blame] | 114 | W503, |
| beierlm | 61bec7d | 2021-02-11 16:32:17 -0500 | [diff] [blame] | 115 | E123, |
| 116 | E125, |
| 117 | E226, |
| 118 | E241 |
| 119 | exclude = |
| 120 | .git, |
| 121 | __pycache__, |
| 122 | .tox, |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 123 | max-line-length = 120 |
| 124 | show-source = True |
| Benjamin Diaz | 7f11ecf | 2018-09-14 12:03:38 -0300 | [diff] [blame] | 125 | builtins = _ |