Collect the coverage report for npm test jobs

The npm test run can optionally create an html coverage report.
This change causes the post job to check if the directory exists,
and if so also collect the coverage report with the npm logs.

Change-Id: I7cc50c352c3feeed283888cbe7f02c6b1264b7b0
This commit is contained in:
Michael Johnson 2018-05-23 14:11:49 -07:00
parent be339b7746
commit b162a69c8b
2 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,4 @@
zuul_work_dir: "{{ zuul.project.src_dir }}"
javascript_content_dir: dist
javascript_copy_links: true
coverage_output_src: "{{ zuul_work_dir }}/cover/"

View File

@ -1,11 +1,13 @@
- name: Set log path for multiple nodes
set_fact:
log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/npm"
cover_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/cover/"
when: groups['all'] | length > 1
- name: Set log path for single node
set_fact:
log_path: "{{ zuul.executor.log_root }}/npm"
cover_path: "{{ zuul.executor.log_root }}/cover/"
when: log_path is not defined
- name: Ensure local tox dir
@ -118,3 +120,23 @@
copy_links: "{{ javascript_copy_links }}"
verify_host: true
when: javascript_output.stat.exists
- name: Check to see if coverage report exists
stat:
path: "{{ coverage_output_src }}"
register: coverage_report_stat
- name: Ensure cover tox dir
file:
path: "{{ cover_path }}"
state: directory
delegate_to: localhost
when: coverage_report_stat.stat.exists
- name: Collect coverage details output
synchronize:
dest: "{{ cover_path }}"
mode: pull
src: "{{ coverage_output_src }}"
verify_host: true
when: coverage_report_stat.stat.exists