Register coverage HTML reports as artifacts
...so that they are nicely shown in the build job summary on Zuul build
landing page.
Change-Id: I6033e0156459462fba743fc098b66f038c12eafe
diff --git a/roles/pycobertura-diff/tasks/main.yaml b/roles/pycobertura-diff/tasks/main.yaml
index 0d5bbe9..418b273 100644
--- a/roles/pycobertura-diff/tasks/main.yaml
+++ b/roles/pycobertura-diff/tasks/main.yaml
@@ -9,3 +9,37 @@
--source2 "{{ new_source_prefix }}/{{ zuul.project.short_name }}" "{{ new_source_prefix }}/coverage.xml"
sed -e 's;^ </body>$; <p>Show <a href="coverage.html">final coverage</a> only</p>\n </body>;' \
-i "{{ ansible_user_dir }}/zuul-output/logs/coverage-diff.html"
+
+- name: Check for coverage-diff.html
+ stat:
+ path: "{{ ansible_user_dir }}/zuul-output/logs/coverage-diff.html"
+ get_checksum: false
+ get_mime: false
+ get_md5: false
+ register: coverage_diff_html_stat
+
+- name: Check for coverage.html
+ stat:
+ path: "{{ ansible_user_dir }}/zuul-output/logs/coverage.html"
+ get_checksum: false
+ get_mime: false
+ get_md5: false
+ register: coverage_html_stat
+
+- name: Register coverage reports as artifacts
+ when: coverage_html_stat.stat.exists
+ zuul_return:
+ data:
+ zuul:
+ artifacts:
+ - name: "Full coverage report"
+ url: "coverage.html"
+
+- name: Register coverage reports as artifacts
+ when: coverage_diff_html_stat.stat.exists
+ zuul_return:
+ data:
+ zuul:
+ artifacts:
+ - name: "Change of code coverage report"
+ url: "coverage-diff.html"