From ff2d24962f61721491e9e811e39e76ec1d9d9213 Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Wed, 20 Sep 2023 16:17:38 +0200 Subject: [PATCH] ci: Check Python code with black and mypy Signed-off-by: Philipp Jungkamp --- .gitlab-ci.yml | 12 +++++++----- packaging/docker/Dockerfile.fedora | 13 ++++++++++--- python/setup.py | 8 -------- 3 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 python/setup.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 457df0b77..88bab1d25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,15 +88,17 @@ build:source: # Stage: test -test:flake8: +test:python: stage: test script: - - flake8 --ignore=E501 python/ + - cd python + - /venv/bin/black --check . + - /venv/bin/mypy . + - /venv/bin/flake8 . + - /venv/bin/pytest -v . image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG} tags: - docker - needs: - - job: "build:source: [fedora]" test:cppcheck: stage: test @@ -217,7 +219,7 @@ pkg:docker: ARCH: arm64 TRIPLET: aarch64-linux-gnu DOCKER_FILE: packaging/docker/Dockerfile.debian-multiarch - + needs: [] # Stage: deploy diff --git a/packaging/docker/Dockerfile.fedora b/packaging/docker/Dockerfile.fedora index 2d1ef0c0e..d28802f2c 100644 --- a/packaging/docker/Dockerfile.fedora +++ b/packaging/docker/Dockerfile.fedora @@ -27,7 +27,7 @@ RUN dnf -y install \ openssh-clients \ jq nmap-ncat \ iproute iproute-tc \ - python-pip \ + python python-devel python-pip \ gdb gdb-gdbserver \ cppcheck \ xmlto dblatex rubygem-asciidoctor \ @@ -37,8 +37,7 @@ RUN dnf -y install \ # Tools for debugging, coverage, profiling RUN pip install \ gcovr \ - protobuf \ - flake8 + protobuf # Dependencies RUN dnf -y install \ @@ -79,6 +78,12 @@ RUN ldconfig # Workaround for libnl3's search path for netem distributions RUN ln -s /usr/lib64/tc /usr/lib/tc +COPY ./python /python +RUN python -m venv /venv && \ + source /venv/bin/activate && \ + pip install /python[dev] && \ + rm -r /python + # Expose ports for HTTP and WebSocket frontend EXPOSE 80 EXPOSE 443 @@ -112,6 +117,8 @@ RUN --mount=type=cache,id=${DISTRO}-${FEDORA_VERSION}-${ARCH}-${REF},target=/vil make -j$(nproc) install && \ ldconfig +WORKDIR /villas + ENTRYPOINT ["villas"] LABEL \ diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index 2d19d0d65..000000000 --- a/python/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University -SPDX-License-Identifier: Apache-2.0 -""" # noqa: E501 - -from setuptools import setup - -setup()