diff --git a/roles/tox-siblings/tasks/main.yaml b/roles/tox-siblings/tasks/main.yaml index 495bcbf8b..fe7b1757a 100644 --- a/roles/tox-siblings/tasks/main.yaml +++ b/roles/tox-siblings/tasks/main.yaml @@ -1,19 +1,3 @@ -- name: Require tox_envlist variable - fail: - msg: tox_envlist is required for this role - when: tox_envlist is not defined - -- name: Run tox without tests - command: "{{ tox_executable }} --notest -e{{ tox_envlist }}" - args: - chdir: "{{ zuul_work_dir }}" - when: tox_install_siblings - -# TODO(mordred) handle tox_envlist being a list -- name: Install any sibling python packages - tox_install_sibling_packages: - tox_envlist: "{{ tox_envlist }}" - tox_constraints_file: "{{ tox_constraints_file | default(omit) }}" - project_dir: "{{ zuul_work_dir }}" - projects: "{{ zuul.projects | selectattr('required') | list }}" +- name: Install tox siblings + include: siblings.yaml when: tox_install_siblings diff --git a/roles/tox-siblings/tasks/siblings.yaml b/roles/tox-siblings/tasks/siblings.yaml new file mode 100644 index 000000000..0aa391a87 --- /dev/null +++ b/roles/tox-siblings/tasks/siblings.yaml @@ -0,0 +1,38 @@ +- name: Require tox_envlist variable + fail: + msg: tox_envlist is required for this role + when: tox_envlist is not defined + +- name: Check to see if the constraints file exists + stat: + path: "{{ tox_constraints_file }}" + get_checksum: false + get_mime: false + get_md5: false + register: stat_results + when: tox_constraints_file is defined + +- name: Fail if constraints file is missing + when: tox_constraints_file is defined and not stat_results.stat.exists + fail: + msg: tox_constraints_file is defined but was not found + +- name: Record file location + set_fact: + tox_constraints_env: + UPPER_CONSTRAINTS_FILE: "{{ tox_constraints_file }}" + when: tox_constraints_file is defined + +- name: Run tox without tests + command: "{{ tox_executable }} --notest -e{{ tox_envlist }}" + args: + chdir: "{{ zuul_work_dir }}" + environment: "{{ tox_environment|combine(tox_constraints_env|default({})) }}" + +# TODO(mordred) handle tox_envlist being a list +- name: Install any sibling python packages + tox_install_sibling_packages: + tox_envlist: "{{ tox_envlist }}" + tox_constraints_file: "{{ tox_constraints_file | default(omit) }}" + project_dir: "{{ zuul_work_dir }}" + projects: "{{ zuul.projects | selectattr('required') | list }}"