[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
|
ignore_errors = True
|
||||||
precision = 3
|
precision = 3
|
||||||
omit = */migrations/versions/ca3626f62937_init_migration.py
|
omit = */migrations/versions/ca3626f62937_init_migration.py
|
||||||
|
|
||||||
|
[html]
|
||||||
|
directory = cover
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
hacking<0.10,>=0.9.2
|
hacking<0.10,>=0.9.2
|
||||||
pytest>=2.7
|
pytest>=2.7
|
||||||
|
pytest-cov>=2.2.1
|
||||||
pytest-html
|
pytest-html
|
||||||
|
|
||||||
coverage>=3.6 # Apache-2.0
|
coverage>=3.6 # Apache-2.0
|
||||||
|
@ -22,24 +22,28 @@ show_diff () {
|
|||||||
diff -U 0 $1 $2 | sed 1,2d
|
diff -U 0 $1 $2 | sed 1,2d
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stash uncommitted changes, checkout master and save coverage report
|
if ! git diff --exit-code || ! git diff --cached --exit-code
|
||||||
uncommited=$(git status --porcelain | grep -v "^??")
|
then
|
||||||
[[ -n $uncommited ]] && git stash > /dev/null
|
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^
|
git checkout HEAD^
|
||||||
|
|
||||||
baseline_report=$(mktemp -t rally_coverageXXXXXXX)
|
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
|
coverage report > $baseline_report
|
||||||
|
mv cover cover-master
|
||||||
cat $baseline_report
|
cat $baseline_report
|
||||||
baseline_missing=$(awk 'END { print $3 }' $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 -
|
git checkout -
|
||||||
[[ -n $uncommited ]] && git stash pop > /dev/null
|
|
||||||
|
|
||||||
# Generate and save coverage report
|
|
||||||
current_report=$(mktemp -t rally_coverageXXXXXXX)
|
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
|
coverage report > $current_report
|
||||||
current_missing=$(awk 'END { print $3 }' $current_report)
|
current_missing=$(awk 'END { print $3 }' $current_report)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user