diff --git a/roles/ansible-test/tasks/init_collection.yaml b/roles/ansible-test/tasks/init_collection.yaml index 62ca0d81d..9501a2b16 100644 --- a/roles/ansible-test/tasks/init_collection.yaml +++ b/roles/ansible-test/tasks/init_collection.yaml @@ -4,8 +4,36 @@ _test_location: "{{ ansible_test_collection_dir }}/{{ ansible_test_collection_namespace }}/{{ ansible_test_collection_name }}" _test_cfg_location: "{{ ansible_test_collection_dir }}/{{ ansible_test_collection_namespace }}/{{ ansible_test_collection_name }}/tests/integration/{{ ansible_test_test_command }}.cfg" +- name: Setup minimum test requirements + set_fact: + _test_requirements: '-r {{ _test_location }}/requirements.txt -r {{ _test_location }}/test-requirements.txt' + +- name: Check for existence of test command specific requirements/constraints + when: ansible_test_test_command in _file_locations + vars: + _file_locations: + integration: '{{ _test_location }}/tests/integration' + units: '{{ _test_location }}/tests/unit' + block: + - name: Check for test command constraints file + stat: + path: '{{ _file_locations[ansible_test_test_command] }}/constraints.txt' + register: _extra_constraints_stat + - name: Check for test command requirements file + stat: + path: '{{ _file_locations[ansible_test_test_command] }}/requirements.txt' + register: _extra_requirements_stat + - name: Add extra constraints.txt + when: _extra_constraints_stat.stat.exists + set_fact: + _test_requirements: '{{_test_requirements}} -c {{ _file_locations[ansible_test_test_command] }}/constraints.txt' + - name: Add extra requirements.txt + when: _extra_requirements_stat.stat.exists + set_fact: + _test_requirements: '{{_test_requirements}} -r {{ _file_locations[ansible_test_test_command] }}/requirements.txt' + - name: Install python requirements - shell: "{{ ansible_test_venv_path }}/bin/pip install -r {{ _test_location }}/requirements.txt -r {{ _test_location }}/test-requirements.txt" + shell: "{{ ansible_test_venv_path }}/bin/pip install {{ _test_requirements }}" - name: Copy potential cloud provider configuration for ansible-test in the collection shell: "cp -v {{ ansible_test_ansible_path }}/test/integration/cloud-config-*.ini {{ _test_location }}/tests/integration/"