From: beierlm Date: Thu, 11 Feb 2021 21:32:17 +0000 (-0500) Subject: Feature 10296 Pip Standardization X-Git-Tag: v9.1.3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3722f5c5c22c07c3776b9f4518d4e2978090ca60;p=osm%2FPOL.git Feature 10296 Pip Standardization Creates standard template for tox.ini Introduces 'safety' for listing upstream CVEs Pins all versions of all upstream modules Removes Makefile step and places all build logic into tox.ini Change-Id: I96b0007f918930e61e54edda4b43a4aba90d26d9 Feature: 10296 Signed-off-by: beierlm --- diff --git a/Dockerfile b/Dockerfile index ec336bb..74b9c36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,37 @@ -# Copyright 2018 Whitestack, LLC -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Whitestack, LLC - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: bdiaz@whitestack.com or glavado@whitestack.com -## +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################################## +# This Dockerfile is intented for devops testing and deb package generation +# +# To run stage 2 locally: +# +# docker build -t stage2 . +# docker run -ti -v `pwd`:/work -w /work --entrypoint /bin/bash stage2 +# devops-stages/stage-test.sh +# devops-stages/stage-build.sh +# FROM ubuntu:20.04 -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox=3.13.2-2 make=4.2.1-1.2 python-all=2.7.17-2ubuntu4 python3=3.8.2-0ubuntu2 python3-pip=20.0.2-5ubuntu1.1 debhelper wget && \ - DEBIAN_FRONTEND=noninteractive apt-get --yes install libmysqlclient-dev=8.0.23-0ubuntu0.20.04.1 libxml2 python3-all=3.8.2-0ubuntu2 dh-python=4.20191017ubuntu7 && \ - DEBIAN_FRONTEND=noninteractive pip3 install -U setuptools==53.0.0 setuptools-version-command==2.2 stdeb==0.10.0 +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -y install \ + debhelper \ + dh-python \ + git \ + python3 \ + python3-all \ + python3-dev \ + python3-setuptools + +RUN python3 -m easy_install pip==21.0.1 +RUN pip3 install tox==3.22.0 diff --git a/MANIFEST.in b/MANIFEST.in index a2e97ec..0b39669 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -20,8 +20,5 @@ # contact: bdiaz@whitestack.com or glavado@whitestack.com ## -include requirements.txt -include test-requirements.txt include README.rst -recursive-include osm_policy_module *.py *.xml *.sh *.yaml -recursive-include devops-stages * \ No newline at end of file +recursive-include osm_policy_module *.py *.xml *.sh *.yaml *.txt diff --git a/Makefile b/Makefile deleted file mode 100644 index 586b73c..0000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: clean package - -clean: - rm -rf dist deb_dist osm_policy_module-*.tar.gz osm_policy_module.egg-info .eggs - -package: - python3 setup.py --command-packages=stdeb.command sdist_dsc - cp debian/python3-osm-policy-module.postinst deb_dist/osm-policy-module*/debian - cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us \ No newline at end of file diff --git a/debian/python3-osm-policy-module.postinst b/debian/python3-osm-policy-module.postinst deleted file mode 100644 index a095f5b..0000000 --- a/debian/python3-osm-policy-module.postinst +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Copyright 2018 Whitestack, LLC -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Whitestack, LLC - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: bdiaz@whitestack.com or glavado@whitestack.com -## - -echo "Installing python dependencies via pip..." -pip3 install aiokafka==0.6.0 -pip3 install peewee==3.8.* -pip3 install jsonschema==2.6.* -pip3 install pyyaml==3.* -pip3 install pymysql -pip3 install peewee-migrate==1.1.* -pip3 install requests==2.* -echo "Installation of python dependencies finished" \ No newline at end of file diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index 8a8d332..671b3e0 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -1,26 +1,18 @@ -# Copyright 2017 Intel Research and Development Ireland Limited -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Intel Corporation - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 +#!/bin/sh +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: prithiv.mohan@intel.com or adrian.hoban@intel.com +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. -#__author__ = "Prithiv Mohan" -#__date__ = "14/Sep/2017" +rm -rf dist deb_dist osm*.tar.gz *.egg-info .eggs -#!/bin/bash -make +tox -e dist diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index d588666..75a3c61 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -16,11 +16,5 @@ # License for the specific language governing permissions and limitations # under the License. -# For those usages not covered by the Apache License, Version 2.0 please -# contact: prithiv.mohan@intel.com or adrian.hoban@intel.com - -#__author__ = "Prithiv Mohan" -#__date__ = "14/Sep/2017" - -#!/bin/bash -tox +OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto) +printf "$OUTPUT" diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000..3ae8b5f --- /dev/null +++ b/requirements-dev.in @@ -0,0 +1,17 @@ +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +git+https://osm.etsi.org/gerrit/osm/common.git@v9.0#egg=osm-common +-r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..816639a --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,32 @@ +aiokafka==0.7.0 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +dataclasses==0.6 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +kafka-python==2.0.2 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # aiokafka +git+https://osm.etsi.org/gerrit/osm/common.git@v9.0#egg=osm-common + # via -r requirements-dev.in +pycrypto==2.6.1 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +pymongo==3.11.3 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +pyyaml==5.4.1 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### diff --git a/requirements-dist.in b/requirements-dist.in new file mode 100644 index 0000000..11f0a2a --- /dev/null +++ b/requirements-dist.in @@ -0,0 +1,17 @@ +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +stdeb +setuptools-version-command \ No newline at end of file diff --git a/requirements-dist.txt b/requirements-dist.txt new file mode 100644 index 0000000..7393626 --- /dev/null +++ b/requirements-dist.txt @@ -0,0 +1,23 @@ +setuptools-version-command==2.2 + # via -r requirements-dist.in +stdeb==0.10.0 + # via -r requirements-dist.in + +# The following packages are considered to be unsafe in a requirements file: +# setuptools +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### diff --git a/requirements-test.in b/requirements-test.in new file mode 100644 index 0000000..623556d --- /dev/null +++ b/requirements-test.in @@ -0,0 +1,24 @@ +# Copyright 2017 Intel Research and Development Ireland Limited +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Intel Corporation + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# For those usages not covered by the Apache License, Version 2.0 please +# contact: helena.mcgough@intel.com or adrian.hoban@intel.com +## +coverage +mock +nose2 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..d0c984f --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,26 @@ +coverage==5.5 + # via + # -r requirements-test.in + # nose2 +mock==4.0.3 + # via -r requirements-test.in +nose2==0.10.0 + # via -r requirements-test.in +six==1.15.0 + # via nose2 +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..8ad3006 --- /dev/null +++ b/requirements.in @@ -0,0 +1,22 @@ +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +aiokafka +peewee==3.8.* +jsonschema==2.6.* +pyyaml +pymysql==0.9.* +peewee-migrate==1.1.* +requests==2.* diff --git a/requirements.txt b/requirements.txt index 0f96a21..0fbd162 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,30 +1,48 @@ -# Copyright 2020 Whitestack, LLC -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Whitestack, LLC - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +aiokafka==0.7.0 + # via -r requirements.in +cached-property==1.5.2 + # via peewee-migrate +certifi==2020.12.5 + # via requests +chardet==4.0.0 + # via requests +click==7.1.2 + # via peewee-migrate +idna==2.10 + # via requests +jsonschema==2.6.0 + # via -r requirements.in +kafka-python==2.0.2 + # via aiokafka +mock==4.0.3 + # via peewee-migrate +peewee-migrate==1.1.6 + # via -r requirements.in +peewee==3.8.2 + # via + # -r requirements.in + # peewee-migrate +pymysql==0.9.3 + # via -r requirements.in +pyyaml==5.4.1 + # via -r requirements.in +requests==2.25.1 + # via -r requirements.in +urllib3==1.26.4 + # via requests +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: fbravo@whitestack.com or glavado@whitestack.com -## - -aiokafka==0.6.0 -peewee==3.8.* -jsonschema==2.6.* -pyyaml==3.* -pymysql==0.9.* -peewee-migrate==1.1.* -requests==2.* -git+https://osm.etsi.org/gerrit/osm/common.git@v9.0#egg=osm-common +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### diff --git a/setup.py b/setup.py index 31e2588..a2273ad 100644 --- a/setup.py +++ b/setup.py @@ -25,11 +25,11 @@ from setuptools import setup _name = 'osm_policy_module' _version_command = ('git describe --match v* --tags --long --dirty', 'pep440-git-full') -_author = "Benjamín Díaz" -_author_email = 'bdiaz@whitestack.com' +_author = "OSM Support" +_author_email = 'osmsupport@etsi.org' _description = 'OSM Policy Module' -_maintainer = 'Benjamín Díaz' -_maintainer_email = 'bdiaz@whitestack.com' +_maintainer = 'OSM Support' +_maintainer_email = 'osmsupport@etsi.org' _license = 'Apache 2.0' _url = 'https://osm.etsi.org/gitweb/?p=osm/MON.git;a=tree' @@ -47,24 +47,12 @@ setup( packages=[_name], package_dir={_name: _name}, include_package_data=True, - install_requires=[ - "aiokafka==0.6.0", - "peewee==3.8.*", - "jsonschema==2.6.*", - "pyyaml==3.*", - "pymysql", - "peewee-migrate==1.1.*", - "requests==2.*", - "osm-common", - ], + entry_points={ "console_scripts": [ "osm-policy-agent = osm_policy_module.cmd.policy_module_agent:main", "osm-pol-healthcheck = osm_policy_module.cmd.policy_module_healthcheck:main", ] }, - dependency_links=[ - 'git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common' - ], setup_requires=['setuptools-version-command'] ) diff --git a/stdeb.cfg b/stdeb.cfg index 021202c..c6a1b3a 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,3 +1,17 @@ +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + [DEFAULT] -X-Python3-Version : >= 3.4 -Depends3 : libmysqlclient-dev, python3-pip, python3-osm-common \ No newline at end of file +X-Python3-Version : >= 3.5 diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 8b0c62f..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2017 Intel Research and Development Ireland Limited -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Intel Corporation - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: helena.mcgough@intel.com or adrian.hoban@intel.com -## -flake8<3.0 -mock -coverage==4.5.3 diff --git a/tox.ini b/tox.ini index d3d576e..9c52bdb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,81 +1,122 @@ -# Copyright 2017 Intel Research and Development Ireland Limited -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Intel Corporation - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: helena.mcgough@intel.com or adrian.hoban@intel.com -## - -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### + [tox] -envlist = cover, flake8 +envlist = black, cover, flake8, pylint, safety +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] usedevelop = True -install_command = pip install -U {opts} {packages} +basepython = python3 setenv = VIRTUAL_ENV={envdir} PYTHONDONTWRITEBYTECODE = 1 - TESTS_DIR=./osm_policy_module/tests/unit/ -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +skip_install = true commands = - coverage erase + - black --check --diff osm_policy_module/ + +####################################################################################### [testenv:cover] -basepython = python3 -deps = nose2 - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = {[testenv]deps} + -r{toxinidir}/requirements-dev.txt + -r{toxinidir}/requirements-test.txt +commands = + sh -c 'rm -f nosetests.xml' + coverage erase + nose2 -C --coverage osm_policy_module + coverage report --omit='*tests*' + coverage html -d ./cover --omit='*tests*' + coverage xml -o coverage.xml --omit=*tests* +whitelist_externals = sh + + +####################################################################################### +[testenv:flake8] +deps = flake8 commands = - coverage erase - nose2 -C --coverage osm_policy_module --plugin nose2.plugins.junitxml - coverage report --omit='*tests*' - coverage html -d ./cover --omit='*tests*' - coverage xml -o coverage.xml --omit='*tests*' + flake8 osm_policy_module/ setup.py + +####################################################################################### [testenv:pylint] -basepython = python3 -deps = pylint - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = {[testenv]deps} + -r{toxinidir}/requirements-dev.txt + -r{toxinidir}/requirements-test.txt + pylint commands = pylint -E osm_policy_module -[testenv:flake8] -basepython = python3 -deps = flake8 - -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 +deps = {[testenv]deps} + safety commands = - flake8 osm_policy_module + - safety check --full-report -[testenv:build] -basepython = python3 -deps = stdeb - setuptools-version-command -commands = python3 setup.py --command-packages=stdeb.command bdist_deb +####################################################################################### +[testenv:pip-compile] +deps = pip-tools==5.5.0 +commands = + - sh -c 'for file in requirements*.in ; do pip-compile -rU --no-header $file ;\ + out=`echo $file | sed "s/.in/.txt/"` ; \ + head -16 tox.ini >> $out ;\ + done' +whitelist_externals = sh + + +####################################################################################### +[testenv:dist] +deps = {[testenv]deps} + -r{toxinidir}/requirements-dist.txt + +# In the commands, we copy the requirements.txt to be presented as a source file (.py) +# so it gets included in the .deb package for others to consume +commands = + sh -c 'cp requirements.txt osm_policy_module/requirements.txt' + python3 setup.py --command-packages=stdeb.command sdist_dsc + sh -c 'cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us' + sh -c 'rm osm_policy_module/requirements.txt' +whitelist_externals = sh + +####################################################################################### [flake8] -# E123, E125 skipped as they are invalid PEP-8. +ignore = + W291, + W293, + E123, + E125, + E226, + E241 +exclude = + .git, + __pycache__, + .tox, max-line-length = 120 show-source = True -ignore = E123,E125,E241 builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,devops_stages/*,.rst