ci: Fix version comparisons involving double digits

See https://gist.github.com/moreati/e7507c5b606b12ec0ddafcb7c8debbf1
pull/878/head
Alex Willmer 3 years ago
parent 9a66d3aeec
commit e194a6367f

@ -144,7 +144,7 @@ def subprocess__Popen__close_fds(self, but):
if ( if (
sys.platform.startswith(u'linux') and sys.platform.startswith(u'linux') and
sys.version < u'3.0' and sys.version_info < (3,) and
hasattr(subprocess.Popen, u'_close_fds') and hasattr(subprocess.Popen, u'_close_fds') and
not mitogen.is_master not mitogen.is_master
): ):

@ -27,6 +27,7 @@ v0.3.1.dev0 (unreleased)
* :gh:issue:`860` Add initial support for podman connection (w/o Ansible support yet) * :gh:issue:`860` Add initial support for podman connection (w/o Ansible support yet)
* :gh:issue:`873` `python -c ...` first stage no longer uses :py:mod:`platform`` to detect the macOS release * :gh:issue:`873` `python -c ...` first stage no longer uses :py:mod:`platform`` to detect the macOS release
* :gh:issue:`876` `python -c ...` first stage no longer contains tab characters, to reduce size * :gh:issue:`876` `python -c ...` first stage no longer contains tab characters, to reduce size
* :gh:issue:`878` Continuous Integration tests now correctly perform comparisons of 2 digit versions
v0.3.0 (2021-11-24) v0.3.0 (2021-11-24)

@ -46,7 +46,8 @@
that: that:
- async_out.invocation.module_args.stdin == None - async_out.invocation.module_args.stdin == None
fail_msg: async_out={{async_out}} fail_msg: async_out={{async_out}}
when: ansible_version.full > '2.4' when:
- ansible_version.full is version('2.4', '>=', strict=True)
vars: vars:
async_out: "{{result.content|b64decode|from_json}}" async_out: "{{result.content|b64decode|from_json}}"
tags: tags:

@ -41,9 +41,9 @@
- result1.changed == True - result1.changed == True
# ansible/b72e989e1837ccad8dcdc926c43ccbc4d8cdfe44 # ansible/b72e989e1837ccad8dcdc926c43ccbc4d8cdfe44
- | - |
(ansible_version.full is version('2.8', ">=") and (ansible_version.full is version('2.8', ">=", strict=True) and
result1.cmd == "echo alldone;\nsleep 1;\n") or result1.cmd == "echo alldone;\nsleep 1;\n") or
(ansible_version.full is version('2.8', '<') and (ansible_version.full is version('2.8', '<', strict=True) and
result1.cmd == "echo alldone;\n sleep 1;") result1.cmd == "echo alldone;\n sleep 1;")
- result1.delta|length == 14 - result1.delta|length == 14
- result1.start|length == 26 - result1.start|length == 26
@ -58,12 +58,14 @@
- result1.stdout == "alldone" - result1.stdout == "alldone"
- result1.stdout_lines == ["alldone"] - result1.stdout_lines == ["alldone"]
fail_msg: result1={{result1}} fail_msg: result1={{result1}}
when: ansible_version.full is version('2.8', '>') # ansible#51393 when:
- ansible_version.full is version('2.8', '>', strict=True) # ansible#51393
- assert: - assert:
that: that:
- result1.failed == False - result1.failed == False
fail_msg: result1={{result1}} fail_msg: result1={{result1}}
when: ansible_version.full is version('2.4', '>') when:
- ansible_version.full is version('2.4', '>', strict=True)
tags: tags:
- runner_one_job - runner_one_job

@ -62,6 +62,7 @@
that: that:
- result2.stdout == 'im_alive' - result2.stdout == 'im_alive'
fail_msg: result2={{result2}} fail_msg: result2={{result2}}
when: ansible_version.full > '2.8' # ansible#51393 when:
- ansible_version.full is version('2.8', '>=', strict=True) # ansible#51393
tags: tags:
- runner_two_simultaneous_jobs - runner_two_simultaneous_jobs

@ -10,10 +10,12 @@
when: not is_mitogen when: not is_mitogen
- debug: msg="reset.yml skipped on Ansible<2.5.6" - debug: msg="reset.yml skipped on Ansible<2.5.6"
when: ansible_version.full < '2.5.6' when:
- ansible_version.full is version('2.5.6', '<', strict=True)
- meta: end_play - meta: end_play
when: ansible_version.full < '2.5.6' when:
- ansible_version.full is version('2.5.6', '<', strict=True)
- custom_python_detect_environment: - custom_python_detect_environment:
register: out register: out

