diff --git a/roles/fetch-tox-output/README.rst b/roles/fetch-tox-output/README.rst index 7e1934b53..e12140142 100644 --- a/roles/fetch-tox-output/README.rst +++ b/roles/fetch-tox-output/README.rst @@ -1 +1,18 @@ -Collect output from a tox build +Collect log output from a tox build + +**Role Variables** + +.. zuul:rolevar:: tox_envlist + :default: all + + Which tox environment to fetch log output from. + +.. zuul:rolevar:: tox_executable + :default: tox + + Location of the tox executable. + +.. zuul:rolevar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + Directory tox was run in. diff --git a/roles/fetch-tox-output/defaults/main.yaml b/roles/fetch-tox-output/defaults/main.yaml index a0afa22c5..04d20860a 100644 --- a/roles/fetch-tox-output/defaults/main.yaml +++ b/roles/fetch-tox-output/defaults/main.yaml @@ -1,2 +1,5 @@ --- -zuul_work_dir: "src/{{ zuul.project.canonical_name }}" +tox_envlist: all +tox_executable: tox + +zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/fetch-tox-output/tasks/main.yaml b/roles/fetch-tox-output/tasks/main.yaml index 31a6d0b5a..de5278d48 100644 --- a/roles/fetch-tox-output/tasks/main.yaml +++ b/roles/fetch-tox-output/tasks/main.yaml @@ -1,12 +1,3 @@ -- name: Find tox directories to synchrionize - find: - file_type: directory - paths: "{{ zuul_work_dir }}/.tox" - # NOTE(pabelanger): The .tox/log folder is empty, ignore it. - patterns: ^(?!log).*$ - use_regex: yes - register: result - - name: Set tox log path for multiple nodes set_fact: log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox" @@ -23,10 +14,25 @@ state: directory delegate_to: localhost +- name: Set envlist fact + set_fact: + envlist: "{{ tox_envlist.split(',') }}" + when: tox_envlist is defined + +- name: Find all environments + command: tox -l + register: tox_environments + when: tox_envlist is not defined or tox_envlist == 'all' + +- name: Set envlist fact + set_fact: + envlist: "{{ tox_environments.stdout_lines }}" + when: tox_envlist is not defined or tox_envlist == 'all' + - name: Collect tox logs synchronize: dest: "{{ log_path }}" mode: pull - src: "{{ item.path }}/log/" + src: "{{ zuul_work_dir }}/.tox/{{ item }}/log/" verify_host: true - with_items: "{{ result.files }}" + with_items: "{{ envlist }}" diff --git a/roles/tox-siblings/library/tox_install_sibling_packages.py b/roles/tox-siblings/library/tox_install_sibling_packages.py index 1b9df5689..8edbfe35a 100644 --- a/roles/tox-siblings/library/tox_install_sibling_packages.py +++ b/roles/tox-siblings/library/tox_install_sibling_packages.py @@ -115,8 +115,12 @@ def main(): tox_python = '{project_dir}/.tox/{envlist}/bin/python'.format( project_dir=project_dir, envlist=envlist) # Write a log file into the .tox dir so that it'll get picked up - log_file = '{project_dir}/.tox/{envlist}/log/siblings.txt'.format( + # Name it with envlist as a prefix so that fetch-tox-output will properly + # get it in a multi-env scenario + log_dir = '{project_dir}/.tox/{envlist}/log'.format( project_dir=project_dir, envlist=envlist) + log_file = '{log_dir}/{envlist}-siblings.txt'.format( + log_dir=log_dir, envlist=envlist) log = list() log.append( diff --git a/roles/tox-siblings/tasks/main.yaml b/roles/tox-siblings/tasks/main.yaml index 006369721..f2c25c1df 100644 --- a/roles/tox-siblings/tasks/main.yaml +++ b/roles/tox-siblings/tasks/main.yaml @@ -9,6 +9,7 @@ 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 }}"