From: garciadeblas Date: Tue, 9 Jul 2024 12:32:13 +0000 (+0200) Subject: Add tox environments to generate Python code from protobuf messages X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=302826fc506b89e4346da3ae400b8abb87455800;p=osm%2Fdocker-api-fe.git Add tox environments to generate Python code from protobuf messages Change-Id: I79b6675373c2ee289e226553ccb6b6a841257ec5 Signed-off-by: garciadeblas --- diff --git a/Dockerfile-proto b/Dockerfile-proto new file mode 100644 index 0000000..2001d54 --- /dev/null +++ b/Dockerfile-proto @@ -0,0 +1,35 @@ +# +# 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 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.* \ + curl=7.81.* \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Download protobuf zip +ENV PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v27.2/protoc-27.2-linux-x86_64.zip" +ENV PROTOC_ZIP="protoc-27.2-linux-x86_64.zip" + +RUN curl -LO ${PROTOC_URL} && \ + unzip -o ${PROTOC_ZIP} -d ./proto && \ + install -m 0755 ./proto/bin/protoc /usr/local/bin && \ + cp -R ./proto/include/* /usr/local/include/ + +ENTRYPOINT [ "/usr/local/bin/protoc" ] + diff --git a/tox.ini b/tox.ini index ded7c50..11071ca 100644 --- a/tox.ini +++ b/tox.ini @@ -61,6 +61,23 @@ commands = - safety check --full-report +####################################################################################### +[testenv:proto] +skip_install = true +commands = + protoc --python_out=. osm_ee/frontend.proto +allowlist_externals = protoc + + +####################################################################################### +[testenv:protodocker] +skip_install = true +commands = + docker build -f Dockerfile-proto . -t protobuf + docker run --rm -it -v ./osm_ee:/work -w /work protobuf --python_out=. frontend.proto +allowlist_externals = docker + + ####################################################################################### [testenv:pip-compile] deps = pip-tools==6.13.0