@ -6,10 +6,12 @@
gather_facts: false gather_facts: false
tasks: tasks:
- debug: msg="reset_become.yml skipped on Ansible<2.5.6" - debug: msg="reset_become.yml skipped on Ansible<2.5.6"
when: ansible_version.full < '2.5.6' when:
- ansible_version.full is version('2.5.6', '<', strict=True)
- meta: end_play - meta: end_play
when: ansible_version.full < '2.5.6' when:
- ansible_version.full is version('2.5.6', '<', strict=True)
- name: save pid of the become acct - name: save pid of the become acct
custom_python_detect_environment: custom_python_detect_environment:

@ -20,7 +20,8 @@
when: not is_mitogen when: not is_mitogen
- meta: end_play - meta: end_play
when: ansible_version.full < '2.4' when:
- ansible_version.full is version('2.4', '<', strict=True)
- mitogen_get_stack: - mitogen_get_stack:
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"

@ -9,7 +9,8 @@
when: not is_mitogen when: not is_mitogen
- meta: end_play - meta: end_play
when: ansible_version.full < '2.5.6' when:
- ansible_version.full is version('2.5.6', '<', strict=True)
# Start with a clean slate. # Start with a clean slate.
- mitogen_shutdown_all: - mitogen_shutdown_all:

@ -8,36 +8,35 @@
vars: vars:
ansible_become_pass: has_sudo_pubkey_password ansible_become_pass: has_sudo_pubkey_password
tasks: tasks:
- mitogen_test_gethostbyname: - mitogen_test_gethostbyname:
name: www.google.com name: www.google.com
register: out register: out
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
- shell: cp /etc/resolv.conf /tmp/resolv.conf - shell: cp /etc/resolv.conf /tmp/resolv.conf
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
- shell: echo > /etc/resolv.conf - shell: echo > /etc/resolv.conf
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
- mitogen_test_gethostbyname: - mitogen_test_gethostbyname:
name: www.google.com name: www.google.com
register: out register: out
ignore_errors: true ignore_errors: true
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
- shell: cat /tmp/resolv.conf > /etc/resolv.conf - shell: cat /tmp/resolv.conf > /etc/resolv.conf
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
- assert: - assert:
that: that:
@ -45,8 +44,8 @@
- '"Name or service not known" in out.msg or - '"Name or service not known" in out.msg or
"Temporary failure in name resolution" in out.msg' "Temporary failure in name resolution" in out.msg'
fail_msg: out={{out}} fail_msg: out={{out}}
when: | when:
ansible_virtualization_type == "docker" and - ansible_facts.virtualization_type == "docker"
ansible_python_version > "2.5" - ansible_facts.python.version_info[:2] >= [2, 5]
tags: tags:
- resolv_conf - resolv_conf

