Skip to content

Commit e194a63

Browse files
committed
ci: Fix version comparisons involving double digits
See https://gist.github.com/moreati/e7507c5b606b12ec0ddafcb7c8debbf1
1 parent 9a66d3a commit e194a63

File tree

18 files changed

+104
-58
lines changed

18 files changed

+104
-58
lines changed

ansible_mitogen/target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def subprocess__Popen__close_fds(self, but):
144144

145145
if (
146146
sys.platform.startswith(u'linux') and
147-
sys.version < u'3.0' and
147+
sys.version_info < (3,) and
148148
hasattr(subprocess.Popen, u'_close_fds') and
149149
not mitogen.is_master
150150
):

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ v0.3.1.dev0 (unreleased)
2727
* :gh:issue:`860` Add initial support for podman connection (w/o Ansible support yet)
2828
* :gh:issue:`873` `python -c ...` first stage no longer uses :py:mod:`platform`` to detect the macOS release
2929
* :gh:issue:`876` `python -c ...` first stage no longer contains tab characters, to reduce size
30+
* :gh:issue:`878` Continuous Integration tests now correctly perform comparisons of 2 digit versions
3031

3132

3233
v0.3.0 (2021-11-24)

tests/ansible/integration/async/result_shell_echo_hi.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
that:
4747
- async_out.invocation.module_args.stdin == None
4848
fail_msg: async_out={{async_out}}
49-
when: ansible_version.full > '2.4'
49+
when:
50+
- ansible_version.full is version('2.4', '>=', strict=True)
5051
vars:
5152
async_out: "{{result.content|b64decode|from_json}}"
5253
tags:

tests/ansible/integration/async/runner_one_job.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
- result1.changed == True
4242
# ansible/b72e989e1837ccad8dcdc926c43ccbc4d8cdfe44
4343
- |
44-
(ansible_version.full is version('2.8', ">=") and
44+
(ansible_version.full is version('2.8', ">=", strict=True) and
4545
result1.cmd == "echo alldone;\nsleep 1;\n") or
46-
(ansible_version.full is version('2.8', '<') and
46+
(ansible_version.full is version('2.8', '<', strict=True) and
4747
result1.cmd == "echo alldone;\n sleep 1;")
4848
- result1.delta|length == 14
4949
- result1.start|length == 26
@@ -58,12 +58,14 @@
5858
- result1.stdout == "alldone"
5959
- result1.stdout_lines == ["alldone"]
6060
fail_msg: result1={{result1}}
61-
when: ansible_version.full is version('2.8', '>') # ansible#51393
61+
when:
62+
- ansible_version.full is version('2.8', '>', strict=True) # ansible#51393
6263

6364
- assert:
6465
that:
6566
- result1.failed == False
6667
fail_msg: result1={{result1}}
67-
when: ansible_version.full is version('2.4', '>')
68+
when:
69+
- ansible_version.full is version('2.4', '>', strict=True)
6870
tags:
6971
- runner_one_job

tests/ansible/integration/async/runner_two_simultaneous_jobs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
that:
6363
- result2.stdout == 'im_alive'
6464
fail_msg: result2={{result2}}
65-
when: ansible_version.full > '2.8' # ansible#51393
65+
when:
66+
- ansible_version.full is version('2.8', '>=', strict=True) # ansible#51393
6667
tags:
6768
- runner_two_simultaneous_jobs

tests/ansible/integration/connection/reset.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
when: not is_mitogen
1111

1212
- debug: msg="reset.yml skipped on Ansible<2.5.6"
13-
when: ansible_version.full < '2.5.6'
13+
when:
14+
- ansible_version.full is version('2.5.6', '<', strict=True)
1415

1516
- meta: end_play
16-
when: ansible_version.full < '2.5.6'
17+
when:
18+
- ansible_version.full is version('2.5.6', '<', strict=True)
1719

1820
- custom_python_detect_environment:
1921
register: out

tests/ansible/integration/connection/reset_become.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
gather_facts: false
77
tasks:
88
- debug: msg="reset_become.yml skipped on Ansible<2.5.6"
9-
when: ansible_version.full < '2.5.6'
9+
when:
10+
- ansible_version.full is version('2.5.6', '<', strict=True)
1011

1112
- meta: end_play
12-
when: ansible_version.full < '2.5.6'
13+
when:
14+
- ansible_version.full is version('2.5.6', '<', strict=True)
1315

1416
- name: save pid of the become acct
1517
custom_python_detect_environment:

tests/ansible/integration/connection_delegation/delegate_to_template.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
when: not is_mitogen
2121

2222
- meta: end_play
23-
when: ansible_version.full < '2.4'
23+
when:
24+
- ansible_version.full is version('2.4', '<', strict=True)
2425

2526
- mitogen_get_stack:
2627
delegate_to: "{{ physical_host }}"

tests/ansible/integration/context_service/disconnect_cleanup.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
when: not is_mitogen
1010

1111
- meta: end_play
12-
when: ansible_version.full < '2.5.6'
12+
when:
13+
- ansible_version.full is version('2.5.6', '<', strict=True)
1314

1415
# Start with a clean slate.
1516
- mitogen_shutdown_all:

tests/ansible/integration/glibc_caches/resolv_conf.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,44 @@
88
vars:
99
ansible_become_pass: has_sudo_pubkey_password
1010
tasks:
11-
1211
- mitogen_test_gethostbyname:
1312
name: www.google.com
1413
register: out
15-
when: |
16-
ansible_virtualization_type == "docker" and
17-
ansible_python_version > "2.5"
14+
when:
15+
- ansible_facts.virtualization_type == "docker"
16+
- ansible_facts.python.version_info[:2] >= [2, 5]
1817

1918
- shell: cp /etc/resolv.conf /tmp/resolv.conf
20-
when: |
21-
ansible_virtualization_type == "docker" and
22-
ansible_python_version > "2.5"
19+
when:
20+
- ansible_facts.virtualization_type == "docker"
21+
- ansible_facts.python.version_info[:2] >= [2, 5]
2322

2423
- shell: echo > /etc/resolv.conf
25-
when: |
26-
ansible_virtualization_type == "docker" and
27-
ansible_python_version > "2.5"
24+
when:
25+
- ansible_facts.virtualization_type == "docker"
26+
- ansible_facts.python.version_info[:2] >= [2, 5]
2827

2928
- mitogen_test_gethostbyname:
3029
name: www.google.com
3130
register: out
3231
ignore_errors: true
33-
when: |
34-
ansible_virtualization_type == "docker" and
35-
ansible_python_version > "2.5"
32+
when:
33+
- ansible_facts.virtualization_type == "docker"
34+
- ansible_facts.python.version_info[:2] >= [2, 5]
3635

3736
- shell: cat /tmp/resolv.conf > /etc/resolv.conf
38-
when: |
39-
ansible_virtualization_type == "docker" and
40-
ansible_python_version > "2.5"
37+
when:
38+
- ansible_facts.virtualization_type == "docker"
39+
- ansible_facts.python.version_info[:2] >= [2, 5]
4140

4241
- assert:
4342
that:
4443
- out.failed
4544
- '"Name or service not known" in out.msg or
4645
"Temporary failure in name resolution" in out.msg'
4746
fail_msg: out={{out}}
48-
when: |
49-
ansible_virtualization_type == "docker" and
50-
ansible_python_version > "2.5"
47+
when:
48+
- ansible_facts.virtualization_type == "docker"
49+
- ansible_facts.python.version_info[:2] >= [2, 5]
5150
tags:
5251
- resolv_conf

0 commit comments

Comments
 (0)