You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/10/15 09:46:47 UTC

[jackrabbit-filevault] branch master updated: JCRVLT-475 enable Sonarcloud.io reporting (#99)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git


The following commit(s) were added to refs/heads/master by this push:
     new f785fcb  JCRVLT-475 enable Sonarcloud.io reporting (#99)
f785fcb is described below

commit f785fcb24d4cbd01c734e9273310a925c29ae15b
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Oct 15 11:46:34 2020 +0200

    JCRVLT-475 enable Sonarcloud.io reporting (#99)
---
 .travis.yml                                        |  16 +++-
 README.md                                          |   4 +
 parent/pom.xml                                     | 105 +++++++++++++++++++++
 vault-core/pom.xml                                 |  12 +--
 .../packaging/integration/IntegrationTestBase.java |  10 +-
 .../packaging/integration/TestSubPackages.java     |   3 +-
 .../src/test/resources/logback-only-errors.xml     |  34 +++++++
 7 files changed, 168 insertions(+), 16 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 2841df4..6a1f8d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,9 +49,10 @@ jobs:
   include:
   - os: linux
     env:
-       - JDK="adopt@1.8"
+       - JDK="adopt@1.11"
        - LANG="de_DE.UTF-8"
        - LC_ALL="de_DE.UTF-8"
+       - SONARQUBE_EXECUTION=true
 before_install:
   # Download the script
   - curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh
@@ -60,10 +61,19 @@ before_install:
   - curl "${GRAVIS}.install-maven.sh" --output ~/.install-maven.sh
   # Download, install, configue the JDK, and export the configuration to the current shell
   - source ~/.install-maven.sh
+addons:
+  sonarcloud:
+    organization: "apache"
+    token:
+      secure: "EMpJMtN+fqjuyy69BByyUc08QGzgYCA8s40HDLofCExA/7i0o8tDMwLm2nVBUO5RNrvK8YDxdNI4P6zRAytws/KIw8WPJG4ycN3OFhaqccZit0zWzHO+JAD3r7rSc7dRTmC3KzeMjEHJbsbKQywLVUuaSy6vf8x5GJT2KG73hIU=" # encrypted value of your token
 # This is your main script
 script:
-  # Just an example. Do what you deem useful
-  - mvn verify -B
+  - | 
+    if [ "$SONARQUBE_EXECUTION" == "true" ]; then 
+      mvn clean verify sonar:sonar -B -Pjacoco-report -Dsonar.projectKey=apache_jackrabbit-filevault -Dlogback.configurationFile=vault-core/src/test/resources/logback-only-errors.xml
+    else
+      mvn clean verify -B
+    fi
 # If you use Gradle, cleanup the build cache from lock/temporary files
 before_cache:
   #- curl "${GRAVIS}.clean_gradle_cache.sh" --output ~/.clean_gradle_cache.sh
diff --git a/README.md b/README.md
index f9fa4e8..0287fb4 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,10 @@
 ![GitHub](https://img.shields.io/github/license/apache/jackrabbit-filevault)
 [![Maven Central](https://img.shields.io/maven-central/v/org.apache.jackrabbit.vault/vault-cli.svg?label=Maven%20Central)](https://search.maven.org/artifact//org.apache.jackrabbit.vault/vault-cli)
 [![Build Status](https://img.shields.io/travis/apache/jackrabbit-filevault/master)](https://travis-ci.org/apache/jackrabbit-filevault)
+[![SonarCloud Status](https://sonarcloud.io/api/project_badges/measure?project=apache_jackrabbit-filevault&metric=alert_status)](https://sonarcloud.io/dashboard?id=apache_jackrabbit-filevault)
+[![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=apache_jackrabbit-filevault&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=apache_jackrabbit-filevault)
+[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=apache_jackrabbit-filevault&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=apache_jackrabbit-filevault)
+[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=apache_jackrabbit-filevault&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=apache_jackrabbit-filevault)
 
 Welcome to Apache Jackrabbit FileVault
 ===========================================================
diff --git a/parent/pom.xml b/parent/pom.xml
index 26e606d..1bd3096 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -304,6 +304,11 @@ Bundle-Category: jackrabbit
                         </execution>
                     </executions>
                 </plugin>
+                <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <version>0.8.6</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
@@ -596,6 +601,106 @@ Bundle-Category: jackrabbit
                 </pluginManagement>
             </build>
         </profile>
+        <profile>
+            <id>jacoco-report</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.jacoco</groupId>
+                        <artifactId>jacoco-maven-plugin</artifactId>
+                        <configuration>
+                            <propertyName>jacoco.command</propertyName>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>prepare-agent</id>
+                                <goals>
+                                    <goal>prepare-agent</goal>
+                                </goals>
+                                <configuration>
+                                    <destFile>${project.build.directory}/jacoco-unit.exec</destFile>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>prepare-agent-integration</id>
+                                <goals>
+                                    <goal>prepare-agent-integration</goal>
+                                </goals>
+                                <configuration>
+                                    <destFile>${project.build.directory}/jacoco-it.exec</destFile>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>report</id>
+                                <goals>
+                                    <goal>report</goal>
+                                </goals>
+                                <configuration>
+                                    <dataFile>${project.build.directory}/jacoco-unit.exec</dataFile>
+                                    <outputDirectory> ${project.reporting.outputDirectory}/jacoco-unit</outputDirectory>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>report-integration</id>
+                                <goals>
+                                    <goal>report-integration</goal>
+                                </goals>
+                                <configuration>
+                                    <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
+                                    <outputDirectory> ${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>merge-unit-and-it</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>merge</goal>
+                                </goals>
+                                <configuration>
+                                    <fileSets>
+                                        <fileSet>
+                                            <directory>${project.build.directory}</directory>
+                                            <includes>
+                                                <include>jacoco-unit.exec</include>
+                                                <include>jacoco-it.exec</include>
+                                            </includes>
+                                        </fileSet>
+                                    </fileSets>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>report-merged</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>report</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <argLine>${jacoco.command}</argLine>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <configuration>
+                            <argLine>${jacoco.command}</argLine>
+                            <systemPropertyVariables>
+                                <!--
+                                for IT where you need a forked JVM to run the tests you can use this system property to make sure that
+                                the JaCoCo agent correctly instruments your code
+                                 -->
+                                <jacoco.command>${jacoco.command}</jacoco.command>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 
 </project>
diff --git a/vault-core/pom.xml b/vault-core/pom.xml
index 73be5c7..b15e812 100644
--- a/vault-core/pom.xml
+++ b/vault-core/pom.xml
@@ -154,12 +154,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <version>1.0.13</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <scope>provided</scope>
@@ -208,9 +202,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>${slf4j.version}</version>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.13</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
index 9d894d5..35e1130 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
@@ -447,7 +447,12 @@ public class IntegrationTestBase  {
 
     public ImportOptions getDefaultOptions() {
         ImportOptions opts = new ImportOptions();
-        opts.setListener(new ProgressTrackerListener() {
+        opts.setListener(getLoggingProgressTrackerListener());
+        return opts;
+    }
+
+    public ProgressTrackerListener getLoggingProgressTrackerListener() {
+        return new ProgressTrackerListener() {
             public void onMessage(Mode mode, String action, String path) {
                 log.info("{} {}", action, path);
             }
@@ -455,8 +460,7 @@ public class IntegrationTestBase  {
             public void onError(Mode mode, String path, Exception e) {
                 log.info("E {} {}", path, e.toString());
             }
-        });
-        return opts;
+        };
     }
 
     /**
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
index e0d277c..87abfcb 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
@@ -672,7 +672,8 @@ public class TestSubPackages extends IntegrationTestBase {
 
         // create new package
         JcrPackage pkg = packMgr.open(PACKAGE_ID_SUB_TEST);
-        packMgr.assemble(pkg, new DefaultProgressListener());
+        //
+        packMgr.assemble(pkg, getLoggingProgressTrackerListener());
 
         try (ZipInputStream in = new ZipInputStream(pkg.getData().getBinary().getStream())) {
             ZipEntry e;
diff --git a/vault-core/src/test/resources/logback-only-errors.xml b/vault-core/src/test/resources/logback-only-errors.xml
new file mode 100644
index 0000000..3b142e3
--- /dev/null
+++ b/vault-core/src/test/resources/logback-only-errors.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?><!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<configuration>
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+    <!-- limit logging to not exceed Travis CI maximum log length -->
+    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+      <level>ERROR</level>
+    </filter>
+  </appender>
+
+  <logger name="org.apache.jackrabbit.oak.query.QueryImpl" level="WARN"/>
+  <logger name="org.apache.jackrabbit.oak.plugins.index.IndexUpdate" level="WARN" />
+
+  <root level="INFO">
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>