From b551430376e98096c30180d0df4644880d3e3fca Mon Sep 17 00:00:00 2001 From: Mark Mercado Date: Thu, 23 Jun 2022 21:03:06 -0400 Subject: [PATCH] Add sanity ignores for 2.12 and 2.13 (#249) * Adding stable-2.13.0rc1 to sanity matrix * Adding stable-2.13.0rc1 to units matrix * Fixing sanity compile on py2.6, 2.7, and 3.5 * Nevermind stable-2.13.0rc1 * Adding ignores for 2.12 * Reverting the Spaces modules * Do a naive version check on dopy * Adding ignores for sanity 2.13 * Adding a changelog fragment * Try packaging.version before naive * Fix tense and capitalization --- .../fragments/247-sanity-checks-2.12-13.yaml | 2 ++ plugins/modules/digital_ocean.py | 17 ++++++++++++++--- tests/sanity/ignore-2.12.txt | 12 ++++++++++++ tests/sanity/ignore-2.13.txt | 8 ++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/247-sanity-checks-2.12-13.yaml create mode 100644 tests/sanity/ignore-2.12.txt create mode 100644 tests/sanity/ignore-2.13.txt diff --git a/changelogs/fragments/247-sanity-checks-2.12-13.yaml b/changelogs/fragments/247-sanity-checks-2.12-13.yaml new file mode 100644 index 00000000..d7a95823 --- /dev/null +++ b/changelogs/fragments/247-sanity-checks-2.12-13.yaml @@ -0,0 +1,2 @@ +minor_changes: + - digital_ocean - add sanity test ignores for Ansible 2.12 and 2.13 (https://github.com/ansible-collections/community.digitalocean/issues/247). diff --git a/plugins/modules/digital_ocean.py b/plugins/modules/digital_ocean.py index dd716e77..1c33f2c7 100644 --- a/plugins/modules/digital_ocean.py +++ b/plugins/modules/digital_ocean.py @@ -189,7 +189,12 @@ import time import traceback -from distutils.version import LooseVersion +try: + from packaging.version import Version + + HAS_PACKAGING = True +except ImportError: + HAS_PACKAGING = False try: # Imported as a dependency for dopy @@ -204,8 +209,14 @@ import dopy from dopy.manager import DoError, DoManager - if LooseVersion(dopy.__version__) >= LooseVersion("0.3.2"): - HAS_DOPY = True + # NOTE: Expressing Python dependencies isn't really possible: + # https://github.com/ansible/ansible/issues/62733#issuecomment-537098744 + if HAS_PACKAGING: + if Version(dopy.__version__) >= Version("0.3.2"): + HAS_DOPY = True + else: + if dopy.__version__ >= "0.3.2": # Naive lexographical check + HAS_DOPY = True except ImportError: pass diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt new file mode 100644 index 00000000..6fa08266 --- /dev/null +++ b/tests/sanity/ignore-2.12.txt @@ -0,0 +1,12 @@ +plugins/modules/digital_ocean_spaces.py compile-2.6!skip +plugins/modules/digital_ocean_spaces_info.py compile-2.6!skip +plugins/modules/digital_ocean_spaces.py compile-2.7!skip +plugins/modules/digital_ocean_spaces_info.py compile-2.7!skip +plugins/modules/digital_ocean_spaces.py compile-3.5!skip +plugins/modules/digital_ocean_spaces_info.py compile-3.5!skip +plugins/modules/digital_ocean_spaces.py import-2.6!skip +plugins/modules/digital_ocean_spaces_info.py import-2.6!skip +plugins/modules/digital_ocean_spaces.py import-2.7!skip +plugins/modules/digital_ocean_spaces_info.py import-2.7!skip +plugins/modules/digital_ocean_spaces.py import-3.5!skip +plugins/modules/digital_ocean_spaces_info.py import-3.5!skip diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt new file mode 100644 index 00000000..56f00467 --- /dev/null +++ b/tests/sanity/ignore-2.13.txt @@ -0,0 +1,8 @@ +plugins/modules/digital_ocean_spaces.py compile-2.7!skip +plugins/modules/digital_ocean_spaces_info.py compile-2.7!skip +plugins/modules/digital_ocean_spaces.py compile-3.5!skip +plugins/modules/digital_ocean_spaces_info.py compile-3.5!skip +plugins/modules/digital_ocean_spaces.py import-2.7!skip +plugins/modules/digital_ocean_spaces_info.py import-2.7!skip +plugins/modules/digital_ocean_spaces.py import-3.5!skip +plugins/modules/digital_ocean_spaces_info.py import-3.5!skip