Make SONAR code coverage work 87/32587/1
authorAndrew Gauld <ag1282@att.com>
Thu, 22 Feb 2018 16:35:58 +0000 (11:35 -0500)
committerAndrew Gauld <ag1282@att.com>
Thu, 22 Feb 2018 16:36:31 +0000 (11:36 -0500)
Change-Id: I8a61f287d439a5bf0b2cb203e31b514a2cae0a5e
Issue-ID: DCAEGEN2-355
Signed-off-by: Andrew Gauld <ag1282@att.com>
13 files changed:
cdap/cdapplugin/.coveragerc
cdap/cdapplugin/tox.ini
cdap/pom.xml
dcae-policy/.coveragerc
dcae-policy/pom.xml
dcae-policy/tox.ini
docker/pom.xml
docker/tox.ini
mvn-phase-lib.sh
mvn-phase-script.sh
pom.xml
relationships/pom.xml
relationships/tox.ini

index 9d9d9a2..7e87c60 100644 (file)
@@ -23,7 +23,3 @@ exclude_lines =
     if __name__ == .__main__.:
 
 ignore_errors = True
-
-[xml]
-output = coverage-reports/coverage-cdapcloudify.xml
-
index 246851e..2f4bb03 100644 (file)
@@ -7,4 +7,8 @@ deps=
     pytest
     coverage
     pytest-cov
-commands=pytest --junitxml xunit-reports/xunit-result-cdapcloudify.xml --cov {envsitepackagesdir} --cov-report=xml
+setenv=
+    PYTHONPATH={toxinidir}
+commands=
+    pytest --junitxml xunit-results.xml --cov cdapcloudify --cov-report xml
+    coverage xml
index 3fcbb4e..e0907c5 100644 (file)
@@ -33,14 +33,13 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
   <properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-      <!-- sonar -->
-      <sonar.skip>true</sonar.skip>
       <sonar.sources>cdapplugin/</sonar.sources>
-      <sonar.junit.reportspath>cdapplugin/xunit-reports/xunit-result-cdapcloudify.xml</sonar.junit.reportspath>
-      <sonar.python.coverage.reportpath>cdapplugin/coverage-reports/coverage-cdapcloudify.xml</sonar.python.coverage.reportpath>
+      <sonar.junit.reportspath>cdapplugin/xunit-results.xml</sonar.junit.reportspath>
+      <sonar.python.coverage.reportpath>cdapplugin/coverage.xml</sonar.python.coverage.reportpath>
       <sonar.language>py</sonar.language>
