diff --git a/playbooks/tox/pre.yaml b/playbooks/tox/pre.yaml index fde7f6155..69e7def02 100644 --- a/playbooks/tox/pre.yaml +++ b/playbooks/tox/pre.yaml @@ -1,5 +1,3 @@ - hosts: all roles: - ensure-tox - - role: tox-siblings - when: tox_install_siblings diff --git a/roles/tox-siblings/README.rst b/roles/tox-siblings/README.rst deleted file mode 100644 index e7277a5c0..000000000 --- a/roles/tox-siblings/README.rst +++ /dev/null @@ -1,29 +0,0 @@ -Installs python packages from other Zuul repos into a tox environment. - -**Role Variables** - -.. zuul:rolevar:: zuul_workdir - :default: {{ zuul.project.src_dir }} - - Directory to run tox in. - -.. zuul:rolevar:: tox_envlist - :default: venv - - Which tox environment to run. Defaults to 'venv'. - -.. zuul:rolevar:: tox_executable - :default: tox - - Location of the tox executable. Defaults to 'tox'. - -.. zuul:rolevar:: tox_constraints_file - - Path to a pip constraints file. Will be provided to pip via '-c' - argument for any sibling package installations. - -.. zuul:rolevar:: tox_install_siblings - :default: true - - Flag controlling whether to attempt to install python packages from any - other source code repos zuul has checked out. Defaults to True. diff --git a/roles/tox-siblings/defaults/main.yaml b/roles/tox-siblings/defaults/main.yaml deleted file mode 100644 index dded4aec3..000000000 --- a/roles/tox-siblings/defaults/main.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -tox_envlist: venv -tox_executable: tox -tox_install_siblings: true - -zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/tox-siblings/tasks/main.yaml b/roles/tox-siblings/tasks/main.yaml index fe7b1757a..d9091c52b 100644 --- a/roles/tox-siblings/tasks/main.yaml +++ b/roles/tox-siblings/tasks/main.yaml @@ -1,3 +1,3 @@ -- name: Install tox siblings - include: siblings.yaml - when: tox_install_siblings +- name: Emit warning message + debug: + msg: tox-siblings is no longer needed and should be removed diff --git a/roles/tox-siblings/tasks/siblings.yaml b/roles/tox-siblings/tasks/siblings.yaml deleted file mode 100644 index 0aa391a87..000000000 --- a/roles/tox-siblings/tasks/siblings.yaml +++ /dev/null @@ -1,38 +0,0 @@ -- 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 }}" diff --git a/roles/tox/README.rst b/roles/tox/README.rst index cf1921e80..40932402b 100644 --- a/roles/tox/README.rst +++ b/roles/tox/README.rst @@ -26,6 +26,12 @@ Runs tox for a project Path to a pip constraints file. Will be provided to tox via UPPER_CONSTRAINTS_FILE environment variable if it exists. +.. zuul:rolevar:: tox_install_siblings + :default: true + + Flag controlling whether to attempt to install python packages from any + other source code repos zuul has checked out. Defaults to True. + .. zuul:rolevar:: zuul_work_dir :default: {{ zuul.project.src_dir }} diff --git a/roles/tox/defaults/main.yaml b/roles/tox/defaults/main.yaml index f4b08abd2..1178db533 100644 --- a/roles/tox/defaults/main.yaml +++ b/roles/tox/defaults/main.yaml @@ -3,5 +3,6 @@ tox_environment: {} tox_envlist: venv tox_executable: tox tox_extra_args: -vv +tox_install_siblings: true zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/tox-siblings/library/tox_install_sibling_packages.py b/roles/tox/library/tox_install_sibling_packages.py similarity index 100% rename from roles/tox-siblings/library/tox_install_sibling_packages.py rename to roles/tox/library/tox_install_sibling_packages.py diff --git a/roles/tox/tasks/main.yaml b/roles/tox/tasks/main.yaml index fe899037b..b1f464fb8 100644 --- a/roles/tox/tasks/main.yaml +++ b/roles/tox/tasks/main.yaml @@ -5,18 +5,27 @@ - name: Check to see if the constraints file exists stat: - path: "{{ tox_constraints_file|default('missing') }}" + 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: not stat_results|skipped and stat_results.stat.exists + when: tox_constraints_file is defined + +- name: Install tox siblings + include: siblings.yaml + when: tox_install_siblings - name: Emit tox command debug: diff --git a/roles/tox/tasks/siblings.yaml b/roles/tox/tasks/siblings.yaml new file mode 100644 index 000000000..84c43cd73 --- /dev/null +++ b/roles/tox/tasks/siblings.yaml @@ -0,0 +1,13 @@ +- 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 }}"