From 5e3d0bca53eebb79d4e8b993c4cbd4fe753c66db Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Wed, 31 Jul 2019 19:41:28 +0200 Subject: [PATCH] fetch-subunit-output: collect additional subunit files In addition to the main subunit file from zuul_work_dir, collect the subunit files from the elements (directories) of the zuul_additional_subunit_dirs list. The default behavior is unchanged. Change-Id: Ic3bc76aa104951bcc0c186347196067342e28751 --- roles/fetch-subunit-output/README.rst | 7 +++++++ roles/fetch-subunit-output/defaults/main.yaml | 1 + roles/fetch-subunit-output/tasks/main.yaml | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/roles/fetch-subunit-output/README.rst b/roles/fetch-subunit-output/README.rst index 283b1d786..2540dbfb0 100644 --- a/roles/fetch-subunit-output/README.rst +++ b/roles/fetch-subunit-output/README.rst @@ -7,6 +7,13 @@ Collect subunit outputs Directory to work in. It has to be a fully qualified path. +.. zuul:rolevar:: zuul_additional_subunit_dirs + :default: [] + + List of additional directories which contains subunit files + to collect. The content of zuul_work_dir is always checked, + so it should not be added here. + .. zuul:rolevar:: tox_envlist tox environment that was used to run the tests originally. diff --git a/roles/fetch-subunit-output/defaults/main.yaml b/roles/fetch-subunit-output/defaults/main.yaml index 8cc97ff70..96c12e1dc 100644 --- a/roles/fetch-subunit-output/defaults/main.yaml +++ b/roles/fetch-subunit-output/defaults/main.yaml @@ -1,3 +1,4 @@ --- tox_envlist: "" +zuul_additional_subunit_dirs: [] zuul_work_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" diff --git a/roles/fetch-subunit-output/tasks/main.yaml b/roles/fetch-subunit-output/tasks/main.yaml index 496ed7d43..1365a9402 100644 --- a/roles/fetch-subunit-output/tasks/main.yaml +++ b/roles/fetch-subunit-output/tasks/main.yaml @@ -9,10 +9,21 @@ - testr_command.rc == 0 - testr_command.stdout_lines block: + - name: Get the list of directories with subunit files + set_fact: + subunit_dirs: "{{ [ zuul_work_dir ] + zuul_additional_subunit_dirs }}" - name: Generate subunit file shell: - cmd: "{{ testr_command.stdout_lines[0] }} last --subunit > ./testrepository.subunit" + cmd: "{{ testr_command.stdout_lines[0] }} last --subunit > {{ ansible_user_dir }}/{{ zuul_work_dir }}/testrepository.partial.{{ '%03d'|format(subidx) }}.subunit" + chdir: "{{ item }}" + loop: "{{ subunit_dirs }}" + loop_control: + index_var: subidx + + - name: Combine the subunit files + shell: + cmd: "cat testrepository.partial.*.subunit >./testrepository.subunit" chdir: "{{ zuul_work_dir }}" - name: Process and fetch subunit results