Skip to content

Commit

Permalink
Rework requirement/constraint into a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Sep 15, 2021
1 parent 2ac8ef4 commit 842d0bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
2 changes: 2 additions & 0 deletions roles/ansible-test/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ ansible_test_network_cli_ssh_type: paramiko
ansible_test_changed: false
ansible_test_base_branch: main
ansible_test_verbosity: "-vvvv"
ansible_test_requirement_files: ['requirements.txt', 'test-requirements.txt']
ansible_test_constraint_files: []
29 changes: 3 additions & 26 deletions roles/ansible-test/tasks/init_collection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,11 @@

- 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'
_test_requirements: '{% for requirement in ansible_test_requirement_files %} -r {{ _test_location }}/{{ requirement }}{% endfor %}'
_test_constraints: '{% for constraint in ansible_test_constraint_files %} -c {{ _test_location }}/{{ constraint }}{% endfor %}'

- name: Install python requirements
shell: "{{ ansible_test_venv_path }}/bin/pip install {{ _test_requirements }}"
shell: "{{ ansible_test_venv_path }}/bin/pip install {{ _test_requirements }} {{ _test_constraints }}"

- 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
25 changes: 20 additions & 5 deletions zuul.d/ansible-cloud-jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@
ansible_test_enable_ara: false
ansible_test_python: 3.6
ansible_test_retry_on_error: true
ansible_test_requirement_files:
- requirements.txt
- test-requirements.txt
# Ansible-test picks up requirements and constraints from
# tests/integration when running in docker, mirror this
- tests/unit/requirements.txt
ansible_test_constraint_files:
- tests/unit/constraints.txt
semaphore: ansible-test-cloud-integration-aws

- job:
Expand Down Expand Up @@ -344,17 +352,24 @@
ansible_test_integration_targets: "{{ child.targets_to_test[5]|join(' ') }}"

#### units
- job:
name: ansible-test-units-community-aws-python38
parent: ansible-test-units-base-python38
vars:
ansible_collections_repo: "{{ zuul.project.canonical_name }}"

- job:
name: ansible-test-units-amazon-aws-python38
parent: ansible-test-units-base-python38
vars:
ansible_collections_repo: "{{ zuul.project.canonical_name }}"
ansible_test_requirement_files:
- requirements.txt
- test-requirements.txt
# Ansible-test picks up requirements and constraints from
# tests/integration when running in docker, mirror this
- tests/integration/requirements.txt
ansible_test_constraint_files:
- tests/integration/constraints.txt

- job:
name: ansible-test-units-community-aws-python38
parent: ansible-test-units-amazon-aws-python38

#### sanity
- job:
Expand Down

0 comments on commit 842d0bd

Please sign in to comment.