From a1f627a5cd320c23d771c786039eeb4a858be954 Mon Sep 17 00:00:00 2001 From: beierlm Date: Tue, 23 Mar 2021 16:04:34 -0400 Subject: [PATCH] Feature 10296 Pip Standardization Cleanup of Dockerfile Moved requirements from devops/docker/tests/Dockerfile into this module so they are visible. Added pylint and safety hooks. Added place for unit tests, but none are written yet, so does not run them. Change-Id: I75ce40c558bd9bc8975269dca681ba84678e6de6 Signed-off-by: beierlm --- .gitignore | 3 + Dockerfile | 22 +- build-debpkg.sh | 2 +- requirements-dev.in | 17 ++ requirements-dev.txt | 54 ++++ requirements.in | 28 ++ requirements.txt | 397 ++++++++++++++++++++++++++++ robot-systest/resources/__init__.py | 17 ++ setup.py | 45 ++++ tox.ini | 99 +++++++ 10 files changed, 676 insertions(+), 8 deletions(-) create mode 100644 requirements-dev.in create mode 100644 requirements-dev.txt create mode 100644 requirements.in create mode 100644 requirements.txt create mode 100644 robot-systest/resources/__init__.py create mode 100644 setup.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 3384736..9b3d525 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ #IDEs .idea .vscode +.project +.pydevproject #Generated folders when building the deb package locally .tox @@ -36,3 +38,4 @@ dist local reports +envfile.rc diff --git a/Dockerfile b/Dockerfile index 65c2c78..b949260 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,21 @@ # 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/NBI in a docker container from source -# Use Dockerfile.fromdeb for running osm/NBI in a docker container from last stable package - -FROM ubuntu:16.04 +FROM ubuntu:18.04 -RUN apt-get update && apt-get -y install git make libcurl4-gnutls-dev \ - libgnutls-dev debhelper apt-utils dh-make +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -y install \ + debhelper \ + dh-make \ + git diff --git a/build-debpkg.sh b/build-debpkg.sh index 61cf51b..bd8955a 100755 --- a/build-debpkg.sh +++ b/build-debpkg.sh @@ -16,7 +16,7 @@ PKG_DIRECTORIES="robot-systest" -PKG_FILES="CONTRIBUTING.md LICENSE README.md charm.sh" +PKG_FILES="CONTRIBUTING.md LICENSE README.md charm.sh requirements.txt" MDG_NAME=tests DEB_INSTALL=debian/osm-${MDG_NAME}.install export DEBEMAIL="gerardo.garciadeblas@telefonica.com" diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000..794b302 --- /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/IM.git@master#egg=osm-im +git+https://osm.etsi.org/gerrit/osm/osmclient.git@master#egg=osm-osmclient diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..b7d397f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,54 @@ +certifi==2020.12.5 + # via requests +chardet==4.0.0 + # via requests +click==7.1.2 + # via osmclient +idna==2.10 + # via requests +jinja2==2.11.3 + # via osmclient +markupsafe==1.1.1 + # via jinja2 +git+https://osm.etsi.org/gerrit/osm/IM.git@master#egg=osm-im + # via + # -r requirements-dev.in + # osmclient +git+https://osm.etsi.org/gerrit/osm/osmclient.git@master#egg=osm-osmclient + # via -r requirements-dev.in +packaging==20.9 + # via osmclient +prettytable==2.1.0 + # via osmclient +pycurl==7.43.0.6 + # via osmclient +pyparsing==2.4.7 + # via packaging +python-magic==0.4.22 + # via osmclient +pyyaml==5.4.1 + # via osmclient +requests==2.25.1 + # via osmclient +urllib3==1.26.4 + # via requests +verboselogs==1.7 + # via osmclient +wcwidth==0.2.5 + # via prettytable +####################################################################################### +# 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..c0fb153 --- /dev/null +++ b/requirements.in @@ -0,0 +1,28 @@ +# 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. +## +bitarray==1.8.1 +charm-tools +haikunator +pyangbind +python-openstackclient +regex==2021.3.17 +requests +robotframework +robotframework-jsonlibrary +robotframework-requests +robotframework-seleniumlibrary +robotframework-sshlibrary +verboselogs \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..197a5ac --- /dev/null +++ b/requirements.txt @@ -0,0 +1,397 @@ +appdirs==1.4.4 + # via + # openstacksdk + # virtualenv +attrs==20.3.0 + # via cmd2 +bcrypt==3.2.0 + # via paramiko +bitarray==1.8.1 + # via + # -r requirements.in + # pyangbind +blessings==1.6 + # via charm-tools +certifi==2020.12.5 + # via requests +cffi==1.14.5 + # via + # bcrypt + # cryptography + # pynacl +chardet==4.0.0 + # via requests +charm-tools==2.8.3 + # via -r requirements.in +cheetah3==3.2.6.post1 + # via charm-tools +cliff==3.7.0 + # via + # osc-lib + # python-openstackclient +cmd2==1.5.0 + # via cliff +colander==1.7.0 + # via charm-tools +colorama==0.4.4 + # via cmd2 +coverage==5.5 + # via robotframework-jsonlibrary +cryptography==3.4.7 + # via + # openstacksdk + # paramiko + # secretstorage +debtcollector==2.2.0 + # via + # oslo.config + # oslo.utils + # python-keystoneclient +decorator==5.0.5 + # via + # dogpile.cache + # jsonpath-rw + # openstacksdk +dict2colander==0.2 + # via charm-tools +distlib==0.3.1 + # via virtualenv +distro==1.5.0 + # via lazr.restfulclient +dogpile.cache==1.1.2 + # via openstacksdk +enum34==1.1.10 + # via pyangbind +filelock==3.0.12 + # via virtualenv +haikunator==2.1.0 + # via -r requirements.in +httplib2==0.19.1 + # via + # launchpadlib + # lazr.restfulclient +idna==2.10 + # via requests +iso8601==0.1.14 + # via + # colander + # keystoneauth1 + # openstacksdk + # oslo.utils + # python-novaclient + # python-openstackclient +jmespath==0.10.0 + # via openstacksdk +jsonpatch==1.32 + # via openstacksdk +jsonpath-rw-ext==1.2.2 + # via robotframework-jsonlibrary +jsonpath-rw==1.4.0 + # via + # jsonpath-rw-ext + # robotframework-jsonlibrary +jsonpointer==2.1 + # via jsonpatch +jsonschema==2.5.1 + # via charm-tools +jujubundlelib==0.5.6 + # via + # charm-tools + # theblues +keyring==20.0.1 + # via + # charm-tools + # launchpadlib +keystoneauth1==4.3.1 + # via + # openstacksdk + # osc-lib + # python-cinderclient + # python-keystoneclient + # python-novaclient +launchpadlib==1.10.13 + # via charm-tools +lazr.restfulclient==0.14.3 + # via launchpadlib +lazr.uri==1.0.5 + # via + # launchpadlib + # wadllib +libcharmstore==0.0.9 + # via charm-tools +lxml==4.6.3 + # via + # pyang + # pyangbind +macaroonbakery==1.3.1 + # via theblues +msgpack==1.0.2 + # via oslo.serialization +munch==2.5.0 + # via openstacksdk +netaddr==0.8.0 + # via + # oslo.config + # oslo.utils +netifaces==0.10.9 + # via + # openstacksdk + # oslo.utils +oauthlib==3.1.0 + # via lazr.restfulclient +openstacksdk==0.55.0 + # via + # osc-lib + # python-openstackclient +os-service-types==1.7.0 + # via + # keystoneauth1 + # openstacksdk +osc-lib==2.3.1 + # via python-openstackclient +oslo.config==8.5.0 + # via python-keystoneclient +oslo.i18n==5.0.1 + # via + # osc-lib + # oslo.config + # oslo.utils + # python-cinderclient + # python-keystoneclient + # python-novaclient + # python-openstackclient +oslo.serialization==4.1.0 + # via + # python-keystoneclient + # python-novaclient +oslo.utils==4.8.0 + # via + # osc-lib + # oslo.serialization + # python-cinderclient + # python-keystoneclient + # python-novaclient + # python-openstackclient +otherstuf==1.1.0 + # via charm-tools +packaging==20.9 + # via oslo.utils +paramiko==2.7.2 + # via + # robotframework-sshlibrary + # scp +parse==1.19.0 + # via stuf +path.py==12.5.0 + # via charm-tools +path==15.1.2 + # via path.py +pathspec==0.3.4 + # via charm-tools +pbr==5.5.1 + # via + # cliff + # debtcollector + # jsonpath-rw-ext + # keystoneauth1 + # openstacksdk + # os-service-types + # osc-lib + # oslo.i18n + # oslo.serialization + # oslo.utils + # python-cinderclient + # python-keystoneclient + # python-novaclient + # python-openstackclient + # stevedore + # testresources +pluggy==0.13.1 + # via tox +ply==3.11 + # via jsonpath-rw +prettytable==2.1.0 + # via + # cliff + # python-cinderclient + # python-novaclient +protobuf==3.15.7 + # via macaroonbakery +py==1.10.0 + # via tox +pyang==2.4.0 + # via pyangbind +pyangbind==0.8.1 + # via -r requirements.in +pycparser==2.20 + # via cffi +pymacaroons==0.13.0 + # via macaroonbakery +pynacl==1.4.0 + # via + # macaroonbakery + # paramiko + # pymacaroons +pyparsing==2.4.7 + # via + # cliff + # httplib2 + # oslo.utils + # packaging +pyperclip==1.8.2 + # via cmd2 +pyrfc3339==1.1 + # via macaroonbakery +python-cinderclient==7.4.0 + # via python-openstackclient +python-keystoneclient==4.2.0 + # via python-openstackclient +python-novaclient==17.4.0 + # via python-openstackclient +python-openstackclient==5.5.0 + # via -r requirements.in +pytz==2021.1 + # via + # oslo.serialization + # oslo.utils + # pyrfc3339 +pyyaml==5.4.1 + # via + # charm-tools + # cliff + # jujubundlelib + # openstacksdk + # oslo.config +regex==2021.3.17 + # via + # -r requirements.in + # pyangbind +requests==2.25.1 + # via + # -r requirements.in + # charm-tools + # keystoneauth1 + # macaroonbakery + # oslo.config + # python-cinderclient + # python-keystoneclient + # robotframework-requests + # theblues +requestsexceptions==1.4.0 + # via openstacksdk +requirements-parser==0.2.0 + # via charm-tools +rfc3986==1.4.0 + # via oslo.config +robotframework-jsonlibrary==0.3.1 + # via -r requirements.in +robotframework-pythonlibcore==2.2.1 + # via robotframework-seleniumlibrary +robotframework-requests==0.8.2 + # via -r requirements.in +robotframework-seleniumlibrary==5.1.3 + # via -r requirements.in +robotframework-sshlibrary==3.6.0 + # via -r requirements.in +robotframework==4.0 + # via + # -r requirements.in + # robotframework-jsonlibrary + # robotframework-requests + # robotframework-seleniumlibrary + # robotframework-sshlibrary +ruamel.yaml==0.15.100 + # via charm-tools +scp==0.13.3 + # via robotframework-sshlibrary +secretstorage==2.3.1 + # via + # charm-tools + # keyring +selenium==3.141.0 + # via robotframework-seleniumlibrary +simplejson==3.17.2 + # via + # osc-lib + # python-cinderclient +six==1.15.0 + # via + # bcrypt + # debtcollector + # jsonpath-rw + # keystoneauth1 + # launchpadlib + # lazr.restfulclient + # macaroonbakery + # munch + # oslo.i18n + # protobuf + # pyangbind + # pymacaroons + # pynacl + # python-keystoneclient + # tox + # virtualenv +stevedore==3.3.0 + # via + # cliff + # dogpile.cache + # keystoneauth1 + # osc-lib + # oslo.config + # python-cinderclient + # python-keystoneclient + # python-novaclient + # python-openstackclient +stuf==0.9.16 + # via otherstuf +testresources==2.0.1 + # via launchpadlib +theblues==0.5.2 + # via libcharmstore +tox==3.0.0 + # via robotframework-jsonlibrary +translationstring==1.4 + # via colander +urllib3==1.26.4 + # via + # requests + # selenium +verboselogs==1.7 + # via -r requirements.in +vergit==1.0.2 + # via charm-tools +virtualenv==20.4.3 + # via + # charm-tools + # tox +wadllib==1.3.5 + # via + # launchpadlib + # lazr.restfulclient +wcwidth==0.2.5 + # via + # cmd2 + # prettytable +wrapt==1.12.1 + # via debtcollector + +# The following packages are considered to be unsafe in a requirements file: +# pip +# 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/robot-systest/resources/__init__.py b/robot-systest/resources/__init__.py new file mode 100644 index 0000000..d10c534 --- /dev/null +++ b/robot-systest/resources/__init__.py @@ -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. +####################################################################################### + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2049a93 --- /dev/null +++ b/setup.py @@ -0,0 +1,45 @@ +####################################################################################### +# 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. +####################################################################################### + +from setuptools import setup + +_name = 'tests' +_version_command = ('git describe --match v* --tags --long --dirty', 'pep440-git-full') +_author = "OSM Support" +_author_email = 'osmsupport@etsi.org' +_description = 'OSM Tests' +_maintainer = 'OSM Support' +_maintainer_email = 'osmsupport@etsi.org' +_license = 'Apache 2.0' +_url = 'https://osm.etsi.org/gitweb/?p=osm/tests.git;a=tree' + +setup( + name=_name, + version_command=_version_command, + description=_description, + long_description=open('README.md', encoding='utf-8').read(), + author=_author, + author_email=_author_email, + maintainer=_maintainer, + maintainer_email=_maintainer_email, + url=_url, + license=_license, + packages=[_name], + package_dir={_name: 'robot-systest'}, + include_package_data=True, + setup_requires=['setuptools-version-command'] +) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4f67210 --- /dev/null +++ b/tox.ini @@ -0,0 +1,99 @@ +####################################################################################### +# 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. +####################################################################################### + +[tox] +envlist = black, cover, flake8, pylint, safety + +[tox:jenkins] +toxworkdir = /tmp/.tox + +[testenv] +usedevelop = True +basepython = python3 +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 +deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +skip_install = true +commands = + - black --check --diff robot-systest --fast + + +####################################################################################### +[testenv:cover] +commands = + sh -c 'echo No unit tests' +whitelist_externals = sh + + +####################################################################################### +[testenv:flake8] +deps = flake8 +commands = + flake8 robot-systest + + +####################################################################################### +[testenv:pylint] +deps = {[testenv]deps} + -r{toxinidir}/requirements-dev.txt + pylint +commands = + pylint -E robot-systest/resources + + +####################################################################################### +[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 + + +####################################################################################### +[flake8] +ignore = + W291, + W293, + E123, + E125, + E226, + E241 +exclude = + .git, + __pycache__, + .tox, +max-line-length = 120 +show-source = True +builtins = _ -- 2.25.1