Skip to content

Commit

Permalink
Add test command specific pip requirements/constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Jul 16, 2021
1 parent 496afce commit 3a01bf7
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion roles/ansible-test/tasks/init_collection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down

0 comments on commit 3a01bf7

Please sign in to comment.