6d23d20f2f
This is preparation for a later version of ansbile-lint, which finds missing names on blocks. This seems a reasonable rule, and the Ansible manual says [1] Names for blocks have been available since Ansible 2.3. We recommend using names in all tasks, within blocks or elsewhere, for better visibility into the tasks being executed when you run the playbook. This simply adds a name tag for blocks that are missing it. This should have no operational change, but allows us to update the linter in a follow-on change. [1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
94 lines
3.2 KiB
YAML
94 lines
3.2 KiB
YAML
# We're not using with_first_found because the files are remote, not local.
|
|
# We want to use stestr if it exists or fallback to testr - and we want to
|
|
# prefer files found in tox envs.
|
|
- name: Find stestr or testr executable
|
|
script: "find-testr.sh {{ zuul_work_dir }}"
|
|
register: testr_command
|
|
failed_when: false
|
|
|
|
- name: Process subunit
|
|
when:
|
|
- testr_command.rc == 0
|
|
# Here we run steps that should apply whether or not there is a valid
|
|
# subunit stream present.
|
|
block:
|
|
- name: Get the list of directories with subunit files
|
|
set_fact:
|
|
all_subunit_dirs: "{{ [ zuul_work_dir ] + fetch_subunit_output_additional_dirs }}"
|
|
|
|
# If (s)testr was stopped early (possibly due to a timeout) it will "leak"
|
|
# a tmp file of the inflight subunit stream. Collect this as it is useful
|
|
# for debugging in these situations. Because it isn't a complete file
|
|
# we don't process it further.
|
|
- name: Find any inflight partial subunit files
|
|
find:
|
|
paths:
|
|
- "{{ zj_item }}/.testrepository"
|
|
- "{{ zj_item }}/.stestr"
|
|
patterns:
|
|
- 'tmp*'
|
|
register: partial_subunit_files
|
|
loop: "{{ all_subunit_dirs }}"
|
|
loop_control:
|
|
loop_var: zj_item
|
|
|
|
# This loop is a bit convoluted because what we get from the previous
|
|
# task is a list of dicts containing a list of files. We use
|
|
# with_subelements to iterate over the list of dicts and their internal
|
|
# files lists.
|
|
- name: Copy any inflight subunit files
|
|
copy:
|
|
dest: "{{ zuul_output_dir }}/logs/"
|
|
src: "{{ zj_item.1.path }}"
|
|
remote_src: true
|
|
mode: 0644
|
|
with_subelements:
|
|
- "{{ partial_subunit_files.results }}"
|
|
- files
|
|
loop_control:
|
|
loop_var: zj_item
|
|
|
|
- name: Process subunit stream
|
|
when:
|
|
- testr_command.rc == 0
|
|
- testr_command.stdout
|
|
# Here we run steps that only apply when there is a valid subunity stream.
|
|
# This is indicated through testr_command.stdout content.
|
|
block:
|
|
# The usage an independent target file instead of sending the output
|
|
# to zuul_work_dir prevents issues related to zuul_work_dir being
|
|
# a relative path, which may happen despite what the documentation
|
|
# of this role claims.
|
|
- name: Create a temporary file to store the subunit stream
|
|
tempfile:
|
|
state: file
|
|
prefix: subunit.
|
|
register: temp_subunit_file
|
|
|
|
- name: Generate subunit file
|
|
shell:
|
|
# We use the trim filter here on all stdout because for some reason
|
|
# we occasionally get the command listed with a blank line prefix.
|
|
# This should clean that up.
|
|
cmd: "{{ testr_command.stdout | trim }} last --subunit >>{{ temp_subunit_file.path }}"
|
|
chdir: "{{ zj_item }}"
|
|
loop: "{{ all_subunit_dirs }}"
|
|
loop_control:
|
|
loop_var: zj_item
|
|
|
|
- name: Copy the combined subunit file to the zuul work directory
|
|
copy:
|
|
src: "{{ temp_subunit_file.path }}"
|
|
dest: "{{ zuul_work_dir }}/testrepository.subunit"
|
|
mode: 0644
|
|
remote_src: yes
|
|
|
|
- name: Remove the temporary file
|
|
file:
|
|
name: "{{ temp_subunit_file.path }}"
|
|
state: absent
|
|
failed_when: false
|
|
|
|
- name: Process and fetch subunit results
|
|
include_tasks: process.yaml
|