From: garciadeblas Date: Tue, 9 Jul 2024 12:30:15 +0000 (+0200) Subject: Add tox.ini and requirements, update Dockerfile X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=56e0be7ebaddd5e32cd850c560c352f0d7458461;p=osm%2Fdocker-api-fe.git Add tox.ini and requirements, update Dockerfile Change-Id: I2489a64b55e29eeb0c20cb4441e609fa8120ad11 Signed-off-by: garciadeblas --- diff --git a/Dockerfile b/Dockerfile index 6761fe1..6b5c15f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,18 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ubuntu:18.04 +FROM ubuntu:22.04 + +RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ + DEBIAN_FRONTEND=noninteractive apt-get --yes install \ + python3=3.10.* \ + python3-pip=22.0.* \ + && rm -rf /var/lib/apt/lists/* + +# gcc=4:11.* \ +# python3-dev=3.10.* \ +# curl=7.81.* \ # Set the working directory to /app WORKDIR /app/EE # Libraries used by the base osm defined ee RUN apt-get update && apt-get install -y git python3 python3-pip \ - && python3 -m pip install --upgrade pip \ - && python3 -m pip install -U grpcio-tools \ - && python3 -m pip install -U grpclib \ - && python3 -m pip install -U PyYAML \ - && python3 -m pip install -U kubernetes + && python3 -m pip install --upgrade pip # Libraries used by the vnf: asyncssh, ansible #RUN apt-get update && apt-get install software-properties-common \ @@ -38,7 +44,7 @@ RUN apt-get update && apt-get install -y git python3 python3-pip \ ADD . /app/EE # Install as module -RUN python3 -m pip install -e /app/EE +RUN python3 -m pip install -e /app/EE -r /app/EE/requirements.txt # Install SNMP Generator and its dependencies #RUN apt-get install -y python3-pip unzip build-essential libsnmp-dev wget curl diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh new file mode 100755 index 0000000..45a6b1c --- /dev/null +++ b/devops-stages/stage-test.sh @@ -0,0 +1,19 @@ +#!/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. +## + +echo "Launching tox" +TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto + diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..0d5b3d1 --- /dev/null +++ b/requirements.in @@ -0,0 +1,18 @@ +## +# 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. +## + +grpcio-tools +grpclib +kubernetes +pyyaml diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a2a308b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,83 @@ +####################################################################################### +# 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. +####################################################################################### +cachetools==5.3.3 + # via google-auth +certifi==2024.7.4 + # via + # kubernetes + # requests +charset-normalizer==3.3.2 + # via requests +google-auth==2.32.0 + # via kubernetes +grpcio==1.64.1 + # via grpcio-tools +grpcio-tools==1.64.1 + # via -r requirements.in +grpclib==0.4.7 + # via -r requirements.in +h2==4.1.0 + # via grpclib +hpack==4.0.0 + # via h2 +hyperframe==6.0.1 + # via h2 +idna==3.7 + # via requests +kubernetes==30.1.0 + # via -r requirements.in +multidict==6.0.5 + # via grpclib +oauthlib==3.2.2 + # via + # kubernetes + # requests-oauthlib +protobuf==5.27.2 + # via grpcio-tools +pyasn1==0.6.0 + # via + # pyasn1-modules + # rsa +pyasn1-modules==0.4.0 + # via google-auth +python-dateutil==2.9.0.post0 + # via kubernetes +pyyaml==6.0.1 + # via + # -r requirements.in + # kubernetes +requests==2.32.3 + # via + # kubernetes + # requests-oauthlib +requests-oauthlib==2.0.0 + # via kubernetes +rsa==4.9 + # via google-auth +six==1.16.0 + # via + # kubernetes + # python-dateutil +urllib3==2.2.2 + # via + # kubernetes + # requests +websocket-client==1.8.0 + # via kubernetes + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/setup.py b/setup.py index ab68a84..7d11087 100644 --- a/setup.py +++ b/setup.py @@ -20,30 +20,29 @@ from setuptools import setup _name = "osm_ee" -_description = 'OSM Resource Orchestrator' -_author = 'ETSI OSM' -_author_email = 'illoret@indra.es' -_maintainer = 'alfonso.tiernosepulveda' -_maintainer_email = 'alfonso.tiernosepulveda@telefonica.com' -_license = 'Apache 2.0' -_url = 'TOBEDEFINED' +_description = "OSM Resource Orchestrator" +_author = "ETSI OSM" +_author_email = "illoret@indra.es" +_maintainer = "alfonso.tiernosepulveda" +_maintainer_email = "alfonso.tiernosepulveda@telefonica.com" +_license = "Apache 2.0" +_url = "TOBEDEFINED" _requirements = [ # Libraries needed by the code defined by osm "PyYAML", "grpcio-tools", "grpclib", "protobuf", - # Libraries defined by the vnf code, they should be in an external file - #"asyncssh", + # "asyncssh", ] setup( name=_name, - #version_command=('0.1'), # TODO - replace for a git command - version='1.0', + # version_command=('0.1'), # TODO - replace for a git command + version="1.0", description=_description, - long_description=open('README.rst').read(), + long_description=open("README.rst").read(), author=_author, author_email=_author_email, maintainer=_maintainer, @@ -52,8 +51,7 @@ setup( license=_license, packages=[_name], package_dir={_name: _name}, - install_requires=_requirements, include_package_data=True, - setup_requires=['setuptools-version-command'], -) \ No newline at end of file + setup_requires=["setuptools-version-command"], +) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ded7c50 --- /dev/null +++ b/tox.ini @@ -0,0 +1,98 @@ +####################################################################################### +# 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, flake8, pylint, safety + +[tox:jenkins] +toxworkdir = /tmp/.tox + +[testenv] +usedevelop = True +basepython = python3.10 +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 +deps = -r{toxinidir}/requirements.txt +parallel_show_output = true + +####################################################################################### +[testenv:black] +deps = black==24.4.2 +skip_install = true +commands = + black --check --diff osm_ee/ --exclude="frontend_pb2.py" + black --check --diff setup.py + + +####################################################################################### +[testenv:flake8] +deps = flake8==7.1.0 +commands = + flake8 osm_ee/ setup.py + + +####################################################################################### +[testenv:pylint] +deps = {[testenv]deps} + pylint==3.1.1 +commands = + pylint -E osm_ee + + +####################################################################################### +[testenv:safety] +deps = {[testenv]deps} + safety +commands = + - safety check --full-report + + +####################################################################################### +[testenv:pip-compile] +deps = pip-tools==6.13.0 +skip_install = true +allowlist_externals = bash + [ +commands = + - bash -c "for file in requirements*.in ; do \ + UNSAFE="" ; \ + if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \ + pip-compile --resolver=backtracking -rU --no-header $UNSAFE $file ;\ + out=`echo $file | sed 's/.in/.txt/'` ; \ + sed -i -e '1 e head -16 tox.ini' $out ;\ + done" + + +####################################################################################### +[flake8] +ignore = +# W291, +# W293, +# W503, +# E123, +# E125, +# E226, +# E241, +# E203 +exclude = + .git, + __pycache__, + .tox, + osm_ee/frontend_pb2.py, +max-line-length = 120 +show-source = True +builtins = _