]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
ci: execute manager unit tests
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 19 Jan 2022 16:06:46 +0000 (17:06 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:53 +0000 (16:17 +0200)
.gitlab-ci.yml
ci/images/manager/Dockerfile [new file with mode: 0644]
manager/.gitlab-ci.yml
manager/containers/ci/Containerfile [deleted file]

index 0eee4c199fa9d9c8e347bb2ccdc3c6fe3ef22d76..de5fe27f1c4bef4b938a6ad76798b6346fed64c8 100644 (file)
@@ -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 (file)
index 0000000..807923d
--- /dev/null
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+FROM fedora:35
+MAINTAINER Knot Resolver <knot-resolver@labs.nic.cz>
+
+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
index 7c5c40defab3d4f4443195e4585a6b40b6ce0738..f8b2d0f0d2220d4e7480ecff2d822c15eb5ee357 100644 (file)
@@ -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 (file)
index b17f911..0000000
+++ /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']))")