@ -132,27 +132,45 @@
that: that:
- auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3' - auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3'
fail_msg: auto_out={{auto_out}} fail_msg: auto_out={{auto_out}}
when: distro == 'fedora' and distro_version is version('23', '>=') when:
- distro == 'fedora'
- distro_version is version('23.0', '>=', strict=True)
- name: rhel assertions - name: rhel < 8 assertions
assert: assert:
that: that:
# rhel 6/7 - auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python'
- (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and distro_version is version('8','<')) or distro_version is version('8','>=') fail_msg: auto_out={{auto_out}}
# rhel 8+ when:
- (auto_out.ansible_facts.discovered_interpreter_python == '/usr/libexec/platform-python' and distro_version is version('8','>=')) or distro_version is version('8','<') - distro in ('redhat', 'centos')
- distro_version is version('8.0', '<', strict=true)
- name: rhel 8+ assertions
assert:
that:
- auto_out.ansible_facts.discovered_interpreter_python == '/usr/libexec/platform-python'
fail_msg: auto_out={{auto_out}} fail_msg: auto_out={{auto_out}}
when: distro in ('redhat', 'centos') when:
- distro in ('redhat', 'centos')
- distro_version is version('8.0', '>=', strict=true)
- name: ubuntu assertions - name: ubuntu < 16.04 assertions
assert: assert:
that: that:
# ubuntu < 16 - auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python'
- (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and distro_version is version('16.04','<')) or distro_version is version('16.04','>=') fail_msg: auto_out={{auto_out}}
# ubuntu >= 16 when:
- (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3' and distro_version is version('16.04','>=')) or distro_version is version('16.04','<') - distro == 'ubuntu'
- distro_version is version('16.04', '<', strict=true)
- name: ubuntu 16.04+ assertions
assert:
that:
- auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3'
fail_msg: auto_out={{auto_out}} fail_msg: auto_out={{auto_out}}
when: distro == 'ubuntu' when:
- distro == 'ubuntu'
- distro_version is version('16.04', '>=', strict=True)
- name: mac assertions - name: mac assertions
assert: assert:
@ -163,6 +181,7 @@
always: always:
- meta: clear_facts - meta: clear_facts
when: ansible_version.full is version_compare('2.8.0', '>=') when:
- ansible_version.full is version_compare('2.8.0', '>=', strict=True)
tags: tags:
- ansible_2_8_tests - ansible_2_8_tests

@ -13,11 +13,12 @@
- out.results[0].message == 'I am a perl script! Here is my input.' - out.results[0].message == 'I am a perl script! Here is my input.'
fail_msg: out={{out}} fail_msg: out={{out}}
- when: ansible_version.full > '2.4' - assert:
assert:
that: that:
- (not out.changed) - (not out.changed)
- (not out.results[0].changed) - (not out.results[0].changed)
fail_msg: out={{out}} fail_msg: out={{out}}
when:
- ansible_version.full is version('2.4', '>=', strict=True)
tags: tags:
- custom_perl_json_args_module - custom_perl_json_args_module

@ -13,11 +13,12 @@
- out.results[0].message == 'I am a want JSON perl script! Here is my input.' - out.results[0].message == 'I am a want JSON perl script! Here is my input.'
fail_msg: out={{out}} fail_msg: out={{out}}
- when: ansible_version.full > '2.4' - assert:
assert:
that: that:
- (not out.changed) - (not out.changed)
- (not out.results[0].changed) - (not out.results[0].changed)
fail_msg: out={{out}} fail_msg: out={{out}}
when:
- ansible_version.full is version('2.4', '>=', strict=True)
tags: tags:
- custom_perl_want_json_module - custom_perl_want_json_module

@ -8,7 +8,8 @@
when: not is_mitogen when: not is_mitogen
- meta: end_play - meta: end_play
when: ansible_version.full < '2.5' when:
- ansible_version.full is version('2.5', '<', strict=True)
- custom_python_detect_environment: - custom_python_detect_environment:
vars: vars:

@ -26,7 +26,15 @@ except NameError:
def main(): def main():
module = AnsibleModule(argument_spec={}) module = AnsibleModule(argument_spec={})
module.exit_json( module.exit_json(
python_version=sys.version[:3], python={
'version': {
'full': '%i.%i.%i' % sys.version_info[:3],
'info': list(sys.version_info),
'major': sys.version_info[0],
'minor': sys.version_info[1],
'patch': sys.version_info[2],
},
},
argv=sys.argv, argv=sys.argv,
__file__=__file__, __file__=__file__,
argv_types_correct=all(type(s) is str for s in sys.argv), argv_types_correct=all(type(s) is str for s in sys.argv),

@ -7,7 +7,8 @@
gather_facts: true gather_facts: true
tasks: tasks:
- meta: end_play - meta: end_play
when: ansible_version.full < '2.6' when:
- ansible_version.full is version('2.6', '<', strict=True)
# Copy the naughty 'ansible' into place. # Copy the naughty 'ansible' into place.
- copy: - copy:

@ -9,27 +9,31 @@
# Can't use pip module because it can't create virtualenvs, must call it # Can't use pip module because it can't create virtualenvs, must call it
# directly. # directly.
- shell: virtualenv /tmp/issue_152_virtualenv - shell: virtualenv /tmp/issue_152_virtualenv
when: lout.python_version > '2.6'
environment: environment:
https_proxy: "{{ lookup('env', 'https_proxy')|default('') }}" https_proxy: "{{ lookup('env', 'https_proxy')|default('') }}"
no_proxy: "{{ lookup('env', 'no_proxy')|default('') }}" no_proxy: "{{ lookup('env', 'no_proxy')|default('') }}"
PATH: "{{ lookup('env', 'PATH') }}" PATH: "{{ lookup('env', 'PATH') }}"
when:
- lout.python.version.full is version('2.7', '>=', strict=True)
- custom_python_detect_environment: - custom_python_detect_environment:
vars: vars:
ansible_python_interpreter: /tmp/issue_152_virtualenv/bin/python ansible_python_interpreter: /tmp/issue_152_virtualenv/bin/python
register: out register: out
when: lout.python_version > '2.6' when:
- lout.python.version.full is version('2.7', '>=', strict=True)
- assert: - assert:
that: that:
- out.sys_executable == "/tmp/issue_152_virtualenv/bin/python" - out.sys_executable == "/tmp/issue_152_virtualenv/bin/python"
fail_msg: out={{out}} fail_msg: out={{out}}
when: lout.python_version > '2.6' when:
- lout.python.version.full is version('2.7', '>=', strict=True)
- file: - file:
path: /tmp/issue_152_virtualenv path: /tmp/issue_152_virtualenv
state: absent state: absent
when: lout.python_version > '2.6' when:
- lout.python.version.full is version('2.7', '>=', strict=True)
tags: tags:
- issue_152 - issue_152

@ -2,7 +2,8 @@
- hosts: test-targets - hosts: test-targets
tasks: tasks:
- meta: end_play - meta: end_play
when: ansible_version.full < '2.8' when:
- ansible_version.full is version('2.8', '<', strict=True)
- custom_python_uses_distro: - custom_python_uses_distro:
register: out register: out

Loading…
Cancel
Save