| - name: Ensure pycobertura is available |
| pip: |
| name: pycobertura |
| extra_args: --user |
| |
| - 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 |
| |
| - name: Retrieve coverage from parent jobs |
| get_url: |
| url: "{{ item.url }}" |
| dest: "{{ ansible_user_dir }}/new/coverage.xml" |
| when: |
| - item.metadata is defined |
| - item.metadata.type is defined |
| - item.metadata.type == "cobertura_xml" |
| loop: "{{ zuul.artifacts }}" |
| |
| - name: Generate pycobertura report |
| shell: | |
| 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" |
| 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" |
| 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" |