|
20 | 20 | virtualenv: "{{ antsibull_ansible_venv }}" |
21 | 21 | virtualenv_command: "{{ ansible_python.executable }} -m venv" |
22 | 22 |
|
23 | | -# Note: the version of ansible-core doesn't necessarily match the deps file since the version requirement is >= |
24 | | -- block: |
25 | | - # Note: the value is either _ansible_base_version or _ansible_core_version depending on the version |
26 | | - # ex: https://github.com/ansible-community/ansible-build-data/blob/main/4/ansible-4.4.0.deps |
27 | | - - name: Retrieve the expected minimum version of ansible-core |
28 | | - shell: >- |
29 | | - grep -E "_ansible_(base|core)_version" {{ antsibull_data_dir }}/{{ _deps_file }} | awk '{print $2}' |
30 | | - changed_when: false |
31 | | - register: _expected_ansible_core |
| 23 | +- name: Test and validate that we have the expected versions of collections, ansible-core and ansible |
| 24 | + include_tasks: tests/versions.yaml |
32 | 25 |
|
33 | | - - name: Retrieve the installed version of ansible-core |
34 | | - shell: >- |
35 | | - {{ antsibull_ansible_venv }}/bin/pip show ansible-core | awk '/Version/ {print $2}' |
36 | | - changed_when: false |
37 | | - register: _installed_ansible_core |
| 26 | +- name: Install the built ansible in venv and run integration tests with it |
| 27 | + include_tasks: tests/nested.yaml |
38 | 28 |
|
39 | | - - name: Validate the version of ansible-core |
40 | | - ansible.builtin.assert: |
41 | | - that: |
42 | | - - _installed_ansible_core.stdout is version(_expected_ansible_core.stdout, '>=') |
43 | | - success_msg: "ansible-core {{ _installed_ansible_core.stdout }} matches (or exceeds) {{ _deps_file }}" |
44 | | - fail_msg: "ansible-core {{ _installed_ansible_core.stdout }} does not match {{ _deps_file }}" |
45 | | - |
46 | | -- block: |
47 | | - - name: Retrieve expected versions of Ansible and collections |
48 | | - command: cat {{ antsibull_data_dir }}/{{ _deps_file }} |
49 | | - changed_when: false |
50 | | - register: _expected_versions |
51 | | - |
52 | | - - name: Retrieve collections that should be included in the package |
53 | | - shell: cat {{ antsibull_data_dir }}/ansible.in | egrep -v "^#" |
54 | | - changed_when: false |
55 | | - register: _included_collections |
56 | | - |
57 | | - - name: Retrieve the installed version of ansible with pip |
58 | | - shell: >- |
59 | | - {{ antsibull_ansible_venv }}/bin/pip show ansible | awk '/Version/ {print $2}' |
60 | | - changed_when: false |
61 | | - register: _ansible_version_pypi |
62 | | - |
63 | | - - name: Retrieve the builtin reported version of ansible |
64 | | - command: >- |
65 | | - {{ antsibull_ansible_venv }}/bin/python3 -c 'from ansible_collections.ansible_release import ansible_version; print(ansible_version)' |
66 | | - changed_when: false |
67 | | - register: _ansible_version_builtin |
68 | | - |
69 | | - - name: Validate the version of ansible |
70 | | - ansible.builtin.assert: |
71 | | - that: |
72 | | - - "'_ansible_version: {{ _ansible_version_pypi.stdout }}' in _expected_versions.stdout" |
73 | | - - _ansible_version_pypi.stdout == _ansible_version_builtin.stdout |
74 | | - success_msg: "ansible {{ _ansible_version_pypi.stdout }} matches {{ _deps_file }} as well as 'ansible_collections.ansible_release'" |
75 | | - fail_msg: "ansible {{ _ansible_version_pypi.stdout }} does not match {{ _deps_file }} or 'ansible_collections.ansible_release'" |
76 | | - |
77 | | - - name: Retrieve installed collections |
78 | | - environment: |
79 | | - # In case we happen to be testing with devel, don't print a warning about it |
80 | | - ANSIBLE_DEVEL_WARNING: false |
81 | | - # Until https://github.com/ansible/ansible/pull/70173 is backported and released |
82 | | - ANSIBLE_COLLECTIONS_PATH: "{{ antsibull_ansible_venv }}/lib/{{ _python_version }}/site-packages/ansible_collections" |
83 | | - # List collections, remove empty lines, headers, file paths and format the results in the same way as the deps file |
84 | | - shell: >- |
85 | | - {{ antsibull_ansible_venv }}/bin/ansible-galaxy collection list | egrep -v '^$|^#|---|Collection.*Version' | awk '{ print $1 ": " $2 }' |
86 | | - changed_when: false |
87 | | - register: _installed_collections |
88 | | - |
89 | | - - name: Validate that the installed collections are the expected ones |
90 | | - ansible.builtin.assert: |
91 | | - that: |
92 | | - - item in _expected_versions.stdout |
93 | | - success_msg: "{{ item }} matches {{ _deps_file }}" |
94 | | - fail_msg: "{{ item }} does not match {{ _deps_file }}" |
95 | | - loop: "{{ _installed_collections.stdout_lines }}" |
96 | | - |
97 | | - - name: Validate that included collections are packaged |
98 | | - ansible.builtin.assert: |
99 | | - that: |
100 | | - - item in _installed_collections.stdout |
101 | | - success_msg: "{{ item }} is in ansible.in and inside the package" |
102 | | - fail_msg: "{{ item }} is in ansible.in but not inside the package. Maybe run 'antsibull-build new-ansible --data-dir={{ antsibull_data_dir }}' to update ansible.in and then rebuild ?" |
103 | | - loop: "{{ _included_collections.stdout_lines }}" |
104 | | - |
105 | | -- block: |
106 | | - - name: Create a temporary COLLECTIONS_PATH |
107 | | - file: |
108 | | - path: "{{ antsibull_sdist_dir }}/ansible_collections" |
109 | | - state: directory |
110 | | - |
111 | | - - name: Install community.general for tests using 'a_module' and 'collection_version' |
112 | | - environment: |
113 | | - ANSIBLE_COLLECTIONS_PATH: "{{ antsibull_sdist_dir }}/ansible_collections" |
114 | | - command: >- |
115 | | - {{ antsibull_ansible_venv }}/bin/ansible-galaxy collection install community.general |
116 | | -
|
117 | | - - name: Run nested Ansible tests with the Ansible we just built |
118 | | - environment: |
119 | | - ANSIBLE_COLLECTIONS_PATH: "{{ antsibull_sdist_dir }}/ansible_collections" |
120 | | - command: >- |
121 | | - {{ antsibull_ansible_venv }}/bin/ansible-playbook -i 'localhost,' --connection=local |
122 | | - -e antsibull_sdist_dir="{{ antsibull_sdist_dir }}" |
123 | | - -e antsibull_ansible_venv="{{ antsibull_ansible_venv }}" |
124 | | - -e antsibull_ansible_git_dir="{{ antsibull_ansible_git_dir }}" |
125 | | - -e antsibull_ansible_git_version="{{ antsibull_ansible_git_version }}" |
126 | | - -e _python_version="{{ _python_version }}" |
127 | | - {{ playbook_dir }}/nested-ansible-tests.yaml |
| 29 | +- name: Run ansible-test sanity --docker on installed collections with podman |
| 30 | + include_tasks: tests/sanity.yaml |
| 31 | + when: antsibull_run_sanity | bool |
0 commit comments