From 0b3d7809f9e0c92af057118efa915e9b9837fae2 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Tue, 5 Feb 2019 10:45:33 -0800 Subject: [PATCH] test pull requests under Python 3 as well --- .cico-pr.pipeline | 6 ++++-- docker/Dockerfile-tests | 2 +- docker/Dockerfile-tests-py3 | 38 +++++++++++++++++++++++++++++++++++++ docker/test-py3.sh | 34 +++++++++++++++++++++++++++++++++ docker/test.sh | 3 +++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 docker/Dockerfile-tests-py3 create mode 100644 docker/test-py3.sh diff --git a/.cico-pr.pipeline b/.cico-pr.pipeline index 9537e9b9..0c57f711 100644 --- a/.cico-pr.pipeline +++ b/.cico-pr.pipeline @@ -56,13 +56,15 @@ node('factory2'){ onmyduffynode "cd fm-orchestrator && git log -2" } - stage('Build Docker Image') { + stage('Build Docker Images') { onmyduffynode 'cd fm-orchestrator && docker build -t mbs/test -f docker/Dockerfile-tests .' + onmyduffynode 'cd fm-orchestrator && docker build -t mbs/test-py3 -f docker/Dockerfile-tests-py3 .' } - stage('Run Test Suite') { + stage('Run Test Suites') { timeout(20) { onmyduffynode 'docker run -v ~/fm-orchestrator:/src:Z mbs/test' + onmyduffynode 'docker run -v ~/fm-orchestrator:/src:Z mbs/test-py3' } } diff --git a/docker/Dockerfile-tests b/docker/Dockerfile-tests index 55fc2cb3..d8b1443e 100644 --- a/docker/Dockerfile-tests +++ b/docker/Dockerfile-tests @@ -44,7 +44,7 @@ RUN yum -y install \ rpm-build \ && yum clean all # We currently require a newer versions of these Python packages for the tests -RUN pip install --upgrade flask-sqlalchemy pytest flake8 tox +RUN pip install --upgrade flask-sqlalchemy pytest flake8 tox pip VOLUME /src WORKDIR /src CMD ["bash", "docker/test.sh"] diff --git a/docker/Dockerfile-tests-py3 b/docker/Dockerfile-tests-py3 new file mode 100644 index 00000000..ea86b62e --- /dev/null +++ b/docker/Dockerfile-tests-py3 @@ -0,0 +1,38 @@ +FROM fedora:29 + +WORKDIR /build +RUN dnf -y install \ + --nogpgcheck \ + --setopt=deltarpm=0 \ + --setopt=install_weak_deps=false \ + --setopt=tsflags=nodocs \ + git-core \ + createrepo_c \ + python3-fedmsg \ + python3-kobo-rpmlib \ + python3-rpm \ + libmodulemd \ + python3-gobject \ + python3-dogpile-cache \ + python3-flask \ + python3-flask-migrate \ + python3-flask-sqlalchemy \ + python3-koji \ + python3-ldap3 \ + python3-munch \ + python3-pip \ + python3-requests \ + python3-six \ + python3-solv \ + python3-sqlalchemy \ + python3-pungi \ + # Test-only dependencies + python3-pytest \ + python3-flake8 \ + python3-mock \ + python3-tox \ + rpm-build \ + && dnf clean all +VOLUME /src +WORKDIR /src +CMD ["bash", "docker/test-py3.sh"] diff --git a/docker/test-py3.sh b/docker/test-py3.sh new file mode 100644 index 00000000..bfb07c6a --- /dev/null +++ b/docker/test-py3.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Remove requirements not necessary for Python 3.7. +# Also, prevent koji from being re-installed from PyPi. +cp requirements.txt requirements.txt.orig.py3 +sed -i \ + -e '/enum34/d' \ + -e '/funcsigs/d' \ + -e '/futures/d' \ + -e '/koji/d' \ + requirements.txt + +# Run everything with Python 3 +cp tox.ini tox.ini.orig.py3 +sed -i \ + -e 's/py.test/py.test-3/g' \ + -e '/basepython/d' \ + tox.ini + +# Delete any leftover compiled Python files +for dir in module_build_service tests; do + find ${dir} -type f \( -name '*.pyc' -or -name '*.pyc' \) -exec rm -f {} \; +done + +# Since tox seems to ignore `usedevelop` when we have `sitepackages` on, we have to run it manually +python3 setup.py develop --no-deps +/usr/bin/tox -e flake8,py3 +rv=$? + +# After running tox, we can revert back to the original files +rm -f requirements.txt tox.ini +mv requirements.txt.orig.py3 requirements.txt +mv tox.ini.orig.py3 tox.ini +exit $rv diff --git a/docker/test.sh b/docker/test.sh index f77232b9..377a0ee8 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -8,6 +8,9 @@ sed -i '/koji/d' requirements.txt for dir in module_build_service tests; do find ${dir} -type f \( -name '*.pyc' -or -name '*.pyc' \) -exec rm -f {} \; done +# The python-virtualenv package bundles a very old version of pip, +# which is incompatible with modern virtualenv. +rm -f /usr/lib/python2.7/site-packages/virtualenv_support/pip-9* # Since tox seems to ignore `usedevelop` when we have `sitepackages` on, we have to run it manually python setup.py develop --no-deps /usr/bin/tox -e flake8,py27