From 38273b37db94c9c8e79d82e14ea7205d9c2afcd7 Mon Sep 17 00:00:00 2001 From: Andrew Gauld Date: Wed, 21 Feb 2018 16:45:51 -0500 Subject: Make SONAR code coverage work Change-Id: I8bd9ca4661ec8821c3fadd28c860791325ef8b36 Issue-ID: DCAEGEN2-355 Signed-off-by: Andrew Gauld --- .coveragerc | 4 ---- mvn-phase-script.sh | 11 +++++++---- pom.xml | 7 ++++--- tox.ini | 4 +++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.coveragerc b/.coveragerc index fdedea1..10793c3 100644 --- a/.coveragerc +++ b/.coveragerc @@ -23,7 +23,3 @@ exclude_lines = if __name__ == .__main__.: ignore_errors = True - -[xml] -output = coverage-reports/coverage-configbinding.xml - diff --git a/mvn-phase-script.sh b/mvn-phase-script.sh index abfa93c..ae1fd65 100755 --- a/mvn-phase-script.sh +++ b/mvn-phase-script.sh @@ -19,8 +19,11 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. +set -e + echo "running script: [$0] for module [$1] at stage [$2]" +export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml} MVN_PROJECT_MODULEID="$1" MVN_PHASE="$2" @@ -99,7 +102,7 @@ expand_templates() KEY=$(echo "$TEMPLATE" | cut -f1 -d'=') VALUE=$(echo "$TEMPLATE" | cut -f2 -d'=') VALUE2=$(echo "$TEMPLATE" | cut -f2 -d'=' |sed 's/\//\\\//g') - FILES=$(grep -rl "$KEY") + FILES=$(grep -rl "$KEY" .) # assuming FILES is not longer than 2M bytes, the limit for variable value max size on this VM for F in $FILES; do @@ -114,8 +117,8 @@ expand_templates() #if [ ! -z "$FILES" ]; then # echo "====> Resolving template $VALUE to value $VALUE" - # #CMD="grep -rl \"$VALUE\" | tr '\n' '\0' | xargs -0 sed -i \"s/{{[[:space:]]*$VALUE[[:space:]]*}}/$VALUE/g\"" - # grep -rl "$KEY" | tr '\n' '\0' | xargs -0 sed -i 's/$KEY/$VALUE2/g' + # #CMD="grep -rl \"$VALUE\" . | tr '\n' '\0' | xargs -0 sed -i \"s/{{[[:space:]]*$VALUE[[:space:]]*}}/$VALUE/g\"" + # grep -rl "$KEY" | tr '\n' '\0' . | xargs -0 sed -i 's/$KEY/$VALUE2/g' # #echo $CMD # #eval $CMD #fi @@ -216,7 +219,7 @@ upload_wagons_and_type_yamls() for WAGON in "${WAGONS[@]}" ; do WAGON_NAME=$(echo "$WAGON" | cut -f1 -d '-') WAGON_VERSION=$(echo "$WAGON" | cut -f2 -d '-') - WAGON_TYPEFILE=$(grep -rl "$WAGON_NAME" | grep yaml | head -1) + WAGON_TYPEFILE=$(grep -rl "$WAGON_NAME" . | grep yaml | head -1) upload_raw_file "$WAGON" upload_raw_file "$WAGON_TYPEFILE" diff --git a/pom.xml b/pom.xml index 53ec939..a007a46 100644 --- a/pom.xml +++ b/pom.xml @@ -33,12 +33,13 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. http://maven.apache.org UTF-8 - - false . + xunit-results.xml + coverage.xml py python - config_binding_service/**.py + **/**.py + tests/*,setup.py ${project.artifactId}-${project.version} diff --git a/tox.ini b/tox.ini index 33a528b..e536a47 100644 --- a/tox.ini +++ b/tox.ini @@ -11,5 +11,7 @@ deps= setenv = CONSUL_HOST = 8.8.8.8 HOSTNAME = config_binding_service + PYTHONPATH={toxinidir} commands= - pytest --verbose --cov config_binding_service --cov-report=xml --cov-report=term tests + -pytest --junitxml xunit-results.xml --cov config_binding_service --cov-report xml + coverage xml -- cgit 1.2.3-korg