zuul-jobs/roles/fetch-tox-output/tasks/main.yaml
Tristan Cacqueray 56ee80234c fetch-tox-output: introduce zuul_use_fetch_output
This change enables using fetch-tox role along with
the fetch-output role. By default the role still synchronizes
artifacts back to the executor.

Change-Id: Iffe5ffc52ee4c765b2e23ab8b3235b6bc7c510d8
2020-01-13 21:13:55 +00:00

62 lines
1.6 KiB
YAML

- name: Set tox log path for multiple nodes
set_fact:
log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox"
when: groups['all'] | length > 1
- name: Set tox log path for single node
set_fact:
log_path: "{{ zuul.executor.log_root }}/tox"
when: log_path is not defined
- name: Ensure local tox dir
file:
path: "{{ log_path }}"
state: directory
delegate_to: localhost
- name: Ensure zuul-output tox dir
file:
path: "{{ zuul_output_dir }}/logs/tox"
state: directory
when: zuul_use_fetch_output
- name: Set envlist fact
set_fact:
envlist: "{{ tox_envlist.split(',') }}"
when: tox_envlist is defined
- name: Find all environments
command: tox -l
args:
chdir: "{{ zuul_work_dir }}"
register: tox_environments
when: tox_envlist is not defined or tox_envlist|lower == 'all'
- name: Set envlist fact
set_fact:
envlist: "{{ tox_environments.stdout_lines }}"
when: tox_envlist is not defined or tox_envlist|lower == 'all'
- name: Copy tox logs
copy:
dest: "{{ zuul_output_dir }}/logs/tox/"
src: "{{ zuul_work_dir }}/.tox/{{ item }}/log/"
remote_src: true
with_items: "{{ envlist }}"
# some tox runs may not create a virtualenv and thus have
# no ./tox/env directory
failed_when: false
when: zuul_use_fetch_output
- name: Collect tox logs
synchronize:
dest: "{{ log_path }}"
mode: pull
src: "{{ zuul_work_dir }}/.tox/{{ item }}/log/"
verify_host: true
with_items: "{{ envlist }}"
# some tox runs may not create a virtualenv and thus have
# no ./tox/env directory
failed_when: false
when: not zuul_use_fetch_output