From 75b3fe4db0dfc958bb7a1d9211ae5734cb75dbec Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sun, 11 Sep 2016 19:30:26 +0200 Subject: [PATCH] Update coverage upload script --- .update_coverage | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.update_coverage b/.update_coverage index 7895cf4..402179c 100755 --- a/.update_coverage +++ b/.update_coverage @@ -2,24 +2,25 @@ BASEDIR="$1" PROJECT_NAME="$2" -cd "$BASEDIR/htmlcov/"; tar czf "$BASEDIR/coverage.tar.gz" ./ - - -cd "$BASEDIR" +TITLE="Coverage report of $PROJECT_NAME" # build by gitlab CI if [ -n "$CI_BUILD_REF_NAME" ]; then BRANCH="$CI_BUILD_REF_NAME" + TITLE="$TITLE, $BRANCH branch" # build by travis elif [ -n "$TRAVIS_BRANCH" ]; then # if this a pull request ? if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then BRANCH="pull-request-$TRAVIS_PULL_REQUEST" + TITLE="$TITLE, pull request n°$BRANCH" else BRANCH="$TRAVIS_BRANCH" + TITLE="$TITLE, $BRANCH branch" fi else BRANCH="$(git rev-parse --abbrev-ref HEAD)" + TITLE="$TITLE, $BRANCH branch" fi if [[ "$BRANCH" = "HEAD" ]] || [ -z "$BRANCH" ]; then @@ -27,6 +28,22 @@ if [[ "$BRANCH" = "HEAD" ]] || [ -z "$BRANCH" ]; then exit 0 fi + +VENV="$(mktemp -d)" +HTMLREPORT="$(mktemp -d)" +virtualenv "$VENV" +"$VENV/bin/pip" install coverage +"$VENV/bin/coverage" html --title "$TITLE" --directory "$HTMLREPORT" +rm -rf "$VENV" + + +cd "$HTMLREPORT"; tar czf "$BASEDIR/coverage.tar.gz" ./ + +cd "$BASEDIR" + +rm -rf "$HTMLREPORT" + + curl https://badges.genua.fr/coverage/ \ -F "secret=$COVERAGE_TOKEN" \ -F "tar=@$BASEDIR/coverage.tar.gz" \