diff --git a/ci/report_result.yml b/ci/report_result.yml index 3b44962e..e4095867 100644 --- a/ci/report_result.yml +++ b/ci/report_result.yml @@ -5,7 +5,17 @@ vars_files: - vars/common.yml tasks: + - name: Check whether the log dir exists + ansible.builtin.stat: + path: "{{ logs_dir }}" + register: stat_out + + - name: show whetehr the log dir exists + ansible.builtin.debug: + var: stat_out + - name: Create log dir + when: not stat_out.stat.exists ansible.builtin.file: path: "{{ logs_dir }}" state: directory @@ -34,10 +44,20 @@ msg: "There were no XML files found in {{ logs_dir }}." when: verbose_matches.stdout_lines | length == 0 + - name: "Get the number of testcase errors" + ansible.builtin.set_fact: + tasks_errored: "{{ verbose_matches.stdout | regex_replace('.*errors=\"([0-9]*)\".*>', '\\1') | split('\n') | map('int') | sum }}" + - name: "Get the number of failed testcases" ansible.builtin.set_fact: tasks_failed: "{{ verbose_matches.stdout | regex_replace('.*failures=\"([0-9]*)\".*>', '\\1') | split('\n') | map('int') | sum }}" + # The RC from grep is 0 if the string is matched + - name: Fail when there's a testcase error + ansible.builtin.fail: + msg: There were {{ tasks_errored }} errors in the testcases. + when: tasks_errored | int > 0 and verbose_matches.rc == 0 + # The RC from grep is 0 if the string is matched - name: Fail when there's a testcase failure ansible.builtin.fail: