aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gauld <ag1282@att.com>2018-02-21 16:45:51 -0500
committerAndrew Gauld <ag1282@att.com>2018-02-22 08:37:35 -0500
commit38273b37db94c9c8e79d82e14ea7205d9c2afcd7 (patch)
treeea2015587a884a9effe82795b8961747c12da5d0
parente0117d81950cb8fdb5e56858d11fbfab6f3766a2 (diff)
Make SONAR code coverage work
Change-Id: I8bd9ca4661ec8821c3fadd28c860791325ef8b36 Issue-ID: DCAEGEN2-355 Signed-off-by: Andrew Gauld <ag1282@att.com>
-rw-r--r--.coveragerc4
-rwxr-xr-xmvn-phase-script.sh11
-rw-r--r--pom.xml7
-rw-r--r--tox.ini4
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.
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <!-- sonar -->
- <sonar.skip>false</sonar.skip>
<sonar.sources>.</sonar.sources>
+ <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath>
+ <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath>
<sonar.language>py</sonar.language>
<sonar.pluginname>python</sonar.pluginname>
- <sonar.inclusions>config_binding_service/**.py</sonar.inclusions>
+ <sonar.inclusions>**/**.py</sonar.inclusions>
+ <sonar.exclusions>tests/*,setup.py</sonar.exclusions>
</properties>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
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