CI: Make most of the tests work on EPEL 9

Resolves: rhbz#2065590
This commit is contained in:
Miro Hrončok 2022-03-17 16:16:06 +01:00
parent 3e4bfeffd8
commit 797cac8d85
7 changed files with 54 additions and 7 deletions

View File

@ -24,7 +24,7 @@ Building this tests that lang files are marked with %%lang in filelist.
%generate_buildrequires
%pyproject_buildrequires
%pyproject_buildrequires -R
%build

View File

@ -28,6 +28,8 @@ Summary: %{summary}
%prep
%autosetup -p1 -n distroinfo-%{version}
# we don't need pytest-runner
sed -Ei "s/(, )?'pytest-runner'//" setup.py
%generate_buildrequires

View File

@ -10,6 +10,14 @@ BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
# no flask, itsdangerous, raven, werkzeug packaged for EPEL 9 yet
# cannot run tests on EPEL and also cannot BuildRequire runtime deps
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This package buildrequires a package with extra: raven[flask].
@ -34,7 +42,7 @@ sed -i /Content-Length/d test_httpbin.py
sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1))/def no\1/' test_httpbin.py
%generate_buildrequires
%pyproject_buildrequires -t
%pyproject_buildrequires %{?with_tests:-t}%{?!with_tests:-R}
%build
@ -46,6 +54,7 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1
%pyproject_save_files httpbin
%if %{with tests}
%check
%tox
@ -53,6 +62,7 @@ sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1
# The runtime dependencies contain raven[flask], we assert we got them.
# The %%tox above also dies without it, but this makes it more explicit
%{python3} -c 'import blinker, flask' # transitive deps
%endif
%files -n python3-httpbin -f %{pyproject_files}

View File

@ -30,6 +30,10 @@ Summary: %{summary}
# we sed it out to save ourselves a dependency, but that is not strictly required
sed -i -e 's., "setuptools-git"..g' pyproject.toml
# the tests don't actually need mock, they use unittest.mock
# https://github.com/os-autoinst/openQA-python-client/pull/21
sed -i '/mock/d' tests.requires
%generate_buildrequires
%pyproject_buildrequires -t

View File

@ -11,6 +11,13 @@ BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
# no xmlschema packaged for EPEL 9 yet, cannot run tests on EPEL
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This is a pure Python package with executables. It has a test suite in tox.ini
and test dependencies specified via the [test] extra.
@ -28,10 +35,13 @@ Summary: %{summary}
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
# remove optional test dependencies we don't like to pull in
sed -E -i '/mock|nose/d' setup.cfg
%generate_buildrequires
%pyproject_buildrequires -x testing -t
%pyproject_buildrequires %{?with_tests:-x testing -t}
%build
%pyproject_wheel
@ -43,9 +53,13 @@ Summary: %{summary}
%check
%if %{with tests}
# Only run one test (which uses a test-only dependency, hypothesis)
# See how to pass options trough the macro to tox, trough tox to pytest
%tox -- -- -k metafunc
%else
%pyproject_check_import
%endif
%files -n python3-%{pypi_name} -f %{pyproject_files}

View File

@ -13,6 +13,13 @@ BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: gcc
# too many missing tests deps in EPEL 9
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This package tests 2 things:
@ -44,7 +51,7 @@ sed -i pytest.ini -e 's/ --flake8//' \
%generate_buildrequires
%pyproject_buildrequires -r -x testing
%pyproject_buildrequires -r %{?with_tests:-x testing}
%build
@ -64,8 +71,12 @@ sed -i '/tests/d' %{pyproject_files}
# https://github.com/pypa/setuptools/discussions/2607
rm pyproject.toml
%if %{with tests}
# We only run a subset of tests to speed things up and be less fragile
PYTHONPATH=$(pwd) %pytest --ignore=pavement.py -k "sdist"
%else
%pyproject_check_import
%endif
# Internal check that license file was recognized correctly
grep '^%%license' %{pyproject_files} > tested.license

View File

@ -11,7 +11,13 @@ BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: /usr/bin/git
BuildRequires: /usr/bin/hg
# flake8 is still missing tests deps in EPEL 9
%if 0%{?fedora}
%bcond_without flake8
%else
%bcond_with flake8
%endif
%description
Here we test that %%pyproject_extras_subpkg works and generates
@ -37,7 +43,7 @@ Summary: %{summary}
%generate_buildrequires
# Note that you should not run flake8-like linters in Fedora spec files,
# here we do it solely to check the *ability* to use multiple toxenvs.
%pyproject_buildrequires -e %{default_toxenv}-test -e flake8
%pyproject_buildrequires -e %{default_toxenv}-test %{?with_flake8:-e flake8}
%build
@ -56,7 +62,7 @@ Summary: %{summary}
# Internal check for our macros: Assert both toxenvs were executed.
grep -F 'py%{python3_version_nodots}-test: commands succeeded' toxlog
grep -F 'flake8: commands succeeded' toxlog
%{?!with_flake8:! }grep -F 'flake8: commands succeeded' toxlog
# Internal check for our macros
# making sure that %%{_pyproject_ghost_distinfo} has the right content