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