From 4a2493e2cbe7afb313e4396752ea0d009cce756f Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Apr 20 2021 19:48:27 +0000 Subject: Jenkins unittests run in docker container Prepared dockerfiles for creating a testing environment in containers. Two containers are prepared. The first for normal Python3 and the second one runs in CentOS 7. A tox configuration is customized for supported versions of Python. JIRA: RHELCMP-4578 Signed-off-by: Ondrej Nosek --- diff --git a/jenkins_test.dockerfile b/jenkins_test.dockerfile new file mode 100644 index 0000000..3a0dfb1 --- /dev/null +++ b/jenkins_test.dockerfile @@ -0,0 +1,31 @@ +FROM fedora:33 +LABEL \ + name="rpkg test" \ + description="Run tests using tox with Python 3" \ + vendor="rpkg developers" \ + license="MIT" + +RUN dnf -y update && dnf -y install \ + python3-devel \ + python3-openidc-client \ + python3-setuptools \ + rpmlint \ + rpm-build +# development packages that are not part of packages' specfile \ +RUN dnf -y install \ + python3-tox \ + python3-pip \ + rpm-devel \ + gcc \ + libcurl-devel \ + krb5-devel \ + openssl-devel \ + make \ + git +RUN dnf clean all + +WORKDIR /src + +COPY . . + +CMD ["tox", "-e", "py36,py39,flake8"] diff --git a/jenkins_test_py2.dockerfile b/jenkins_test_py2.dockerfile new file mode 100644 index 0000000..803ac88 --- /dev/null +++ b/jenkins_test_py2.dockerfile @@ -0,0 +1,37 @@ +FROM centos:7 +LABEL \ + name="rpkg test for Python 2" \ + description="Run tests using tox with Python 2" \ + vendor="rpkg developers" \ + license="MIT" + +RUN yum -y update && yum -y install \ + python2-devel \ + python2-openidc-client \ + python2-setuptools \ + rpmlint \ + rpm-build +# development packages that are not part of packages' specfile \ +RUN yum -y install \ + rpm-devel \ + gcc \ + libcurl-devel \ + krb5-devel \ + openssl-devel \ + make \ + git +# Python 3 packages needed for building some python dependencies +# while Python 2 are not available or outdated +RUN yum -y install \ + python3-pip \ + python3-devel +RUN yum clean all + +# python-tox in yum repo is too old, let's install latest version +RUN pip3 install tox + +WORKDIR /src + +COPY . . + +CMD ["tox", "-e", "py27,flake8python2"] diff --git a/tox.ini b/tox.ini index f3be666..f1acbba 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py36,py37,flake8,doc +envlist = py27,py36,py39,flake8,doc [testenv] skip_install = True @@ -7,8 +7,8 @@ parallel_show_output = True basepython= py27: {env:TOXPYTHON:python2.7} py36: {env:TOXPYTHON:python3.6} - py37: {env:TOXPYTHON:python3.7} - flake8: {env:TOXPYTHON:python3.7} + py39: {env:TOXPYTHON:python3.9} + flake8: {env:TOXPYTHON:python3.6} flake8python2: {env:TOXPYTHON:python2.7} deps =