Coverage change job test
Zuul check for changes in unit test coverage. With this running we can ensure that no more code is merged without tests. At this stage, I'm proposing is a non-voting job. After a grace period, for example one sprint or two, it would become voting. Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Change-Id: If2e61c9bbf59e91163357023d16620934dc7d3a0
This commit is contained in:
parent
4d1df7b0e7
commit
2bd6c60eec
13
.zuul.yaml
13
.zuul.yaml
|
@ -27,6 +27,18 @@
|
|||
files:
|
||||
- ^requirements.txt$
|
||||
|
||||
- job:
|
||||
name: validations-libs-coverchange
|
||||
nodeset: centos-8
|
||||
parent: base
|
||||
run: playbooks/coverchange.yaml
|
||||
timeout: 1600
|
||||
voting: false
|
||||
required-projects:
|
||||
- openstack/validations-libs
|
||||
files:
|
||||
- ^validations_libs/.*
|
||||
|
||||
- job:
|
||||
name: tripleo-ci-centos-8-standalone-validation-libs
|
||||
parent: tripleo-ci-centos-8-standalone
|
||||
|
@ -42,6 +54,7 @@
|
|||
check:
|
||||
jobs:
|
||||
- validations-libs-reqcheck
|
||||
- validations-libs-coverchange
|
||||
- openstack-tox-linters
|
||||
- openstack-tox-cover
|
||||
- openstack-tox-py36
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
- hosts: all
|
||||
name: Coverage change
|
||||
roles:
|
||||
- ensure-virtualenv
|
||||
- ensure-pip
|
||||
- role: ensure-tox
|
||||
vars:
|
||||
ensure_global_symlinks: true
|
||||
tasks:
|
||||
- name: Environment setup
|
||||
shell:
|
||||
cmd: |
|
||||
set -e
|
||||
virtualenv --system-site-packages {{ ansible_user_dir }}/.venv
|
||||
args:
|
||||
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
- name: Measure coverage with the submitted change
|
||||
shell:
|
||||
cmd: |
|
||||
set -e
|
||||
source {{ ansible_user_dir }}/.venv/bin/activate
|
||||
tox -e cover | grep "TOTAL" | awk '{print $3/$2}'
|
||||
args:
|
||||
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
register: coverage_after
|
||||
- name: Checkout previous commit
|
||||
shell:
|
||||
cmd: |
|
||||
set -e
|
||||
source {{ ansible_user_dir }}/.venv/bin/activate
|
||||
git checkout HEAD^
|
||||
args:
|
||||
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
- name: Measure coverage before submitted change
|
||||
shell:
|
||||
cmd: |
|
||||
set -e
|
||||
source {{ ansible_user_dir }}/.venv/bin/activate
|
||||
tox -e cover | grep "TOTAL" | awk '{print $3/$2}'
|
||||
args:
|
||||
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
register: coverage_before
|
||||
- name: Coverage comparison - Check
|
||||
assert:
|
||||
that: "{{ (coverage_after.stdout | float) }} >= {{ (coverage_before.stdout | float) }}"
|
||||
fail_msg: |
|
||||
Before the change {{ (coverage_before.stdout | float)*100 }}% of the lines were without coverage.
|
||||
Now it's {{ (coverage_after.stdout | float )*100 }}%. Did you write your unit tests?
|
||||
success_msg: |
|
||||
Code coverage check successful, {{ (coverage_before.stdout | float) * 100 }}% of code is now covered.
|
Loading…
Reference in New Issue