Use Ansible's features for "new sources" preparation
Change-Id: I33f47c65f2bb609798fee8df7f700b3dad3e46d3
diff --git a/roles/pycobertura-diff/tasks/main.yaml b/roles/pycobertura-diff/tasks/main.yaml
index 64726eb..444d525 100644
--- a/roles/pycobertura-diff/tasks/main.yaml
+++ b/roles/pycobertura-diff/tasks/main.yaml
@@ -1,17 +1,17 @@
+- name: Place for new version of sources
+ file:
+ path: "{{ new_source_prefix }}"
+ state: directory
+
- name: Prepare copy of the new version of sources
- shell: |
- set -ex
- NEW_WORK={{ ansible_user_dir }}/new
- mkdir "${NEW_WORK}"
- NEW_SRCDIR=${NEW_WORK}/{{ zuul.project.short_name }}
- pushd {{ zuul.project.src_dir }}
- git worktree add "${NEW_SRCDIR}" {{ zuul.branch }}
- popd
+ command: git worktree add {{ new_source_prefix }}/{{ zuul.project.short_name }} {{ zuul.branch }}
+ args:
+ chdir: "{{ zuul.project.src_dir }}"
- name: Retrieve coverage from parent jobs
get_url:
url: "{{ item.url }}"
- dest: "{{ ansible_user_dir }}/new/coverage.xml"
+ dest: "{{ new_source_prefix }}/coverage.xml"
when:
- item.metadata is defined
- item.metadata.type is defined
@@ -23,9 +23,9 @@
set -ex
PATH=${PATH}:~/.local/bin
pycobertura show --format html --output "{{ ansible_user_dir }}/zuul-output/logs/coverage.html" \
- --source "{{ ansible_user_dir }}/new/{{ zuul.project.short_name }}" "{{ ansible_user_dir }}/new/coverage.xml"
+ --source "{{ new_source_prefix }}/{{ zuul.project.short_name }}" "{{ new_source_prefix }}/coverage.xml"
pycobertura diff --format html --output "{{ ansible_user_dir }}/zuul-output/logs/coverage-diff.html" \
--source1 "{{ zuul.project.src_dir }}" "{{ coverage_xml_dir }}/coverage.xml" \
- --source2 "{{ ansible_user_dir }}/new/{{ zuul.project.short_name }}" "{{ ansible_user_dir }}/new/coverage.xml"
+ --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"
diff --git a/zuul.yaml b/zuul.yaml
index cf2f5a6..9524560 100644
--- a/zuul.yaml
+++ b/zuul.yaml
@@ -54,6 +54,7 @@
failure-url: coverage-diff.html
vars:
coverage_xml_dir: "{{ ansible_user_dir }}/build"
+ new_source_prefix: "{{ ansible_user_dir }}/new"
- job:
name: f29-gcc-asan