mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
tox testing support for client wheel packages
Add tox infrastructure to test client wheel packages workflow: * build client packages * install client packages * ipa-run-tests --ipaclient-unittests under Python 2 and 3 * pylint of client packages under Python 2 and 3 * placeholder packages work as expected Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
9ac56e47d7
commit
3a5b3be8b9
2
.gitignore
vendored
2
.gitignore
vendored
@@ -61,6 +61,8 @@ freeipa2-dev-doc
|
||||
# Root directory
|
||||
/freeipa.spec
|
||||
/dist/
|
||||
/.tox/
|
||||
/.cache/
|
||||
/*/dist/
|
||||
/RELEASE
|
||||
/rpmbuild/
|
||||
|
94
.tox-install.sh
Executable file
94
.tox-install.sh
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
FLAVOR="$1"
|
||||
ENVPYTHON="$2"
|
||||
ENVSITEPACKAGESDIR="$3"
|
||||
# 3...end are package requirements
|
||||
shift 3
|
||||
|
||||
TOXINIDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# sanity checks
|
||||
if [ ! -x "${ENVPYTHON}" ]; then
|
||||
echo "${ENVPYTHON}: no such executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${ENVSITEPACKAGESDIR}" ]; then
|
||||
echo "${ENVSITEPACKAGESDIR}: no such directory"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "${TOXINIDIR}/tox.ini" ]; then
|
||||
echo "${TOXINIDIR}: no such directory"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# https://pip.pypa.io/en/stable/user_guide/#environment-variables
|
||||
export PIP_CACHE_DIR="${TOXINIDIR}/.tox/cache"
|
||||
mkdir -p "${PIP_CACHE_DIR}"
|
||||
|
||||
DISTBUNDLE="${TOXINIDIR}/dist/bundle"
|
||||
mkdir -p "${DISTBUNDLE}"
|
||||
|
||||
DISTPYPI="${TOXINIDIR}/dist/pypi"
|
||||
mkdir -p "${DISTPYPI}"
|
||||
|
||||
# create configure
|
||||
pushd "${TOXINIDIR}"
|
||||
if [ ! -f "configure" ]; then
|
||||
autoreconf -i -f
|
||||
fi
|
||||
# (re)create Makefile
|
||||
./configure --disable-server
|
||||
popd
|
||||
|
||||
case $FLAVOR in
|
||||
wheel_bundle)
|
||||
# copy pylint plugin
|
||||
cp "${TOXINIDIR}/pylint_plugins.py" "${ENVSITEPACKAGESDIR}"
|
||||
|
||||
# build packages and bundles
|
||||
make -C "${TOXINIDIR}" \
|
||||
wheel_bundle \
|
||||
PYTHON="${ENVPYTHON}" \
|
||||
IPA_EXTRA_WHEELS="$*"
|
||||
|
||||
# chdir to prevent local .egg-info from messing up pip
|
||||
pushd "${ENVSITEPACKAGESDIR}"
|
||||
|
||||
# Install packages with dist/bundle/ as extra source for wheels while ignoring
|
||||
# upstream Python Package Index.
|
||||
$ENVPYTHON -m pip install \
|
||||
--no-index \
|
||||
--disable-pip-version-check \
|
||||
--constraint "${TOXINIDIR}/.wheelconstraints" \
|
||||
--find-links "${DISTBUNDLE}" \
|
||||
$@
|
||||
|
||||
popd
|
||||
;;
|
||||
pypi_packages)
|
||||
# build packages and bundles
|
||||
make -C "${TOXINIDIR}" \
|
||||
pypi_packages \
|
||||
PYTHON="${ENVPYTHON}"
|
||||
|
||||
# chdir to prevent local .egg-info from messing up pip
|
||||
pushd "${ENVSITEPACKAGESDIR}"
|
||||
|
||||
# Install packages from dist/pypi
|
||||
$ENVPYTHON -m pip install \
|
||||
--disable-pip-version-check \
|
||||
--constraint "${TOXINIDIR}/.wheelconstraints" \
|
||||
--find-links "${DISTPYPI}" \
|
||||
$@
|
||||
|
||||
popd
|
||||
;;
|
||||
*)
|
||||
echo "Unknown install flavor $FLAVOR"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@@ -57,6 +57,7 @@ EXTRA_DIST = .mailmap \
|
||||
clean-local:
|
||||
rm -rf "$(RPMBUILD)"
|
||||
rm -rf "$(top_builddir)/dist"
|
||||
rm -rf "$(top_builddir)/.tox"
|
||||
rm -rf "$(top_srcdir)/__pycache__"
|
||||
rm -f "$(top_builddir)"/$(PACKAGE)-*.tar.gz
|
||||
|
||||
@@ -212,6 +213,7 @@ pylint: $(top_builddir)/ipapython/version.py ipasetup.py
|
||||
-path './freeipa-*' -prune -o \
|
||||
-path './dist' -prune -o \
|
||||
-path './pypi' -prune -o \
|
||||
-path './.tox' -prune -o \
|
||||
-name '.*' -o \
|
||||
-name '*.in' -o \
|
||||
-name '*~' -o \
|
||||
@@ -299,12 +301,12 @@ pypi_packages: $(WHEELPYPIDIR) .wheelconstraints
|
||||
rm -f $(WHEELPYPIDIR)/*
|
||||
for dir in $(IPACLIENT_SUBDIRS); do \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
IPA_OMIT_INSTALL=1 WHEELDISTDIR=$(abspath $(WHEELPYPIDIR)) \
|
||||
IPA_OMIT_INSTALL=1 WHEELDISTDIR="$(abspath $(WHEELPYPIDIR))" \
|
||||
-C $${dir} bdist_wheel || exit 1; \
|
||||
done
|
||||
for dir in $(IPA_PLACEHOLDERS); do \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
IPA_OMIT_INSTALL=1 WHEELDISTDIR=$(abspath $(WHEELPYPIDIR)) \
|
||||
IPA_OMIT_INSTALL=1 WHEELDISTDIR="$(abspath $(WHEELPYPIDIR))" \
|
||||
-C $(top_srcdir)/pypi/$${dir} bdist_wheel || exit 1; \
|
||||
done
|
||||
@echo -e "\n\nTo upload packages to PyPI, run:\n"
|
||||
|
@@ -276,6 +276,7 @@ AC_CONFIG_COMMANDS([po/POTFILES.in],
|
||||
-path "./${PACKAGE}-*" -prune -o dnl dist directories
|
||||
-path '*/build' -prune -o dnl Python builds
|
||||
-path '*/dist' -prune -o dnl Python dists
|
||||
-path './.tox' -prune -o dnl Python tox test
|
||||
-path './conf*' -prune -o dnl generated by configure
|
||||
-name '*.py' -print -o dnl
|
||||
-name '*.c' -print -o dnl
|
||||
|
@@ -144,9 +144,12 @@ BuildRequires: python-cffi
|
||||
#
|
||||
%if 0%{?with_wheels}
|
||||
BuildRequires: dbus-glib-devel
|
||||
BuildRequires: libffi-devel
|
||||
BuildRequires: python-tox
|
||||
BuildRequires: python2-twine
|
||||
BuildRequires: python2-wheel
|
||||
%if 0%{?with_python3}
|
||||
BuildRequires: python3-tox
|
||||
BuildRequires: python3-twine
|
||||
BuildRequires: python3-wheel
|
||||
%endif
|
||||
|
@@ -52,7 +52,9 @@ NO_RECURSE_DIRS = [
|
||||
'ipaserver/build',
|
||||
'ipatests/build',
|
||||
# install/share/wsgi.py
|
||||
'install/share'
|
||||
'install/share',
|
||||
# integration plugin imports from ipaplatform
|
||||
'ipatests/pytest_plugins',
|
||||
]
|
||||
|
||||
|
||||
|
47
pypi/test_placeholder.py
Normal file
47
pypi/test_placeholder.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
|
||||
|
||||
import importlib
|
||||
|
||||
import pkg_resources
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize("modname", [
|
||||
# placeholder packages raise ImportError
|
||||
'ipaplatform',
|
||||
'ipaserver',
|
||||
'ipatests',
|
||||
# PyPI packages do not have install subpackage
|
||||
'ipaclient.install',
|
||||
'ipalib.install',
|
||||
'ipapython.install',
|
||||
])
|
||||
def test_fail_import(modname):
|
||||
try:
|
||||
importlib.import_module(modname)
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
pytest.fail("'import {}' does not fail".format(modname))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("modname", [
|
||||
'ipaclient',
|
||||
'ipalib',
|
||||
'ipapython',
|
||||
])
|
||||
def test_import(modname):
|
||||
importlib.import_module(modname)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pkgname", [
|
||||
'ipaclient',
|
||||
'ipalib',
|
||||
'ipaplatform',
|
||||
'ipapython',
|
||||
'ipaserver',
|
||||
'ipatests',
|
||||
])
|
||||
def test_package_installed(pkgname):
|
||||
pkg_resources.require(pkgname)
|
55
tox.ini
Normal file
55
tox.ini
Normal file
@@ -0,0 +1,55 @@
|
||||
[tox]
|
||||
minversion=2.3.1
|
||||
envlist=py27,py35,py36,pylint2,pylint3,pypi
|
||||
skip_missing_interpreters=true
|
||||
skipsdist=true
|
||||
|
||||
[testenv]
|
||||
# always re-create virtual env. A special install helper is used to configure,
|
||||
# build and install packages.
|
||||
recreate=True
|
||||
install_command={toxinidir}/.tox-install.sh wheel_bundle {envpython} {envsitepackagesdir} {packages}
|
||||
changedir={envdir}
|
||||
setenv=
|
||||
HOME={envtmpdir}
|
||||
deps=
|
||||
ipaclient
|
||||
ipatests
|
||||
commands=
|
||||
{envbindir}/ipa --help
|
||||
{envpython} -bb {envbindir}/ipa-run-tests --ipaclient-unittests
|
||||
|
||||
[testenv:pylint2]
|
||||
basepython=python2.7
|
||||
deps=
|
||||
ipaclient
|
||||
ipapython[certmonger]
|
||||
pylint
|
||||
commands=
|
||||
{envpython} -m pylint \
|
||||
--rcfile={toxinidir}/pylintrc \
|
||||
--load-plugins pylint_plugins \
|
||||
{envsitepackagesdir}/ipaclient \
|
||||
{envsitepackagesdir}/ipalib \
|
||||
{envsitepackagesdir}/ipapython
|
||||
|
||||
[testenv:pylint3]
|
||||
basepython=python3
|
||||
deps={[testenv:pylint2]deps}
|
||||
commands={[testenv:pylint2]commands}
|
||||
|
||||
[testenv:pypi]
|
||||
recreate=True
|
||||
install_command={toxinidir}/.tox-install.sh pypi_packages {envpython} {envsitepackagesdir} {packages}
|
||||
changedir={envdir}
|
||||
setenv=
|
||||
HOME={envtmpdir}
|
||||
deps=
|
||||
pytest
|
||||
ipaclient
|
||||
# placeholder
|
||||
ipaplatform
|
||||
ipaserver
|
||||
ipatests
|
||||
commands=
|
||||
{envpython} -m pytest {toxinidir}/pypi/test_placeholder.py
|
Reference in New Issue
Block a user