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/roles/git-use-previous-commit/tasks/main.yaml b/roles/git-use-previous-commit/tasks/main.yaml
index cb7458e..db63a97 100644
--- a/roles/git-use-previous-commit/tasks/main.yaml
+++ b/roles/git-use-previous-commit/tasks/main.yaml
@@ -1,7 +1,8 @@
- name: Prepare git submodules
shell: |
- echo "{{ item.key }}"
- git checkout -b "zuul_origin_{{ zuul.branch }}" "origin/{{ zuul.branch }}"
+ PREVIOUS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+ echo "{{ item.key }}: ${PREVIOUS_BRANCH}"
+ git checkout -b zuul_origin_${PREVIOUS_BRANCH} origin/${PREVIOUS_BRANCH}
args:
chdir: "{{ ansible_user_dir }}/{{ item.value.src_dir }}"
loop: "{{ query('dict', zuul.projects) }}"