Commit 74d6f894 authored by Jakub Ru啪i膷ka's avatar Jakub Ru啪i膷ka
Browse files

Merge branch 'kresd' into 'master'

CI: cross-project integration tests 馃悶

Closes #24

See merge request !47
parents e073b173 3c2ac3f0
Pipeline #81706 passed with stages
in 5 minutes and 25 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
integration:
stage: test
script:
- tox -e integration
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:
......@@ -51,3 +202,6 @@ pages:
- public
only:
- master
except:
variables:
- $INTEGRATION
Docker Build
------------
* python-current (for python-$VER replace "current" with "$VER")
```
$ docker build --no-cache -t registry.nic.cz/packaging/apkg/ci/python-current:apkg python-current
$ docker login registry.nic.cz
$ docker push registry.nic.cz/packaging/apkg/ci/python-current:apkg
```
# apkg CI images
## build image
use `build.sh` to build docker image, for example:
```
./build.sh debian-10
```
## upload image into apkg CI
you need to login first:
```
$ docker login registry.nic.cz
```
then you can use `upload.sh` script:
```
./upload.sh debian-10
```
#!/bin/bash
# build specified docker image
IMAGE=$1
if [ -z "$IMAGE" ]; then
echo "usage: $0 IMAGE"
exit 1
fi
set -ex
docker build --no-cache -t "registry.nic.cz/packaging/apkg/ci/$IMAGE:apkg" "$IMAGE"
......@@ -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
#!/bin/bash
# upload docker image into apkg registry
IMAGE=$1
if [ -z "$IMAGE" ]; then
echo "usage: $0 IMAGE"
exit 1
fi
set -ex
docker push "registry.nic.cz/packaging/apkg/ci/$IMAGE:apkg"
"""
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()
"""
integration tests for Knot Resolver
"""
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
KRESD_REPO_URL = 'https://gitlab.nic.cz/knot/knot-resolver'
# 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_kresd_git")
p = '%s/knot-resolver' % tmpd
# XXX: using apkg branch for now
git('clone', '--recursive', '-b', 'apkg', KRESD_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_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()