| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [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 | # |
| 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] |
| garciadeblas | 02f71cd | 2023-05-23 21:57:36 +0200 | [diff] [blame] | 19 | envlist = black, flake8, pylint, pylint-webhook |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 20 | |
| 21 | [tox:jenkins] |
| 22 | toxworkdir = /tmp/.tox |
| 23 | setenv = XDG_CACHE_HOME=/tmp/.cache |
| 24 | |
| 25 | [testenv] |
| 26 | usedevelop = True |
| garciadeblas | 4e36505 | 2023-03-23 13:25:27 +0100 | [diff] [blame] | 27 | basepython = python3.10 |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 28 | setenv = VIRTUAL_ENV={envdir} |
| 29 | PYTHONDONTWRITEBYTECODE = 1 |
| 30 | deps = -r{toxinidir}/requirements.txt |
| 31 | parallel_show_output = true |
| 32 | |
| 33 | |
| 34 | ####################################################################################### |
| 35 | [testenv:black] |
| 36 | deps = black |
| 37 | skip_install = true |
| 38 | commands = |
| garciadeblas | d067157 | 2023-03-27 14:22:09 +0200 | [diff] [blame] | 39 | black --check --diff src setup.py |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 40 | black --check --diff osm_webhook_translator |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 41 | |
| 42 | |
| 43 | ####################################################################################### |
| 44 | [testenv:cover] |
| 45 | deps = {[testenv]deps} |
| 46 | -r{toxinidir}/requirements-dev.txt |
| 47 | -r{toxinidir}/requirements-test.txt |
| garciadeblas | 239971d | 2023-03-23 11:46:36 +0100 | [diff] [blame] | 48 | allowlist_externals = sh |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 49 | commands = |
| 50 | sh -c 'rm -f nosetests.xml' |
| 51 | coverage erase |
| 52 | nose2 -C --coverage src -s src |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 53 | sh -c 'mv .coverage .coverage_ngsa' |
| 54 | nose2 -C --coverage osm_webhook_translator -s osm_webhook_translator |
| 55 | sh -c 'mv .coverage .coverage_webhook_translator' |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 56 | coverage report --omit='*tests*' |
| 57 | coverage html -d ./cover --omit='*tests*' |
| 58 | coverage xml -o coverage.xml --omit='*tests*' |
| 59 | |
| 60 | |
| 61 | ####################################################################################### |
| 62 | [testenv:flake8] |
| garciadeblas | 998ff73 | 2022-11-10 14:19:44 +0100 | [diff] [blame] | 63 | deps = flake8==5.0.4 |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 64 | flake8-import-order |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 65 | commands = |
| garciadeblas | d067157 | 2023-03-27 14:22:09 +0200 | [diff] [blame] | 66 | flake8 src setup.py |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 67 | flake8 osm_webhook_translator |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 68 | |
| 69 | |
| 70 | ####################################################################################### |
| 71 | [testenv:pylint] |
| 72 | deps = {[testenv]deps} |
| 73 | -r{toxinidir}/requirements-dev.txt |
| 74 | -r{toxinidir}/requirements-test.txt |
| 75 | pylint |
| 76 | skip_install = true |
| 77 | commands = |
| garciadeblas | 02f71cd | 2023-05-23 21:57:36 +0200 | [diff] [blame] | 78 | pylint -E src setup.py --disable=E0401 |
| 79 | |
| 80 | |
| 81 | [testenv:pylint-webhook] |
| 82 | changedir = {toxinidir}/osm_webhook_translator |
| 83 | deps = -r{toxinidir}/osm_webhook_translator/requirements.txt |
| 84 | pylint |
| 85 | skip_install = true |
| 86 | commands = |
| 87 | pylint -E src setup.py |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 88 | |
| 89 | |
| 90 | ####################################################################################### |
| 91 | [testenv:safety] |
| 92 | setenv = |
| 93 | LC_ALL=C.UTF-8 |
| 94 | LANG=C.UTF-8 |
| 95 | deps = {[testenv]deps} |
| 96 | safety |
| 97 | commands = |
| 98 | - safety check --full-report |
| 99 | |
| 100 | |
| 101 | ####################################################################################### |
| 102 | [testenv:pip-compile] |
| garciadeblas | cc9870f | 2023-05-10 11:03:41 +0200 | [diff] [blame] | 103 | deps = pip-tools==6.13.0 |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 104 | skip_install = true |
| garciadeblas | 239971d | 2023-03-23 11:46:36 +0100 | [diff] [blame] | 105 | allowlist_externals = |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 106 | bash |
| 107 | [ |
| 108 | commands = |
| 109 | bash -c "for file in requirements*.in ; do \ |
| 110 | UNSAFE="" ; \ |
| 111 | if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ |
| garciadeblas | cc9870f | 2023-05-10 11:03:41 +0200 | [diff] [blame] | 112 | pip-compile -rU --resolver=backtracking --no-header $UNSAFE $file ;\ |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 113 | out=`echo $file | sed 's/.in/.txt/'` ; \ |
| 114 | sed -i -e '1 e head -16 tox.ini' $out ;\ |
| 115 | done" |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 116 | bash -c "for file in osm_webhook_translator/requirements*.in ; do \ |
| 117 | UNSAFE="" ; \ |
| 118 | if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ |
| garciadeblas | 4e36505 | 2023-03-23 13:25:27 +0100 | [diff] [blame] | 119 | pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\ |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 120 | out=`echo $file | sed 's/.in/.txt/'` ; \ |
| 121 | sed -i -e '1 e head -16 tox.ini' $out ;\ |
| 122 | done" |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 123 | |
| 124 | |
| 125 | ####################################################################################### |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 126 | [testenv:dist_ng_sa] |
| garciadeblas | 8d41d56 | 2022-11-24 14:42:35 +0100 | [diff] [blame] | 127 | deps = {[testenv]deps} |
| 128 | -r{toxinidir}/requirements-dist.txt |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 129 | allowlist_externals = sh |
| garciadeblas | 8d41d56 | 2022-11-24 14:42:35 +0100 | [diff] [blame] | 130 | commands = |
| 131 | sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt' |
| 132 | sh -c 'cp README.rst src/osm_ngsa/README.rst' |
| 133 | python3 setup.py --command-packages=stdeb.command sdist_dsc |
| 134 | sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us' |
| 135 | sh -c 'rm src/osm_ngsa/requirements.txt' |
| 136 | sh -c 'rm src/osm_ngsa/README.rst' |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 137 | |
| 138 | |
| 139 | ####################################################################################### |
| 140 | [testenv:dist_webhook_translator] |
| 141 | deps = -r{toxinidir}/osm_webhook_translator/requirements.txt |
| 142 | -r{toxinidir}/osm_webhook_translator/requirements-dist.txt |
| garciadeblas | 239971d | 2023-03-23 11:46:36 +0100 | [diff] [blame] | 143 | allowlist_externals = sh |
| garciadeblas | 9cbad10 | 2023-04-05 11:09:19 +0200 | [diff] [blame] | 144 | commands = |
| 145 | sh -c 'cp src/osm_ngsa/_version.py osm_webhook_translator/src/osm_webhook_translator/_version.py' |
| 146 | sh -c 'cd osm_webhook_translator && cp requirements.txt src/osm_webhook_translator/requirements.txt' |
| 147 | sh -c 'cd osm_webhook_translator && cp README.rst src/osm_webhook_translator/README.rst' |
| 148 | sh -c 'cd osm_webhook_translator && python3 setup.py --command-packages=stdeb.command sdist_dsc' |
| 149 | sh -c 'cd osm_webhook_translator/deb_dist/osm-webhook-translator*/ && dpkg-buildpackage -rfakeroot -uc -us' |
| 150 | sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/requirements.txt' |
| 151 | sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/README.rst' |
| garciadeblas | 8d41d56 | 2022-11-24 14:42:35 +0100 | [diff] [blame] | 152 | |
| 153 | |
| 154 | ####################################################################################### |
| garciadeblas | 6683456 | 2022-11-10 14:07:04 +0100 | [diff] [blame] | 155 | [flake8] |
| 156 | ignore = |
| 157 | W291, |
| 158 | W293, |
| 159 | W503, |
| 160 | W605, |
| 161 | E123, |
| 162 | E125, |
| 163 | E203, |
| 164 | E226, |
| 165 | E241, |
| 166 | E501, |
| 167 | exclude = |
| 168 | .git, |
| 169 | __pycache__, |
| 170 | .tox, |
| 171 | max-line-length = 120 |
| 172 | show-source = True |
| 173 | builtins = _ |
| 174 | import-order-style = google |