diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/ansible-packaging.spec b/ansible-packaging.spec index 42f6415..f68204e 100644 --- a/ansible-packaging.spec +++ b/ansible-packaging.spec @@ -1,6 +1,8 @@ +%global _docdir_fmt ansible-packaging + Name: ansible-packaging Version: 1 -Release: 9.1%{?dist} +Release: 12%{?dist} Summary: RPM packaging macros and generators for Ansible collections License: GPL-3.0-or-later @@ -48,7 +50,7 @@ Requires: /usr/bin/ansible-test Requires: %{py3_dist pytest} Requires: %{py3_dist pytest-mock} Requires: %{py3_dist pytest-xdist} -Requires: %{py3_dist pytest-forked} +Requires: (%{py3_dist pytest-forked} if ansible-core < 2.16~~) Requires: %{py3_dist pyyaml} # mock is included in the list upstream, but is deprecated in Fedora. # Maintainers should work with upstream to add compat code to support @@ -114,23 +116,24 @@ errors rpm_eval -E '%%ansible_collection_url' echo echo echo "Ensure macro works when both arguments are passed and no control macros are set" -[[ $(rpm_eval -E '%%ansible_collection_url community general') == \ - "https://galaxy.ansible.com/community/general" ]] +[ "$(rpm_eval -E '%%ansible_collection_url community general')" = \ + "https://galaxy.ansible.com/ui/repo/published/community/general" ] echo echo "Ensure macro works with the control macros" -[[ $(rpm_eval -D 'collection_namespace ansible' -D 'collection_name posix' \ - -E '%%ansible_collection_url') == "https://galaxy.ansible.com/ansible/posix" ]] +[ "$(rpm_eval -D 'collection_namespace ansible' -D 'collection_name posix' \ + -E '%%ansible_collection_url')" = \ + "https://galaxy.ansible.com/ui/repo/published/ansible/posix" ] echo echo "Ensure macro prefers the collection namespace and name passed as an argument over the control macros" -[[ $(rpm_eval -D 'collection_namespace ansible' -D 'collection_name posix' \ - -E '%%ansible_collection_url community general') == "https://galaxy.ansible.com/community/general" ]] +[ "$(rpm_eval -D 'collection_namespace ansible' -D 'collection_name posix' \ + -E '%%ansible_collection_url community general')" = \ + "https://galaxy.ansible.com/ui/repo/published/community/general" ] %files -%license COPYING %{_fileattrsdir}/ansible.attr %{_rpmmacrodir}/macros.ansible %{_rpmconfigdir}/ansible-generator @@ -138,6 +141,7 @@ echo "Ensure macro prefers the collection namespace and name passed as an argume %files -n ansible-srpm-macros +%license COPYING %{_rpmmacrodir}/macros.ansible-srpm # ansible-core in RHEL 8.6 is built against python38. In c8s and the next RHEL @@ -149,6 +153,17 @@ echo "Ensure macro prefers the collection namespace and name passed as an argume %changelog +* Tue Dec 05 2023 Maxwell G - 1-12 +- %%ansible_collection_url: handle new URL scheme + +* Wed Jul 19 2023 Fedora Release Engineering - 1-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Thu May 11 2023 Maxwell G - 1-10 +- %%ansible_collection_install - disable spurious collections path warnings +- ansible-packaging-tests - don't depend on pytest-forked with ansible-core 2.16 +- ansible-srpm-macros - include license file in the package + * Wed Jan 18 2023 Fedora Release Engineering - 1-9.1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild diff --git a/ansible_collection.py b/ansible_collection.py index 70093be..80c4b33 100755 --- a/ansible_collection.py +++ b/ansible_collection.py @@ -19,6 +19,7 @@ the provided arguments. """ import argparse +import os import shutil import subprocess import sys @@ -96,7 +97,12 @@ class AnsibleCollection: # Without this, the print statements are shown after the command # output when building in mock. sys.stdout.flush() - subprocess.run(args, cwd=temppath, check=True) + subprocess.run( + args, + cwd=temppath, + check=True, + env={**os.environ, "ANSIBLE_GALAXY_COLLECTIONS_PATH_WARNING": "0"}, + ) def parseargs() -> argparse.Namespace: diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..5480e33 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,10 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: + - bodhi_update_push_testing + - bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +... diff --git a/macros.ansible-srpm b/macros.ansible-srpm index 0adacd7..fdf2ce5 100644 --- a/macros.ansible-srpm +++ b/macros.ansible-srpm @@ -8,6 +8,9 @@ # either or approach. Both arguments must be passed OR both control macros must # be defined. + +%__ansible_galaxy_collection_url https://galaxy.ansible.com/ui/repo/published + %ansible_collection_url() %{lua: local namespace_name = nil if rpm.expand("%collection_namespace") ~= "%collection_namespace" @@ -21,5 +24,6 @@ rpm.expand("%{error:%%ansible_collection_url: You must pass the collection " .. "namespace as the first arg and the collection name as the second}") end - print("https://galaxy.ansible.com/" .. namespace_name) + url = rpm.expand("%__ansible_galaxy_collection_url") + print(url .. "/" .. namespace_name) } diff --git a/tests/rebuild.fmf b/tests/rebuild.fmf new file mode 100644 index 0000000..a1414be --- /dev/null +++ b/tests/rebuild.fmf @@ -0,0 +1,16 @@ +summary: Rebuild dependents to ensure that builds pass +discover: + - name: Rebuild collection packages + how: shell + tests: + - name: Rebuild ansible-collection-community-docker + test: tests/rebuild.sh ansible-collection-community-docker + require: + - ansible-core + - ansible-packaging + - ansible-srpm-macros + - fedpkg + - rpm-build + - sudo +execute: + how: tmt diff --git a/tests/rebuild.sh b/tests/rebuild.sh new file mode 100755 index 0000000..fbbb8b8 --- /dev/null +++ b/tests/rebuild.sh @@ -0,0 +1,27 @@ +#!/usr/bin/bash -x +set -euo pipefail + +package="${1}" + +cat <<'EOF' > ~/.rpmmacros +%_topdir %(echo $HOME)/rpmbuild +%_sourcedir %(pwd) +%_srcrpmdir %(pwd) +%_rpmdir %(pwd)/rpms +EOF + +mkdir -p clones +cd clones +fedpkg clone -a "${package}" +cd "${package}" +fedpkg srpm +sudo dnf builddep -y *.src.rpm +rc=0 +rpmbuild --rebuild *.src.rpm | tee build.log || rc=$? + +# move the results to the artifacts directory, so we can examine them +artifacts="${TEST_ARTIFACTS:-/tmp/artifacts}" +mkdir -p "${artifacts}" +mv -v *.rpm rpms/*/* build.log "${artifacts}/" || : + +exit "${rc}"