[CI] Fix coverage job
Changes: * start using pytest-cov library * if there are uncommitted changes then do not try to stash them automatically but exit with error message Co-Authored-By: Andrey Kurilin <andr.kurilin@gmail.com> Co-Authored-By: Alexander Maretskiy <amaretskiy@mirantis.com> Change-Id: Id5f396550a600fe0ab899b09aceff60b3d98dc0e
This commit is contained in:
parent
5b0bd5f167
commit
57ca3f43d1
@ -6,3 +6,6 @@ source = rally
|
||||
ignore_errors = True
|
||||
precision = 3
|
||||
omit = */migrations/versions/ca3626f62937_init_migration.py
|
||||
|
||||
[html]
|
||||
directory = cover
|
||||
|
@ -3,6 +3,7 @@
|
||||
# process, which may cause wedges in the gate later.
|
||||
hacking<0.10,>=0.9.2
|
||||
pytest>=2.7
|
||||
pytest-cov>=2.2.1
|
||||
pytest-html
|
||||
|
||||
coverage>=3.6 # Apache-2.0
|
||||
|
@ -22,24 +22,28 @@ show_diff () {
|
||||
diff -U 0 $1 $2 | sed 1,2d
|
||||
}
|
||||
|
||||
# Stash uncommitted changes, checkout master and save coverage report
|
||||
uncommited=$(git status --porcelain | grep -v "^??")
|
||||
[[ -n $uncommited ]] && git stash > /dev/null
|
||||
if ! git diff --exit-code || ! git diff --cached --exit-code
|
||||
then
|
||||
echo "There are uncommited changes!"
|
||||
echo "Please clean git working directory and try again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checkout master and save coverage report
|
||||
git checkout HEAD^
|
||||
|
||||
baseline_report=$(mktemp -t rally_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
|
||||
py.test --cov=rally tests/unit/ --cov-report=html
|
||||
coverage report > $baseline_report
|
||||
mv cover cover-master
|
||||
cat $baseline_report
|
||||
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
|
||||
|
||||
# Checkout back and unstash uncommitted changes (if any)
|
||||
# Checkout back and save coverage report
|
||||
git checkout -
|
||||
[[ -n $uncommited ]] && git stash pop > /dev/null
|
||||
|
||||
# Generate and save coverage report
|
||||
current_report=$(mktemp -t rally_coverageXXXXXXX)
|
||||
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
|
||||
py.test --cov=rally tests/unit/ --cov-report=html
|
||||
coverage report > $current_report
|
||||
current_missing=$(awk 'END { print $3 }' $current_report)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user