Skip to content

Commit

Permalink
Make tox -e rpm testing easier to use
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 29, 2023
1 parent d736af6 commit 16ccc00
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 2 deletions.
58 changes: 58 additions & 0 deletions dist/python-ansible-compat.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# spell-checker:ignore bcond pkgversion buildrequires autosetup PYTHONPATH noarch buildroot bindir sitelib numprocesses clib
# All tests require Internet access
# to test in mock use: --enable-network --with check
# to test in a privileged environment use:
# --with check --with privileged_tests
%global debug_package %{nil}
%bcond_with check
%bcond_with privileged_tests

Name: ansible-compat
Version: VERSION_PLACEHOLDER
Release: 1%{?dist}
Summary: Ansible Compat

License: GPL-3.0-or-later AND MIT
URL: https://github.com/ansible/ansible-compat
Source0: %{pypi_source}

BuildArch: noarch

BuildRequires: python%{python3_pkgversion}-devel
%if %{with check}
# These are required for tests:
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pytest-xdist
BuildRequires: python%{python3_pkgversion}-libselinux
BuildRequires: python%{python3_pkgversion}-jsonschema
BuildRequires: python%{python3_pkgversion}-subprocess-tee
BuildRequires: git-core
%endif
Requires: git-core


%description
A python package containing functions that help interacting with various versions of Ansible.

%prep
%autosetup


%build
%pyproject_wheel


%install
%pyproject_install


%if %{with check}
%check
pytest
%endif


%files -f %{pyproject_files}
%doc docs/ README.md

%changelog
21 changes: 21 additions & 0 deletions tools/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -euxo pipefail

# Clean leftovers from previous builds
rm -R dist/*/ dist/*-record dist/*-distinfo dist/*.tar.gz 2> /dev/null || true

if [ -f /etc/redhat-release ]; then
sudo dnf install -y libcurl-devel krb5-devel python3-jsonschema python3-devel rpm-build
# Only Fedora has packit as rpm available, on others we install it using pip
if grep Fedora /etc/redhat-release; then
sudo dnf install -y packit python3-setuptools_scm+toml python3-subprocess-tee
else
type packit 2>/dev/null || sudo pip3 install packitos
fi
else
echo 'FATAL: This can be run only on rpm based operating systems at this moment.' >&2
exit 1
fi

packit build locally

8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ envlist =
docs
# matrix assumed current (implicit) is 2.13:
py{39,310,311}{,-devel,-ansible212,-ansible213,-ansible214,-ansible215}
rpm
isolated_build = true
skip_missing_interpreters = True
requires =
Expand Down Expand Up @@ -144,9 +145,12 @@ deps =
[testenv:rpm]
description = Use packit to build RPM (requires RPM based Linux distro)
deps =
packitos
setuptools-scm
commands =
packit build in-mock
./tools/build-rpm.sh
allowlist_externals =
./tools/build-rpm.sh
sh

[testenv:docs]
description = Build docs
Expand Down

0 comments on commit 16ccc00

Please sign in to comment.