From 9db158c13372d7837ca820c3a49ede5edd593774 Mon Sep 17 00:00:00 2001 From: beierlm Date: Wed, 17 Mar 2021 08:11:23 -0400 Subject: [PATCH] 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: I15c8ec22ad911d5bfa67df5a85175642a59da971 Signed-off-by: beierlm --- .gitignore | 34 +++ .gitlab-ci.yml | 17 ++ Dockerfile | 41 ++-- MANIFEST.in | 2 +- devops-stages/stage-build.sh | 5 +- devops-stages/stage-test.sh | 5 +- Makefile => requirements-dev.in | 17 +- requirements-dev.txt | 210 ++++++++++++++++++ requirements-dist.in | 17 ++ requirements-dist.txt | 23 ++ test-requirements.txt => requirements-test.in | 5 +- requirements-test.txt | 28 +++ ...ython3-osm-lcm.postinst => requirements.in | 20 +- requirements.txt | 80 +++++-- setup.py | 39 ++-- stdeb.cfg | 1 - tox.ini | 134 ++++++++--- 17 files changed, 550 insertions(+), 128 deletions(-) create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml rename Makefile => requirements-dev.in (52%) create mode 100644 requirements-dev.txt create mode 100644 requirements-dist.in create mode 100644 requirements-dist.txt rename test-requirements.txt => requirements-test.in (96%) create mode 100644 requirements-test.txt rename debian/python3-osm-lcm.postinst => requirements.in (60%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e6dc4cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# 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. + +__pycache__ +*.pyc +.tox/ +dist/ +.cache/ +.local/ +.eggs +osm_lcm.egg-info/ +.coverage +cover +coverage.xml +.tox +nosetests.xml +.cache +.vscode/ +.project +.settings +.pydevproject +pyvenv.cfg +venv/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..eb9750e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +# Copyright Contributors to ETSI OSM +# +# 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. + +include: + - project: 'devops/cicd' + file: '/templates/osm-base.yml' diff --git a/Dockerfile b/Dockerfile index 79c1a50..8230f42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# Copyright 2018 Telefonica S.A. -# # 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 @@ -12,27 +10,30 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. - -# This Dockerfile is intented for devops and deb package generation +######################################################################################## +# 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 # -# Use Dockerfile.local for running osm/LCM in a docker container from source - FROM ubuntu:18.04 -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox make debhelper wget \ - python-all python3 python3-pip python3-all apt-utils && \ - DEBIAN_FRONTEND=noninteractive pip3 install -U setuptools setuptools-version-command stdeb - -# TODO delete if not needed: -# libcurl4-gnutls-dev libgnutls-dev python-dev python3-dev python-setuptools - +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -y install \ + debhelper \ + git \ + python3 \ + python3-all \ + python3-dev \ + python3-setuptools -# Uncomment this block to generate automatically a debian package and show info -# # Set the working directory to /app -# WORKDIR /app -# # Copy the current directory contents into the container at /app -# ADD . /app -# CMD /app/devops-stages/stage-build.sh && find -name "*.deb" -exec dpkg -I {} ";" +RUN python3 -m easy_install pip==21.0.1 +RUN pip3 install tox==3.22.0 +ENV LC_ALL C.UTF-8 +ENV LANG C.UTF-8 diff --git a/MANIFEST.in b/MANIFEST.in index 84ee0e9..46ee438 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -14,6 +14,6 @@ # limitations under the License. include README.rst -recursive-include osm_lcm *.py *.xml *.sh lcm.cfg +recursive-include osm_lcm *.py *.xml *.sh lcm.cfg *.txt recursive-include devops-stages * diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index 2db54db..47c2efc 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -14,7 +14,6 @@ # under the License. ## -# For the moment it is not needed any post-intall action, so tox instead of Makefile is used - -make clean package +rm -rf dist deb_dist osm*.tar.gz *.egg-info .eggs +tox -e dist \ No newline at end of file diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index 36e445d..141fa55 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -13,5 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. ## -rm -f nosetests.xml -tox # flake8 unittest + +OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto) +printf "$OUTPUT" diff --git a/Makefile b/requirements-dev.in similarity index 52% rename from Makefile rename to requirements-dev.in index cdbb183..d66bea5 100644 --- a/Makefile +++ b/requirements-dev.in @@ -1,4 +1,4 @@ -# Copyright 2018 Telefonica S.A. +# 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. @@ -13,15 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -all: clean package - -clean: - rm -rf dist deb_dist osm_lcm-*.tar.gz osm_lcm.egg-info .eggs - -package: - python3 setup.py --command-packages=stdeb.command sdist_dsc - cp debian/python3-osm-lcm.postinst deb_dist/osm-lcm*/debian - # cd deb_dist/osm-lcm*/debian && echo "osm-common python3-osm-common" > py3dist-overrides - # cd deb_dist/osm-lcm*/debian && echo "pip3 python3-pip" >> py3dist-overrides - cd deb_dist/osm-lcm*/ && dpkg-buildpackage -rfakeroot -uc -us +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 +git+https://osm.etsi.org/gerrit/osm/N2VC.git@v9.0#egg=n2vc +-r https://osm.etsi.org/gitweb/?p=osm/N2VC.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..aece680 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,210 @@ +aiokafka==0.7.0 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +async-timeout==3.0.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # retrying-async +bcrypt==3.2.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # paramiko +cachetools==4.2.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # google-auth +certifi==2020.12.5 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes + # requests +cffi==1.14.5 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # bcrypt + # cryptography + # pynacl +chardet==4.0.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # requests +cryptography==3.4.7 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # paramiko +dataclasses==0.6 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +google-auth==1.28.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes +idna==2.10 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # requests +juju==2.8.4 + # via -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 +jujubundlelib==0.5.6 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # theblues +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 +kubernetes==10.0.1 + # via -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 +macaroonbakery==1.3.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju + # theblues +motor==1.3.1 + # via -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 +mypy-extensions==0.4.3 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # typing-inspect +git+https://osm.etsi.org/gerrit/osm/N2VC.git@v9.0#egg=n2vc + # via -r requirements-dev.in +oauthlib==3.1.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # requests-oauthlib +git+https://osm.etsi.org/gerrit/osm/common.git@v9.0#egg=osm-common + # via -r requirements-dev.in +paramiko==2.7.2 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju +protobuf==3.15.6 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # macaroonbakery +pyasn1-modules==0.2.8 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # google-auth +pyasn1==0.4.8 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju + # pyasn1-modules + # rsa +pycparser==2.20 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # cffi +pycrypto==2.6.1 + # via -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 +pymacaroons==0.13.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # macaroonbakery +pymongo==3.11.3 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # motor +pynacl==1.4.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # macaroonbakery + # paramiko + # pymacaroons +pyrfc3339==1.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju + # macaroonbakery +python-dateutil==2.8.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes +pytz==2021.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # pyrfc3339 +pyyaml==5.4.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # -r https://osm.etsi.org/gitweb/?p=osm/common.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju + # jujubundlelib + # kubernetes +requests-oauthlib==1.3.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes +requests==2.25.1 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes + # macaroonbakery + # requests-oauthlib + # theblues +retrying-async==1.2.0 + # via -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 +rsa==4.7.2 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # google-auth +six==1.15.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # bcrypt + # google-auth + # kubernetes + # macaroonbakery + # protobuf + # pymacaroons + # pynacl + # python-dateutil + # websocket-client +theblues==0.5.2 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju +toposort==1.6 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju +typing-extensions==3.7.4.3 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # typing-inspect +typing-inspect==0.6.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju +urllib3==1.26.4 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes + # requests +websocket-client==0.58.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # kubernetes +websockets==7.0 + # via + # -r https://osm.etsi.org/gitweb/?p=osm/N2VC.git;a=blob_plain;f=requirements.txt;hb=v9.0 + # juju + +# 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-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/test-requirements.txt b/requirements-test.in similarity index 96% rename from test-requirements.txt rename to requirements-test.in index c2aa856..15fb5ee 100644 --- a/test-requirements.txt +++ b/requirements-test.in @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -flake8<3.0 asynctest - +coverage +mock +nose2 \ No newline at end of file diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..3b87659 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,28 @@ +asynctest==0.13.0 + # via -r requirements-test.in +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/debian/python3-osm-lcm.postinst b/requirements.in old mode 100755 new mode 100644 similarity index 60% rename from debian/python3-osm-lcm.postinst rename to requirements.in index 8a7082c..6307ee1 --- a/debian/python3-osm-lcm.postinst +++ b/requirements.in @@ -1,5 +1,3 @@ -#!/bin/bash - ## # 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 @@ -12,17 +10,11 @@ # 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 with: OSM_TECH@list.etsi.org ## -echo "POST INSTALL OSM-LCM" -echo "Installing python dependencies grpcio-tools grpclib via pip..." -echo -python3 -m pip install -U pip -python3 -m pip install grpcio-tools grpclib - -# Creation of log folder -# mkdir -p /var/log/osm - +aiohttp +grpcio-tools +grpclib +idna==2.10 +jinja2 +pyyaml diff --git a/requirements.txt b/requirements.txt index 37a5599..9212e2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,64 @@ -## -# 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 +aiohttp==3.7.4.post0 + # via -r requirements.in +async-timeout==3.0.1 + # via aiohttp +attrs==20.3.0 + # via aiohttp +chardet==4.0.0 + # via aiohttp +grpcio-tools==1.36.1 + # via -r requirements.in +grpcio==1.36.1 + # via grpcio-tools +grpclib==0.4.1 + # via -r requirements.in +h2==4.0.0 + # via grpclib +hpack==4.0.0 + # via h2 +hyperframe==6.0.0 + # via h2 +idna==2.10 + # via + # -r requirements.in + # yarl +jinja2==2.11.3 + # via -r requirements.in +markupsafe==1.1.1 + # via jinja2 +multidict==5.1.0 + # via + # aiohttp + # grpclib + # yarl +protobuf==3.15.6 + # via grpcio-tools +pyyaml==5.4.1 + # via -r requirements.in +six==1.15.0 + # via + # grpcio + # protobuf +typing-extensions==3.7.4.3 + # via aiohttp +yarl==1.6.3 + # via aiohttp + +# 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 +# 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. -## - -pyyaml -aiohttp>=2.3.10 -jinja2 -grpcio-tools -grpclib -git+https://osm.etsi.org/gerrit/osm/common.git@v9.0#egg=osm-common -git+https://osm.etsi.org/gerrit/osm/N2VC.git@v9.0#egg=n2vc - +# 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 411066f..664b32d 100644 --- a/setup.py +++ b/setup.py @@ -23,39 +23,26 @@ _name = "osm_lcm" # version is at first line of osm_lcm/html_public/version here = os.path.abspath(os.path.dirname(__file__)) # VERSION = "4.0.1rc1" -with open(os.path.join(here, 'README.rst')) as readme_file: +with open(os.path.join(here, "README.rst")) as readme_file: README = readme_file.read() setup( name=_name, - description='OSM Life Cycle Management module', + description="OSM Life Cycle Management module", long_description=README, - version_command=('git describe --match v* --tags --long --dirty', 'pep440-git-full'), + version_command=( + "git describe --match v* --tags --long --dirty", + "pep440-git-full", + ), # version=VERSION, # python_requires='>3.5.0', - author='ETSI OSM', - author_email='alfonso.tiernosepulveda@telefonica.com', - maintainer='Alfonso Tierno', - maintainer_email='alfonso.tiernosepulveda@telefonica.com', - url='https://osm.etsi.org/gitweb/?p=osm/LCM.git;a=summary', - license='Apache 2.0', - + author="ETSI OSM", + author_email="osmsupport@etsi.org", + maintainer="ETSI OSM", + maintainer_email="osmsupport@etsi.org", + url="https://osm.etsi.org/gitweb/?p=osm/LCM.git;a=summary", + license="Apache 2.0", packages=[_name], include_package_data=True, - # data_files=[('/etc/osm/', ['osm_lcm/lcm.cfg']), - # ('/etc/systemd/system/', ['osm_lcm/osm-lcm.service']), - # ], - install_requires=[ - # 'pymongo', - 'PyYAML', - 'aiohttp>=2.3.10', - 'osm-common', - 'n2vc', - 'jinja2', - 'grpcio-tools', - 'grpclib', - # TODO this is version installed by 'apt python3-aiohttp' on Ubuntu Sserver 14.04 - # version installed by pip 3.3.2 is not compatible. Code should be migrated to this version and use pip3 - ], - setup_requires=['setuptools-version-command'], + setup_requires=["setuptools-version-command"], ) diff --git a/stdeb.cfg b/stdeb.cfg index 2794a1f..ba313de 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -17,4 +17,3 @@ ## [DEFAULT] X-Python3-Version : >= 3.6 -Depends3: python3-osm-common, python3-n2vc, python3-yaml, python3-aiohttp, python3-jinja2, python3-pip diff --git a/tox.ini b/tox.ini index 2b8b682..e9816cd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ -# Copyright 2018 Telefonica S.A. +####################################################################################### +# 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. @@ -12,42 +13,119 @@ # 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 basepython = python3 -install_command = python3 -m pip install -r requirements.txt -U {opts} {packages} +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 +deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +skip_install = true +commands = + - black --check --diff osm_lcm/ + - black --check --diff setup.py + +####################################################################################### [testenv:cover] -basepython = python3 -deps = - nose2 - nose2-cov - coverage - -rrequirements.txt - -rtest-requirements.txt +deps = {[testenv]deps} + -r{toxinidir}/requirements-dev.txt + -r{toxinidir}/requirements-test.txt commands = - coverage erase - nose2 -C --coverage osm_lcm --plugin nose2.plugins.junitxml -s osm_lcm/tests - coverage report --omit='*tests*' - coverage html -d ./cover --omit='*tests*' - coverage xml -o coverage.xml --omit='*tests*' + sh -c 'rm -f nosetests.xml' + coverage erase + nose2 -C --coverage osm_lcm + coverage report --omit='*tests*' + coverage html -d ./cover --omit='*tests*' + coverage xml -o coverage.xml --omit=*tests* +whitelist_externals = sh + +####################################################################################### [testenv:flake8] -basepython = python3 -deps = - flake8 - -rrequirements.txt -commands = flake8 osm_lcm --max-line-length 120 \ - --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp,frontend_grpc.py,frontend_pb2.py \ - --ignore W291,W293,E226,W504 - -[testenv:build] -basepython = python3 -deps = stdeb - setuptools-version-command -commands = python3 setup.py --command-packages=stdeb.command bdist_deb +deps = flake8 +commands = + flake8 osm_lcm/ setup.py + + +####################################################################################### +[testenv:pylint] +deps = {[testenv]deps} + -r{toxinidir}/requirements-dev.txt + -r{toxinidir}/requirements-test.txt + pylint +commands = + - pylint -E osm_lcm + + +####################################################################################### +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 +deps = {[testenv]deps} + safety +commands = + - safety check --full-report + + +####################################################################################### +[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_lcm/requirements.txt' + python3 setup.py --command-packages=stdeb.command sdist_dsc + sh -c 'cd deb_dist/osm-lcm*/ && dpkg-buildpackage -rfakeroot -uc -us' + sh -c 'rm osm_lcm/requirements.txt' +whitelist_externals = sh +####################################################################################### +[flake8] +ignore = + W291, + W293, + W503, + E123, + E125, + E226, + E241, +# Temporary until code can be reformatted + E121, + E122, + E203, + E303, + E501 + W504 +exclude = + .git, + __pycache__, + .tox, +max-line-length = 120 +show-source = True +builtins = _ -- 2.25.1