Use three separate jobs for code coverage diffing
Reusable roles and playbooks are quite important upstream (I have
zuul-jobs inclusion in mind). Besides that, in Zuul's Ansible a playbook
is supposed to come from the same repo as the one where the job
definition is placed, and one can only override a job's `run` playbook.
This makes it rather annoying to modify, say, `tox-coverage` definition.
My previous approach with a job which performed two things (build the
old source *and* then generate coverage report) also would not scale
that well if the build+test phase is long.
Switch to three jobs:
- build the current, proposed state, and gather coverage info,
- build the past state, gather coverage info,
- download two artifacts from previous runs, reproduce the source trees,
and generate the final coverage diff report.
See-also: https://review.gerrithub.io/c/Telecominfraproject/oopt-zuul-jobs/+/489964
Change-Id: I6eb61669c6f28440a55ba08569a4f2683513a9fa
diff --git a/playbooks/coverage-diff/checkout-previous.yaml b/playbooks/coverage-diff/checkout-previous.yaml
new file mode 100644
index 0000000..330adce
--- /dev/null
+++ b/playbooks/coverage-diff/checkout-previous.yaml
@@ -0,0 +1,3 @@
+- hosts: all
+ roles:
+ - git-use-previous-commit
diff --git a/playbooks/coverage-diff/pre.yaml b/playbooks/coverage-diff/pre.yaml
deleted file mode 100644
index 190ac26..0000000
--- a/playbooks/coverage-diff/pre.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- hosts: all
- roles:
- - ensure-pycobertura
- - git-use-previous-commit
- - download-next-coverage
diff --git a/playbooks/coverage-diff/prepare.yaml b/playbooks/coverage-diff/prepare.yaml
new file mode 100644
index 0000000..94e9198
--- /dev/null
+++ b/playbooks/coverage-diff/prepare.yaml
@@ -0,0 +1,12 @@
+- hosts: all
+ roles:
+ - ensure-pycobertura
+ - prepare-previous-src
+ - name: download-coverage
+ vars:
+ job_name: '{{ coverage_job_name_previous }}'
+ coverage_destination: '{{ ansible_user_dir }}/coverage-previous.xml'
+ - name: download-coverage
+ vars:
+ job_name: '{{ coverage_job_name_current }}'
+ coverage_destination: '{{ ansible_user_dir }}/coverage-current.xml'
diff --git a/playbooks/coverage-diff/upload-diff.yaml b/playbooks/coverage-diff/upload-diff.yaml
new file mode 100644
index 0000000..a71d814
--- /dev/null
+++ b/playbooks/coverage-diff/upload-diff.yaml
@@ -0,0 +1,3 @@
+- hosts: all
+ roles:
+ - fetch-coverage-diff
diff --git a/playbooks/coverage-diff/upload.yaml b/playbooks/coverage-diff/upload-one-report.yaml
similarity index 100%
rename from playbooks/coverage-diff/upload.yaml
rename to playbooks/coverage-diff/upload-one-report.yaml