From b162a69c8b085592c8c6537fce50c78cf92e4555 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 23 May 2018 14:11:49 -0700 Subject: [PATCH] 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 --- .../defaults/main.yaml | 1 + roles/fetch-javascript-output/tasks/main.yaml | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/roles/fetch-javascript-output/defaults/main.yaml b/roles/fetch-javascript-output/defaults/main.yaml index 788c31bb7..f638ecb9e 100644 --- a/roles/fetch-javascript-output/defaults/main.yaml +++ b/roles/fetch-javascript-output/defaults/main.yaml @@ -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/" diff --git a/roles/fetch-javascript-output/tasks/main.yaml b/roles/fetch-javascript-output/tasks/main.yaml index a2febd117..13416cb2a 100644 --- a/roles/fetch-javascript-output/tasks/main.yaml +++ b/roles/fetch-javascript-output/tasks/main.yaml @@ -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