Commit 3c2ac3f0 authored by Jakub Ru啪i膷ka's avatar Jakub Ru啪i膷ka
Browse files

CI: cross-project integration tests 馃悶

Add new CI stage "integration" which is only run when $INTEGRATION
variable is set.

Add new testing images:

* debian-10, debian-10-full (previously python-current)
* fedora-33
* suse-15,
* ubuntu-18.04, ubuntu-20.04

Add new integration jobs on supported images for first projects:

* BIRD
* Knot DNS
* Knot Resolver

Jobs on images with known issues are allowed to fail for the time being.

Fixes: #24
parent ca69772d
Pipeline #81685 passed with stage
in 5 minutes and 13 seconds
variables:
LC_ALL: C.UTF-8
stages:
- test
- integration
- deploy
image: $CI_REGISTRY/packaging/apkg/ci/python-current:apkg
image: $CI_REGISTRY/packaging/apkg/ci/debian-10-full:apkg
flake8:
.setup-git: &setup-git
- git config --global user.name CI
- git config --global user.email ci@nic
.setup-py-reqs: &setup-py-reqs
- pip3 install -r requirements.txt
.setup-py-develop: &setup-py-develop
- python3 setup.py develop --user
.setup-project: &setup-project
- *setup-git
- *setup-py-develop
.test: &test
stage: test
.integration: &integration
stage: integration
only:
variables:
- $INTEGRATION
dependencies:
- unit
# basic tests
flake8:
<<: *test
script:
- tox -e flake8
pylint:
stage: test
<<: *test
allow_failure: true
script:
- tox -e pylint
unit:
stage: test
<<: *test
script:
- tox -e unit
self:
stage: test
<<: *test
script:
# `python3 -m build` causes issues in tox in docker container
# use py.test directly
- pip3 install -r requirements.txt
- python3 setup.py develop --user
- py.test-3 tests/self
- *setup-py-reqs
- *setup-py-develop
- py.test-3 -v tests/self
# integration tests
debian-10-kresd:
image: $CI_REGISTRY/packaging/apkg/ci/debian-10:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_resolver.py
# TODO: problems with root build
allow_failure: true
ubuntu-18.04-kresd:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-18.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_resolver.py
# TODO: dpkg: error: PATH is not set
allow_failure: true
ubuntu-20.04-kresd:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-20.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_resolver.py
# TODO: problems with root build
allow_failure: true
fedora-33-kresd:
image: $CI_REGISTRY/packaging/apkg/ci/fedora-33:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_resolver.py
suse-15-kresd:
image: $CI_REGISTRY/packaging/apkg/ci/suse-15:apkg
<<: *integration
script:
- *setup-project
- py.test3 -v ci/tests/test_knot_resolver.py
debian-10-knot:
image: $CI_REGISTRY/packaging/apkg/ci/debian-10:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_dns.py
ubuntu-18.04-knot:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-18.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_dns.py
# TODO: dpkg: error: PATH is not set
allow_failure: true
ubuntu-20.04-knot:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-20.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_dns.py
fedora-33-knot:
image: $CI_REGISTRY/packaging/apkg/ci/fedora-33:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_knot_dns.py
suse-15-knot:
image: $CI_REGISTRY/packaging/apkg/ci/suse-15:apkg
<<: *integration
script:
- *setup-project
- py.test3 -v ci/tests/test_knot_dns.py
debian-10-bird:
image: $CI_REGISTRY/packaging/apkg/ci/debian-10:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_bird.py
ubuntu-18.04-bird:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-18.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_bird.py
# TODO: dpkg: error: PATH is not set
allow_failure: true
ubuntu-20.04-bird:
image: $CI_REGISTRY/packaging/apkg/ci/ubuntu-20.04:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_bird.py
fedora-33-bird:
image: $CI_REGISTRY/packaging/apkg/ci/fedora-33:apkg
<<: *integration
script:
- *setup-project
- py.test-3 -v ci/tests/test_bird.py
# TODO: old autoconf
allow_failure: true
suse-15-bird:
image: $CI_REGISTRY/packaging/apkg/ci/suse-15:apkg
<<: *integration
script:
- *setup-project
- py.test3 -v ci/tests/test_bird.py
# TODO: old autoconf
allow_failure: true
# docs published to GitLab Pages: https://packaging.pages.nic.cz/apkg/
pages:
stage: deploy
script:
......@@ -46,3 +202,6 @@ pages:
- public
only:
- master
except:
variables:
- $INTEGRATION
......@@ -5,7 +5,7 @@
use `build.sh` to build docker image, for example:
```
./build.sh python-current
./build.sh debian-10
```
## upload image into apkg CI
......@@ -19,5 +19,5 @@ $ docker login registry.nic.cz
then you can use `upload.sh` script:
```
./upload.sh python-current
./upload.sh debian-10
```
......@@ -12,13 +12,11 @@ RUN apt-get update -qqq
RUN apt-get upgrade -y -qqq
# packaging deps
RUN apt-get install -y -qqq dpkg-dev debhelper-compat dh-python python3-all python3-setuptools python3-build python3-pip python3-venv
RUN apt-get install -y -qqq dpkg-dev debhelper-compat dh-python git python3-all python3-setuptools python3-pip python3-venv
# basic deps
RUN apt-get install -y -qqq python3-jinja2 python3-distro python3-docopt python3-blessings python3-requests python3-toml python3-cached-property
# non-python deps
RUN apt-get install -y -qqq git
# deps not available in distro
RUN pip3 install htmllistparse
RUN pip3 install build htmllistparse
# testing deps
RUN apt-get install -y -qqq tox python3-pytest python3-pytest-sugar python3-pytest-cov
# linting deps
......
# SPDX-License-Identifier: GPL-3.0-or-later
FROM debian:buster
MAINTAINER Jakub Ru啪i膷ka <jakub.ruzicka@nic.cz>
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root
CMD ["/bin/bash"]
# upgrade system to latest
RUN apt-get update -qqq
RUN apt-get upgrade -y -qqq
# enable Knot DNS (required for Knot Resolver integration)
RUN apt-get -y -qqq install apt-transport-https lsb-release ca-certificates wget
RUN wget -O /etc/apt/trusted.gpg.d/knot-latest.gpg https://deb.knot-dns.cz/knot-latest/apt.gpg
RUN sh -c 'echo "deb https://deb.knot-dns.cz/knot-latest/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/knot-latest.list'
RUN apt-get update -qqq
# packaging deps
RUN apt-get install -y -qqq dpkg-dev debhelper-compat dh-python git python3-all python3-setuptools python3-pip
# basic deps
RUN apt-get install -y -qqq python3-jinja2 python3-distro python3-docopt python3-blessings python3-requests python3-toml python3-cached-property
# deps not available in distro
RUN pip3 install build htmllistparse
# testing deps
RUN apt-get install -y -qqq tox python3-pytest python3-pytest-sugar
# SPDX-License-Identifier: GPL-3.0-or-later
FROM fedora:33
MAINTAINER Jakub Ru啪i膷ka <jakub.ruzicka@nic.cz>
WORKDIR /root
CMD ["/bin/bash"]
# upgrade system to latest
RUN dnf upgrade -y
# packaging deps
RUN dnf install -y git rpm-build python3-pip
# basic deps
RUN dnf install -y python3-jinja2 python3-distro python3-docopt python3-blessings python3-requests python3-toml python3-cached-property
# deps not available in distro
RUN pip3 install htmllistparse
# testing deps
RUN dnf install -y python3-pytest python3-pytest-sugar
# SPDX-License-Identifier: GPL-3.0-or-later
FROM opensuse/leap
MAINTAINER Jakub Ru啪i膷ka <jakub.ruzicka@nic.cz>
WORKDIR /root
CMD ["/bin/bash"]
# add Knot Resolver build deps repo
RUN zypper addrepo -G -f https://download.opensuse.org/repositories/home:CZ-NIC:knot-resolver-build/openSUSE_Leap_15.2/home:CZ-NIC:knot-resolver-build.repo
# packaging deps
RUN zypper install -y git rpm-build python3-pip
# basic deps
RUN zypper install -y python3-setuptools python3-Jinja2 python3-distro python3-docopt python3-blessings python3-requests python3-toml python3-cached-property
# deps not available in distro
RUN pip3 install htmllistparse
# testing deps
RUN zypper install -y python3-pytest python3-pytest-sugar
# SPDX-License-Identifier: GPL-3.0-or-later
FROM ubuntu:bionic
MAINTAINER Jakub Ru啪i膷ka <jakub.ruzicka@nic.cz>
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="/usr/bin:${PATH}"
WORKDIR /root
CMD ["/bin/bash"]
RUN apt-get update -qqq
# upgrade system to latest
RUN apt-get upgrade -y -qqq
# install add-apt-repository
RUN apt-get install -y -qqq software-properties-common
# add Knot DNS repo (needed by Knot Resolver as build dep)
RUN add-apt-repository ppa:cz.nic-labs/knot-dns-latest
# refresh repos
RUN apt-get update -qqq
# packaging deps
RUN apt-get install -y -qqq apt-utils dpkg-dev debhelper dh-python git python3-all python3-pip
# basic deps
RUN apt-get install -y -qqq python3-jinja2 python3-docopt python3-blessings python3-toml python3-packaging
# deps not available/too old in distro
RUN pip3 install distro cached_property htmllistparse
# testing deps
RUN apt-get install -y -qqq tox python3-pytest python3-pytest-cov
# SPDX-License-Identifier: GPL-3.0-or-later
FROM ubuntu:focal
MAINTAINER Jakub Ru啪i膷ka <jakub.ruzicka@nic.cz>
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root
CMD ["/bin/bash"]
# upgrade system to latest
RUN apt-get update -qqq
RUN apt-get upgrade -y -qqq
# install add-apt-repository
RUN apt-get install -y -qqq software-properties-common
# add Knot DNS repo (needed by Knot Resolver as build dep)
RUN add-apt-repository ppa:cz.nic-labs/knot-dns-latest
# refresh repos
RUN apt-get update -qqq
# packaging deps
RUN apt-get install -y -qqq apt-utils dpkg-dev debhelper-compat dh-python git python3-all python3-setuptools python3-pip
# basic deps
RUN apt-get install -y -qqq python3-jinja2 python3-distro python3-docopt python3-blessings python3-requests python3-toml python3-cached-property
# deps not available in distro
RUN pip3 install build htmllistparse
# testing deps
RUN apt-get install -y -qqq tox python3-pytest python3-pytest-sugar
[project]
name = "knot-resolver"
make_archive_script = "scripts/make-dev-archive.sh"
[upstream]
archive_url = "https://secure.nic.cz/files/knot-resolver/knot-resolver-{{ version }}.tar.xz"
signature_url = "https://secure.nic.cz/files/knot-resolver/knot-resolver-{{ version }}.tar.xz.asc"
"""
integration tests for BIRD
"""
import glob
from pathlib import Path
import pytest
from apkg.util.run import cd
from apkg.util.git import git
from apkg.cli import apkg
BIRD_REPO_URL = 'https://gitlab.nic.cz/labs/bird'
# pylint: disable=redefined-outer-name
@pytest.fixture(scope="module")
def clone_path(tmpdir_factory):
"""
clone project repo once on module load and reuse it in individual tests
"""
tmpd = tmpdir_factory.mktemp("apkg_test_bird_git")
p = '%s/bird' % tmpd
# XXX: using bird-apkg branch for now
git('clone', '--recursive', '-b', 'bird-apkg', BIRD_REPO_URL, p)
return Path(p)
@pytest.fixture(scope="module")
def repo_path(clone_path):
"""
clone project repo and setup system for testing
"""
with cd(clone_path):
assert apkg('build-dep', '-y') == 0
# XXX: autoreconf: command not found
assert apkg('install', '-y', '-D', 'autoconf') == 0
return clone_path
def test_bird_make_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('make-archive') == 0
ar_files = glob.glob('pkg/archives/dev/bird*')
assert ar_files
def test_bird_get_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('get-archive') == 0
ar_files = glob.glob('pkg/archives/upstream/bird*')
assert ar_files
def test_bird_srcpkg_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('srcpkg') == 0
out, _ = capsys.readouterr()
for srcpkg in out.split("\n"):
assert Path(srcpkg).exists()
def test_bird_build_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('build', '-i') == 0
out, _ = capsys.readouterr()
for pkg in out.split("\n"):
assert Path(pkg).exists()
"""
integration tests for Knot DNS
"""
import glob
from pathlib import Path
import pytest
from apkg.util.run import cd
from apkg.util.git import git
from apkg.cli import apkg
KNOT_REPO_URL = 'https://gitlab.nic.cz/knot/knot-dns'
# pylint: disable=redefined-outer-name
@pytest.fixture(scope="module")
def clone_path(tmpdir_factory):
"""
clone project repo once on module load and reuse it in individual tests
"""
tmpd = tmpdir_factory.mktemp("apkg_test_knot_git")
p = '%s/knot-dns' % tmpd
# XXX: using apkg branch for now
git('clone', '--recursive', '-b', 'apkg', KNOT_REPO_URL, p)
return Path(p)
@pytest.fixture(scope="module")
def repo_path(clone_path):
"""
clone project repo and setup system for testing
"""
with cd(clone_path):
assert apkg('build-dep', '-y') == 0
return clone_path
def test_knot_make_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('make-archive') == 0
ar_files = glob.glob('pkg/archives/dev/knot*')
assert ar_files
def test_knot_get_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('get-archive') == 0
ar_files = glob.glob('pkg/archives/upstream/knot*')
assert ar_files
def test_knot_srcpkg_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('srcpkg') == 0
out, _ = capsys.readouterr()
for srcpkg in out.split("\n"):
assert Path(srcpkg).exists()
def test_knot_build_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('build', '-i') == 0
out, _ = capsys.readouterr()
for pkg in out.split("\n"):
assert Path(pkg).exists()
......@@ -4,60 +4,63 @@ integration tests for Knot Resolver
import glob
from pathlib import Path
import pytest
import apkg.util.shutil35 as shutil
from apkg.util import test
from apkg.util.run import cd
from apkg.util.git import git
from apkg.cli import apkg
KRESD_REPO_URL = 'https://gitlab.nic.cz/knot/knot-resolver'
KRESD_EXTRAS_DIR = Path(__file__).parent / 'data' / 'knot-resolver'
# pylint: disable=redefined-outer-name
@pytest.fixture(scope="module")
def kresd_git(tmpdir_factory):
def clone_path(tmpdir_factory):
"""
clone kresd repo once on module load and reuse it in individual tests
using kresd_path
don't use this directly in tests - use kresd_path instead for a fresh copy
clone project repo once on module load and reuse it in individual tests
"""
# NOTE(py35): use tmp_path_factory once py3.5 is dropped
tmpd = tmpdir_factory.mktemp("apkg_test_kresd_git")
p = '%s/knot-resolver' % tmpd
# NOTE: add --recursive to fetch submodules once needed
git('clone', KRESD_REPO_URL, p)
# XXX: using apkg branch for now
git('clone', '--recursive', '-b', 'apkg', KRESD_REPO_URL, p)
return Path(p)
@pytest.fixture(scope="function")
def kresd_path(kresd_git, tmpdir):
@pytest.fixture(scope="module")
def repo_path(clone_path):
"""
copy kresd_git into tmpdir for use in test
clone project repo and setup system for testing
"""
# NOTE(py35): use tmp_path once py3.5 is dropped
p = '%s/knot-resolver' % tmpdir
shutil.copytree(kresd_git, p, symlinks=True)
return Path(p)
with cd(clone_path):
assert apkg('build-dep', '-y') == 0
return clone_path
# pylint: disable=redefined-outer-name
def test_kresd_get_archive(kresd_path, capsys):
VERSION = '5.2.0'
repo_dir = str(kresd_path)
assert repo_dir.endswith('knot-resolver')
with cd(repo_dir):
test.inject_tree(KRESD_EXTRAS_DIR, kresd_path)
apkg('get-archive', '--version', VERSION)
ar_files = glob.glob('pkg/archives/upstream/*')
out, _ = capsys.readouterr()
# expected output files
archive_dst = "pkg/archives/upstream/knot-resolver-%s.tar.xz" % VERSION
signature_dst = "%s.asc" % archive_dst
# last stdout line should be downloaded archive
assert archive_dst in out
# make sure both archive and signature were downloaded into right path
assert archive_dst in ar_files
assert signature_dst in ar_files
def test_kresd_make_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('make-archive') == 0
ar_files = glob.glob('pkg/archives/dev/knot-resolver*')
assert ar_files
def test_kresd_get_archive(repo_path, capsys):
with cd(repo_path):
assert apkg('get-archive') == 0
ar_files = glob.glob('pkg/archives/upstream/knot-resolver*')
assert ar_files
def test_kresd_srcpkg_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('srcpkg') == 0
out, _ = capsys.readouterr()
for srcpkg in out.split("\n"):
assert Path(srcpkg).exists()
def test_kresd_build_dev(repo_path, capsys):
with cd(repo_path):
assert apkg('build', '-i') == 0
out, _ = capsys.readouterr()
for pkg in out.split("\n"):
assert Path(pkg).exists()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment