Fix coverage job gate

Change-Id: I9d4fa6dfdda21b2cfae568cff044b515f3b56705
This commit is contained in:
zhurong 2016-11-02 10:40:18 +08:00
parent 86f3966ee7
commit f8815cdd50
1 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
#
# Copyright 2015: Mirantis Inc.
# All Rights Reserved.
@ -28,7 +28,7 @@ uncommited=$(git status --porcelain | grep -v "^??")
git checkout HEAD^
baseline_report=$(mktemp -t murano_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --coverage-package-name=muranopkgcheck --testr-args="$*"
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
coverage report > $baseline_report
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
@ -38,20 +38,28 @@ git checkout -
# Generate and save coverage report
current_report=$(mktemp -t murano_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --coverage-package-name=muranopkgcheck --testr-args="$*"
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
coverage report > $current_report
current_missing=$(awk 'END { print $3 }' $current_report)
baseline_percentage=$(awk 'END { print $6 }' $baseline_report)
current_percentage=$(awk 'END { print $6 }' $current_report)
# Show coverage details
allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING))
echo "Baseline report: $(cat ${baseline_report})"
echo "Proposed change report: $(cat ${current_report})"
echo ""
echo ""
echo "Allowed to introduce missing lines : ${ALLOWED_EXTRA_MISSING}"
echo "Missing lines in master : ${baseline_missing}"
echo "Missing lines in proposed change : ${current_missing}"
echo "Current percentage : ${baseline_percentage}"
echo "Proposed change percentage : ${current_percentage}"
if [ $allowed_missing -gt $current_missing ];
if [[ $allowed_missing -gt $current_missing ]];
then
if [ $baseline_missing -lt $current_missing ];
if [[ $baseline_missing -lt $current_missing ]];
then
show_diff $baseline_report $current_report
echo "I believe you can cover all your code with 100% coverage!"