Merge "Make fetch-tox-output more resilient"

This commit is contained in:
Zuul 2017-10-01 00:54:26 +00:00 committed by Gerrit Code Review
commit c1fb3e9ed1
5 changed files with 45 additions and 14 deletions

View File

@ -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.

View File

@ -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 }}"

View File

@ -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 - name: Set tox log path for multiple nodes
set_fact: set_fact:
log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox" log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox"
@ -23,10 +14,25 @@
state: directory state: directory
delegate_to: localhost 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 - name: Collect tox logs
synchronize: synchronize:
dest: "{{ log_path }}" dest: "{{ log_path }}"
mode: pull mode: pull
src: "{{ item.path }}/log/" src: "{{ zuul_work_dir }}/.tox/{{ item }}/log/"
verify_host: true verify_host: true
with_items: "{{ result.files }}" with_items: "{{ envlist }}"

View File

@ -115,8 +115,12 @@ def main():
tox_python = '{project_dir}/.tox/{envlist}/bin/python'.format( tox_python = '{project_dir}/.tox/{envlist}/bin/python'.format(
project_dir=project_dir, envlist=envlist) project_dir=project_dir, envlist=envlist)
# Write a log file into the .tox dir so that it'll get picked up # 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) project_dir=project_dir, envlist=envlist)
log_file = '{log_dir}/{envlist}-siblings.txt'.format(
log_dir=log_dir, envlist=envlist)
log = list() log = list()
log.append( log.append(

View File

@ -9,6 +9,7 @@
chdir: "{{ zuul_work_dir }}" chdir: "{{ zuul_work_dir }}"
when: tox_install_siblings when: tox_install_siblings
# TODO(mordred) handle tox_envlist being a list
- name: Install any sibling python packages - name: Install any sibling python packages
tox_install_sibling_packages: tox_install_sibling_packages:
tox_envlist: "{{ tox_envlist }}" tox_envlist: "{{ tox_envlist }}"