-      <sonar.pluginname>python</sonar.pluginname>
-      <sonar.inclusions>*/cdapcloudify/**.py</sonar.inclusions>
+      <sonar.pluginname>Python</sonar.pluginname>
+      <sonar.inclusions>cdapcloudify/**/*.py</sonar.inclusions>
+      <sonar.exclusions>cdapcloudify/test/*,cdapcloudify/setup.py</sonar.exclusions>
   </properties>
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
index 2e600b5..eba9bd0 100644 (file)
@@ -23,7 +23,3 @@ exclude_lines =
     if __name__ == .__main__.:
 
 ignore_errors = True
-
-[xml]
-output = coverage-reports/coverage-dcaepolicyplugin.xml
-
index a96f6d2..5f96122 100644 (file)
@@ -32,21 +32,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.skip>true</sonar.skip>
     <sonar.sources>.</sonar.sources>
-    <!-- customize the SONARQUBE URL -->
-    <!-- sonar.host.url>http://localhost:9000</sonar.host.url -->
-    <!-- below are language dependent -->
-    <!-- for Python -->
+    <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>**/*.py</sonar.inclusions>
-    <!-- for JavaScaript -->
-    <!--
-    <sonar.language>js</sonar.language>
-    <sonar.pluginName>JS</sonar.pluginName>
-    <sonar.inclusions>**/*.js</sonar.inclusions>
-    -->
+    <sonar.exclusions>tests/*,setup.py</sonar.exclusions>
   </properties>
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
index b78ba54..40caed5 100644 (file)
@@ -11,5 +11,7 @@ deps=
     pytest-cov
 setenv =
     PYTHONPATH={toxinidir}
-# recreate = True
-commands=pytest --junitxml xunit-reports/xunit-result-dcaepolicyplugin.xml --cov dcaepolicyplugin --cov-report=xml
+commands=
+  -mkdir logs
+  pytest --junitxml xunit-results.xml --cov dcaepolicyplugin --cov-report xml
+  coverage xml
index be11078..ebe2f26 100644 (file)
@@ -32,21 +32,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.skip>true</sonar.skip>
     <sonar.sources>.</sonar.sources>
-    <!-- customize the SONARQUBE URL -->
-    <!-- sonar.host.url>http://localhost:9000</sonar.host.url -->
-    <!-- below are language dependent -->
-    <!-- for Python -->
+    <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>**/*.py</sonar.inclusions>
-    <!-- for JavaScaript -->
-    <!--
-    <sonar.language>js</sonar.language>
-    <sonar.pluginName>JS</sonar.pluginName>
-    <sonar.inclusions>**/*.js</sonar.inclusions>
-    -->
+    <sonar.exclusions>tests/*,setup.py</sonar.exclusions>
   </properties>
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
index 91f7dc6..5fad68b 100644 (file)
@@ -8,4 +8,8 @@ deps=
     pytest
     coverage
     pytest-cov
-commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir}/dockerplugin
+setenv=
+    PYTHONPATH={toxinidir}
+commands=
+  pytest --junitxml xunit-results.xml --cov dockerplugin --cov-report xml
+  coverage xml
index 3a41708..a44a206 100755 (executable)
@@ -52,10 +52,7 @@ if [ -z "$WORKSPACE" ]; then
     WORKSPACE=$(pwd)
 fi
 
-if [ -z "$SETTINGS_FILE" ]; then
-    echo "SETTINGS_FILE environment variable not set.  Cannot proceed"
-    exit
-fi
+export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml}
 
 
 
@@ -144,7 +141,7 @@ expand_templates()
     VALUE=$(echo "$TEMPLATE" | cut -f2 -d'=')
     VALUE2=$(echo "$TEMPLATE" | cut -f2 -d'=' |sed 's/\//\\\//g')
     set +e
-    FILES=$(grep -rl "$KEY")
+    FILES=$(grep -rl "$KEY" .)
     set -e
 
     if [ -z "$FILES" ]; then
@@ -167,8 +164,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
index 0978017..519e809 100755 (executable)
@@ -58,10 +58,7 @@ if [ -z "$WORKSPACE" ]; then
     WORKSPACE=$(pwd)
 fi
 
-if [ -z "$SETTINGS_FILE" ]; then
-    echo "SETTINGS_FILE environment variable not set.  Cannot proceed"
-    exit
-fi
+export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml}
    
 
 
@@ -105,6 +102,7 @@ compile)
   ;;
 test)
   echo "==> test phase script"
+  run_tox_test
   ;;
 package)
   echo "==> package phase script"
diff --git a/pom.xml b/pom.xml
index 6b3abba..878f538 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,10 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
     <!-- properties for Pypi server -->
     <onap.nexus.pypiserver.baseurl>https://nexus3.onap.org/repository/PyPi</onap.nexus.pypiserver.baseurl>
     <onap.nexus.pypiserver.serverid>onap-pypi</onap.nexus.pypiserver.serverid>
+    <!-- customize the SONARQUBE URL -->
+    <sonar.host.url>http://localhost:9000</sonar.host.url>
+    <!-- taken care of in the children -->
+    <sonar.exclusions>**/*.py</sonar.exclusions>
   </properties>
   <build>
     <pluginManagement>
index aba8619..4a1ef79 100644 (file)
@@ -32,21 +32,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.skip>true</sonar.skip>
     <sonar.sources>.</sonar.sources>
-    <!-- customize the SONARQUBE URL -->
-    <!-- sonar.host.url>http://localhost:9000</sonar.host.url -->
-    <!-- below are language dependent -->
-    <!-- for Python -->
+    <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>**/*.py</sonar.inclusions>
-    <!-- for JavaScaript -->
-    <!--
-    <sonar.language>js</sonar.language>
-    <sonar.pluginName>JS</sonar.pluginName>
-    <sonar.inclusions>**/*.js</sonar.inclusions>
-    -->
+    <sonar.exclusions>tests/*,setup.py</sonar.exclusions>
   </properties>
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
index 5d8f4ae..a7157be 100644 (file)
@@ -8,4 +8,8 @@ deps=
     pytest
     coverage
     pytest-cov
-commands=pytest --junitxml xunit-results.xml --cov {envsitepackagesdir}/relationshipplugin --cov-report=xml
+setenv=
+  PYTHONPATH={toxinidir}
+commands=
+  pytest --junitxml xunit-results.xml --cov relationshipplugin --cov-report xml
+  coverage xml