From 47d5722ba0f8f47265e619f4ba627ad68683d516 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 19 Aug 2022 14:46:01 -0500 Subject: [PATCH 1/5] Update to 2.7.1. --- .gitignore | 1 + ansible-collection-community-docker.spec | 5 ++++- sources | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a151fe8..9f57afa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /community.docker-2.5.0.tar.gz /community.docker-2.5.1.tar.gz /community.docker-2.6.0.tar.gz +/community.docker-2.7.1.tar.gz diff --git a/ansible-collection-community-docker.spec b/ansible-collection-community-docker.spec index cc0edbc..b0d7408 100644 --- a/ansible-collection-community-docker.spec +++ b/ansible-collection-community-docker.spec @@ -11,7 +11,7 @@ Name: ansible-collection-%{collection_namespace}-%{collection_name} -Version: 2.6.0 +Version: 2.7.1 %global tag %{version} %forgemeta Release: 1%{?dist} @@ -84,6 +84,9 @@ popd %changelog +* Fri Aug 19 2022 Maxwell G - 2.7.1-1 +- Update to 2.7.1. + * Wed May 25 2022 Maxwell G - 2.6.0-1 - Update to 2.6.0. Fixes rhbz#2089991. diff --git a/sources b/sources index 174e012..81b4061 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (community.docker-2.6.0.tar.gz) = 8cd8bb735576324c57bc0a897e3ae080d08762b74f9f33072a5b95b8e07adc0ee50c5f4226cb620ebd6ad7a121b3a88b26f61b65bd4f2ad254b165acf1b9c2e1 +SHA512 (community.docker-2.7.1.tar.gz) = 4b0b3bd123729d35fbb70c7ddc90eb67154e17e53762be9a9ccc4cf63081b4a4f4e73a050a881d56bd13cd119e14785259777e2caf64a89243403eec8e99d8ea From 79c9b8a25f82657ad73618be013d812076f8e676 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 19 Aug 2022 15:10:33 -0500 Subject: [PATCH 2/5] Use new macros for unit testing --- ansible-collection-community-docker.spec | 35 +++++++----------------- build_ignore-unnecessary-files.patch | 3 +- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ansible-collection-community-docker.spec b/ansible-collection-community-docker.spec index b0d7408..5d5708a 100644 --- a/ansible-collection-community-docker.spec +++ b/ansible-collection-community-docker.spec @@ -3,10 +3,10 @@ %global forgeurl https://github.com/ansible-collections/%{collection_namespace}.%{collection_name} # Only run tests where %%generate_buildrequires and test deps are available. -%if 0%{?fedora} -%bcond_without tests +%if %{defined fedora} +%bcond_without tests %else -%bcond_with tests +%bcond_with tests %endif @@ -22,19 +22,17 @@ License: GPLv3+ and Python URL: %{ansible_collection_url} Source0: %{forgesource} Source1: %{name}.rpmlintrc +# Downstream only patch to remove tests, CI configuration, and other +# unnecessary development files from the built collection. Patch0: build_ignore-unnecessary-files.patch +Patch1: https://github.com/ansible-collections/community.docker/pull/433.patch#/remove-python-mock.patch BuildArch: noarch -# Needed for %%py3_shebang_fix. -Buildrequires: python3-devel - BuildRequires: ansible-packaging -# The new ansible-core, specifically, is required for the `build_ignore:` patch and ansible-test to work properly. -# Therefore, we cannot rely on ansible-packaging which might pull in ansible 2.9. -BuildRequires: ansible-core %if %{with tests} -BuildRequires: /usr/bin/ansible-test +BuildRequires: ansible-packaging-tests +BuildRequires: %{py3_dist docker} %endif @@ -46,16 +44,10 @@ working with Docker. %prep %forgeautosetup -p1 + %global py3_shbang_opts %{nil} %py3_shebang_fix . - -%if %{with tests} -%generate_buildrequires -%pyproject_buildrequires -N tests/unit/requirements.txt %{python3_sitelib}/ansible_test/_data/requirements/units.txt -%endif - - %build %ansible_collection_build @@ -66,14 +58,7 @@ working with Docker. %check %if %{with tests} -mkdir -p ../ansible_collections/%{collection_namespace} -cp -a $(pwd) ../ansible_collections/%{collection_namespace}/%{collection_name} -pushd ../ansible_collections/%{collection_namespace}/%{collection_name} -# mkdir -p ansible_collections/%%{collection_namespace} -# ln -sr . ansible_collections/%%{collection_namespace}/%%{collection_name} -# pushd ansible_collections/%%{collection_namespace}/%%{collection_name} -ansible-test units --python-interpreter %{__python3} --local -popd +%ansible_test_unit %endif diff --git a/build_ignore-unnecessary-files.patch b/build_ignore-unnecessary-files.patch index 9586180..762a921 100644 --- a/build_ignore-unnecessary-files.patch +++ b/build_ignore-unnecessary-files.patch @@ -1,7 +1,7 @@ diff -Naur a/galaxy.yml b/galaxy.yml --- a/galaxy.yml 2022-04-25 14:32:27.000000000 -0500 +++ b/galaxy.yml 2022-04-29 21:07:55.917219135 -0500 -@@ -18,3 +18,9 @@ +@@ -18,3 +18,8 @@ # https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#ignoring-files-and-folders - .gitignore - changelogs/.plugin-cache.yaml @@ -10,4 +10,3 @@ diff -Naur a/galaxy.yml b/galaxy.yml + - .azure-pipelines + - changelogs/fragments/.keep + - docs -+ - .pyproject-builddir From 0bf04a1127d6c115625136e716ef56b85931b37a Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 19 Aug 2022 15:11:29 -0500 Subject: [PATCH 3/5] Fix shebang handling --- ansible-collection-community-docker.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ansible-collection-community-docker.spec b/ansible-collection-community-docker.spec index 5d5708a..f09cbd4 100644 --- a/ansible-collection-community-docker.spec +++ b/ansible-collection-community-docker.spec @@ -44,9 +44,8 @@ working with Docker. %prep %forgeautosetup -p1 +find -type f ! -executable -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' + -%global py3_shbang_opts %{nil} -%py3_shebang_fix . %build %ansible_collection_build From 1e2d60d2dea4b70c6eceff659d290cf5765b81a8 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 19 Aug 2022 15:12:09 -0500 Subject: [PATCH 4/5] Adopt new licensing guidelines --- ansible-collection-community-docker.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible-collection-community-docker.spec b/ansible-collection-community-docker.spec index f09cbd4..007874e 100644 --- a/ansible-collection-community-docker.spec +++ b/ansible-collection-community-docker.spec @@ -17,8 +17,8 @@ Version: 2.7.1 Release: 1%{?dist} Summary: Ansible modules and plugins for working with Docker -# All files are GPLv3+ except plugins/module_utils/_version.py. -License: GPLv3+ and Python +# All files are GPL-3.0-or-later except plugins/module_utils/_version.py. +License: GPL-3.0-or-later and Python URL: %{ansible_collection_url} Source0: %{forgesource} Source1: %{name}.rpmlintrc From 5c1e44164141eeaad0252b6776a5120e5e38bcfa Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 19 Aug 2022 15:27:18 -0500 Subject: [PATCH 5/5] Upload missing patch --- remove-python-mock.patch | 125 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 remove-python-mock.patch diff --git a/remove-python-mock.patch b/remove-python-mock.patch new file mode 100644 index 0000000..3ff2c20 --- /dev/null +++ b/remove-python-mock.patch @@ -0,0 +1,125 @@ +From 7e9eee69c273515129cc0ac0e425b4b2c7da9263 Mon Sep 17 00:00:00 2001 +From: Maxwell G +Date: Thu, 28 Jul 2022 13:57:18 +0200 +Subject: [PATCH 1/2] Prefer unitest.mock by using compat.mock + +`mock` is a backport of the `unittest.mock` module from the stdlib, and +there's no reason to use it on newer Python versions. `mock` is deprecated +in Fedora, so I figured I'd propose this here before downstream patching +our ansible-collection-community-docker package. +--- + tests/unit/plugins/inventory/test_docker_containers.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/unit/plugins/inventory/test_docker_containers.py b/tests/unit/plugins/inventory/test_docker_containers.py +index 1c831b21..74721bfe 100644 +--- a/tests/unit/plugins/inventory/test_docker_containers.py ++++ b/tests/unit/plugins/inventory/test_docker_containers.py +@@ -11,7 +11,7 @@ + + import pytest + +-from mock import MagicMock ++from ansible_collections.community.docker.tests.unit.compat.mock import MagicMock + + from ansible import constants as C + from ansible.errors import AnsibleError + +From 0efaff6a01c113980a70b92e93bdadd7237a7949 Mon Sep 17 00:00:00 2001 +From: Maxwell G +Date: Thu, 28 Jul 2022 14:15:53 +0200 +Subject: [PATCH 2/2] Remove compat.mock code for older Python 3 versions + +This removes compatibility for older versions of Python 3 that are no +longer supported. +--- + tests/unit/compat/mock.py | 79 --------------------------------------- + 1 file changed, 79 deletions(-) + +diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py +index f8f565dc..515b94a3 100644 +--- a/tests/unit/compat/mock.py ++++ b/tests/unit/compat/mock.py +@@ -28,82 +28,3 @@ + from mock import * + except ImportError: + print('You need the mock library installed on python2.x to run tests') +- +- +-# Prior to 3.4.4, mock_open cannot handle binary read_data +-if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): +- file_spec = None +- +- def _iterate_read_data(read_data): +- # Helper for mock_open: +- # Retrieve lines from read_data via a generator so that separate calls to +- # readline, read, and readlines are properly interleaved +- sep = b'\n' if isinstance(read_data, bytes) else '\n' +- data_as_list = [l + sep for l in read_data.split(sep)] +- +- if data_as_list[-1] == sep: +- # If the last line ended in a newline, the list comprehension will have an +- # extra entry that's just a newline. Remove this. +- data_as_list = data_as_list[:-1] +- else: +- # If there wasn't an extra newline by itself, then the file being +- # emulated doesn't have a newline to end the last line remove the +- # newline that our naive format() added +- data_as_list[-1] = data_as_list[-1][:-1] +- +- for line in data_as_list: +- yield line +- +- def mock_open(mock=None, read_data=''): +- """ +- A helper function to create a mock to replace the use of `open`. It works +- for `open` called directly or used as a context manager. +- +- The `mock` argument is the mock object to configure. If `None` (the +- default) then a `MagicMock` will be created for you, with the API limited +- to methods or attributes available on standard file handles. +- +- `read_data` is a string for the `read` methoddline`, and `readlines` of the +- file handle to return. This is an empty string by default. +- """ +- def _readlines_side_effect(*args, **kwargs): +- if handle.readlines.return_value is not None: +- return handle.readlines.return_value +- return list(_data) +- +- def _read_side_effect(*args, **kwargs): +- if handle.read.return_value is not None: +- return handle.read.return_value +- return type(read_data)().join(_data) +- +- def _readline_side_effect(): +- if handle.readline.return_value is not None: +- while True: +- yield handle.readline.return_value +- for line in _data: +- yield line +- +- global file_spec +- if file_spec is None: +- import _io +- file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) +- +- if mock is None: +- mock = MagicMock(name='open', spec=open) +- +- handle = MagicMock(spec=file_spec) +- handle.__enter__.return_value = handle +- +- _data = _iterate_read_data(read_data) +- +- handle.write.return_value = None +- handle.read.return_value = None +- handle.readline.return_value = None +- handle.readlines.return_value = None +- +- handle.read.side_effect = _read_side_effect +- handle.readline.side_effect = _readline_side_effect() +- handle.readlines.side_effect = _readlines_side_effect +- +- mock.return_value = handle +- return mock