From: Tomas Krizek Date: Wed, 19 Jan 2022 16:06:46 +0000 (+0100) Subject: ci: execute manager unit tests X-Git-Tag: v6.0.0a1~47^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aceeecc8cc09e1ddff1537e8573a01358979891;p=thirdparty%2Fknot-resolver.git ci: execute manager unit tests --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0eee4c199..de5fe27f1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -346,8 +346,9 @@ pkgtest: variables: - $SKIP_CI == "1" -manager: # TODO better CI integration +manager: stage: test + needs: [] trigger: include: manager/.gitlab-ci.yml strategy: depend diff --git a/ci/images/manager/Dockerfile b/ci/images/manager/Dockerfile new file mode 100644 index 000000000..807923d06 --- /dev/null +++ b/ci/images/manager/Dockerfile @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +FROM fedora:35 +MAINTAINER Knot Resolver + +WORKDIR /root +CMD ["/bin/bash"] +ENV PATH="/root/.local/bin:${PATH}" + +# Install Python +RUN dnf install -y git diffutils python3.6 python3.7 python3.8 python3.9 python3.10 python3-gobject pkg-config cairo-devel gcc python3-devel gobject-introspection-devel cairo-gobject-devel which \ + && dnf clean all + +# Install Poetry +RUN python3 -m pip install -U pip \ + && curl -sSL https://install.python-poetry.org | python3 - \ + # not exactly required, but helpful + && python3 -m pip install poethepoet diff --git a/manager/.gitlab-ci.yml b/manager/.gitlab-ci.yml index 7c5c40def..f8b2d0f0d 100644 --- a/manager/.gitlab-ci.yml +++ b/manager/.gitlab-ci.yml @@ -1,32 +1,26 @@ stages: - check - - packaging default: - image: registry.nic.cz/knot/knot-resolver-manager/knot-manager:ci + image: registry.nic.cz/knot/knot-resolver/ci/manager:knot-$KNOT_VERSION before_script: - - pushd manager - # make sure Poetry is in $PATH - - source $HOME/.poetry/env - # there is already a pyproject.toml with installed dependencies in the root - # it has its own virtualenv and we want to use that env in a different directory - # so let's create a new one and replace it by the already existing one - # we don't care about destroying the environment in process, because it's going to be discarded anyway - - poetry env use $(which python3.6); ourpath=$(poetry env info -p); upperpath=$( (cd ..; poetry env info -p) ); rm -rf "$ourpath"; cp -a "$upperpath" "$ourpath" - # the virtualenv we recycled might be slightly out of date. Let's quickly update it + - cd manager + - poetry env use $PYTHON_INTERPRETER - poetry install - # fix podman; see https://gitlab.nic.cz/labs/lxc-gitlab-runner#nesting-with-podman - - unset TMPDIR tags: - - lxc + - docker + - linux - amd64 -lint: +lint:py3.10: stage: check script: - poe check + variables: + PYTHON_INTERPRETER: python3.10 -test: + +.unit: &unit stage: check script: - poe test @@ -36,36 +30,27 @@ test: reports: cobertura: coverage.xml -integration: - stage: check - script: - - poe integration +unit:py3.6: + <<: *unit + variables: + PYTHON_INTERPRETER: python3.6 +unit:py3.7: + <<: *unit + variables: + PYTHON_INTERPRETER: python3.7 -package-debian-10: - when: manual - stage: packaging - image: registry.nic.cz/labs/lxc-gitlab-runner/debian-10 - before_script: - - pushd manager - script: - - bash scripts/make-package.sh - artifacts: - paths: - - knot-resolver/pkg/pkgs/ - - knot-resolver/pkg/srcpkgs/ - expire_in: 1 week +unit:py3.8: + <<: *unit + variables: + PYTHON_INTERPRETER: python3.8 -package-fedora-34: - when: manual - stage: packaging - image: registry.nic.cz/labs/lxc-gitlab-runner/fedora-34 - before_script: - - pushd manager - script: - - bash scripts/make-package.sh - artifacts: - paths: - - knot-resolver/pkg/pkgs/ - - knot-resolver/pkg/srcpkgs/ - expire_in: 1 week +unit:py3.9: + <<: *unit + variables: + PYTHON_INTERPRETER: python3.9 + +unit:py3.10: + <<: *unit + variables: + PYTHON_INTERPRETER: python3.10 diff --git a/manager/containers/ci/Containerfile b/manager/containers/ci/Containerfile deleted file mode 100644 index b17f91136..000000000 --- a/manager/containers/ci/Containerfile +++ /dev/null @@ -1,49 +0,0 @@ -FROM registry.nic.cz/labs/lxc-gitlab-runner/fedora-34:podman - -# Install Python and NodeJS -RUN dnf install -y python3.6 nodejs python3-gobject pkg-config cairo-devel gcc python3-devel gobject-introspection-devel cairo-gobject-devel which \ - && dnf clean all - -# Install Poetry -RUN python3 -m pip install -U pip \ - && curl -sSL https://install.python-poetry.org | python3 - \ - && source $HOME/.poetry/env \ - # not exactly required, but helpful - && python3 -m pip install poethepoet - -# force Poetry to use local .venv/ directory that we can cache -ENV POETRY_NO_INTERACTION=1 \ - # python: - PYTHONFAULTHANDLER=1 \ - PYTHONUNBUFFERED=1 \ - PYTHONHASHSEED=random \ - PYTHONDONTWRITEBYTECODE=1 - -RUN dnf install -y knot-resolver procps-ng - -# How does this work? -# =================== -# -# NPM dependencies are installed globally. There is no problem with that. -# -# Python dependencies are however installed into a virtualenv created by Poetry. Why you might ask? -# Because we can't change the default python interpreter without virtualenv. This creates a problem, -# that the virtualenv is created for a directory different than the one, where CI will run. -# -# Yup, that's a slight issue, that has to be fixed before running anything. This migration step is however -# quick. It's just copying files locally and there's not a ton of them. This virtualenv migration step is -# therefore done every time a CI job starts. -# -# How does it speed up CI? -# ======================== -# -# We do not have to install the dependencies every single time. They are cached in the container itself and -# we can rebuild it only when it's definition or the list of dependencies changes. - -COPY pyproject.toml poetry.lock package.json . -RUN source $HOME/.poetry/env \ - && poetry config --list \ - && poetry env use $(which python3.6) \ - && poetry env info \ - && poetry install --no-interaction --no-ansi \ - && npm install -g $(python -c "import json; print(*(k for k in json.loads(open('package.json').read())['dependencies']))")