You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/12/23 06:08:58 UTC
[incubator-iotdb] branch master updated: enable Sonarcloud (#645)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 2b47675 enable Sonarcloud (#645)
2b47675 is described below
commit 2b47675d7af1355222fb94cf2f48b6312c47bfa6
Author: Xiangdong Huang <hx...@qq.com>
AuthorDate: Mon Dec 23 14:08:50 2019 +0800
enable Sonarcloud (#645)
* enable Sonarcloud
---
.travis.yml | 19 ++++++++
Jenkinsfile | 18 ++++++++
hadoop/pom.xml | 28 ++++++++++++
pom.xml | 141 ++++++++++++++++++++++++++++-----------------------------
4 files changed, 135 insertions(+), 71 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 24e0686..3fd3e99 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -174,6 +174,25 @@ matrix:
# - mvn -version
# - mvn -B apache-rat:check
# - mvn -B clean package -pl server,grafana,client,example,:kafka-example,:rocketmq-example -am integration-test
+ - os: linux
+ name: sonar-analysis
+ dist: xenial
+ jdk: openjdk8
+ addons:
+ sonarcloud:
+ organization: "apache"
+ projectKey: "apache_incubator-iotdb"
+ token:
+ secure: "a2n2+MFfuOb3hsrw5vjiIUZzjt6S0j4YmRVrms6NVKF+EpEAWU/zOjzfccLGRr3VFUAlkoM2p578c/0DMMGew2oj3Yl1iJe2n35BWIV6r/psUKRUMdgMAogdshQzZGMYmY1XL2xA3ATu8cf4F8WoRAafd/S58JGQdTfsQ5svh31BxK0iuh+nMIZb4dYxO717dSVD45D9hoF5ROxdtTRbyAaXFPs5djxWrdzKw0J3e6a8m82K9FGcpy4pY9ct3ttbyEzGqMnzE4fhd3KgopFJj+3QdAi/3Cmkf1voxorQdCSbktl4PtlzMY/nxF6XETI2E4T+GLUVMw4iHiXCabqwOiudGnEj5DjNz6X5MVCOyj7lrFBTlDirGzv9fNpvQ2I47WOL8DzBJPqFwQ0nRAlbvcWVtE4aAqj8YF1QwwLxEIi4abDfOwaxGG2TOixQf627pvhh1o0RdEf9R6aRyur7vbM [...]
+ script:
+ - mvn verify sonar:sonar -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-iotdb -DskipTests
+ - os: linux
+ name: code-coverage
+ dist: xenial
+ jdk: openjdk8
+ script:
+ - mvn test -Pcode-coverage -pl '!distribution'
+
cache:
directories:
diff --git a/Jenkinsfile b/Jenkinsfile
index efd3710..ca7b1d9 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -106,6 +106,24 @@ pipeline {
// }
// }
+ stage('Code Quality') {
+ when {
+ branch 'master'
+ }
+ steps {
+ echo 'Checking Code Quality on SonarCloud'
+ // Main parameters
+ script {
+ // Then run the analysis
+ // 'my-sonarcloud-token' needs to be defined for this job and contains the user token
+ withCredentials([string(credentialsId: 'xiangdong-iotdb-sonarcloud-token', variable: 'SONAR_TOKEN')]) {
+ sh 'mvn verify sonar:sonar -Dsonar.branch.name=master -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-iotdb -Dsonar.login=${SONAR_TOKEN} -DskipTests'
+ }
+ }
+ }
+ }
+
+
stage('Deploy') {
when {
branch 'master'
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index d1fc95b..cc54b34 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -98,4 +98,32 @@
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>skipHadoopTests</id>
+ <activation>
+ <property>
+ <name>skipTests</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <hadoop.test.skip>true</hadoop.test.skip>
+ <hadoop.ut.skip>true</hadoop.ut.skip>
+ <hadoop.it.skip>true</hadoop.it.skip>
+ </properties>
+ </profile>
+ <profile>
+ <id>skipUT_HadoopTests</id>
+ <activation>
+ <property>
+ <name>skipUTs</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <hadoop.ut.skip>true</hadoop.ut.skip>
+ </properties>
+ </profile>
+ </profiles>
</project>
diff --git a/pom.xml b/pom.xml
index 9639627..6125540 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,9 +88,12 @@
<jetty.version>9.4.24.v20191120</jetty.version>
<metrics.version>3.2.6</metrics.version>
<!-- URL of the ASF SonarQube server -->
- <sonar.host.url>https://builds.apache.org/analysis</sonar.host.url>
+ <sonar.host.url>https://sonarcloud.io</sonar.host.url>
+ <sonar.organization>apache</sonar.organization>
<!-- Exclude all generated code -->
<sonar.exclusions>**/generated-sources</sonar.exclusions>
+ <!-- By default, the argLine is empty-->
+ <argLine></argLine>
</properties>
<!--
if we claim dependencies in dependencyManagement, then we do not claim
@@ -465,7 +468,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Xmx1024m</argLine>
+ <argLine>${argLine} -Xmx1024m</argLine>
</configuration>
</plugin>
<!--
@@ -474,7 +477,7 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
- <version>3.6.0.1398</version>
+ <version>3.6.1.1688</version>
</plugin>
<plugin>
<groupId>org.apache.rat</groupId>
@@ -575,48 +578,6 @@
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
- <!-- use mvn license:remove to remove license header; mvn license:format -->
- <!-- we do not recommend using the plugin because it maybe out of control
- (adding headers in some files that you do not want) -->
- <!--<plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <header>asf.header</header>
- <properties>
- <owner>Apache IoTDB(incubating)</owner>
- <email>dev@iotdb.apache.org</email>
- <project.inceptionYear>2019</project.inceptionYear>
- </properties>
- <mapping>
- <g>DOUBLESLASH_STYLE</g>
- <thrift>SLASHSTAR_STYLE</thrift>
- </mapping>
- <excludes>
- <exclude>**/README.md</exclude>
- <exclude>**/src/test/resources/*.json</exclude>
- <exclude>**/src/main/resources/*.json</exclude>
- <exclude>jdbc/example/data/*.csv</exclude>
- <exclude>**/*.log</exclude>
- <exclude>licenses-binary/*</exclude>
- <exclude>.checkstyle</exclude>
- <exclude>NOTICE*</exclude>
- <exclude>LICENSE*</exclude>
- <exclude>License</exclude>
- <exclude>asf.header</exclude>
- <exclude>**/iotdb/data/</exclude>
- <exclude>local-snapshots-dir/**</exclude>
- </excludes>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin> -->
<!--
Check if all files contain Apache headers in them.
Ignore this plugin, we use license-maven-plugin to check apache header.
@@ -634,32 +595,6 @@
</execution>
</executions>
</plugin>
- <!--use `mvn cobertura:cobertura` -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <quiet>true</quiet>
- <formats>
- <format>xml</format>
- </formats>
- <instrumentation>
- <ignoreTrivial>true</ignoreTrivial>
- </instrumentation>
- <check/>
- </configuration>
- <executions>
- <execution>
- <id>check</id>
- <!-- skip when executing 'mvn clean test' -->
- <!-- <phase>test</phase> -->
- <goals>
- <goal>cobertura</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>au.com.acegi</groupId>
<artifactId>xml-format-maven-plugin</artifactId>
@@ -1041,5 +976,69 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>code-coverage</id>
+ <build>
+ <plugins>
+ <!-- Jacoco is a code coverage analysis plugin when tests run.
+ (not a static code analysis tool)-->
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.8.5</version>
+ <configuration>
+ <skip>false</skip>
+ <destFile>${basedir}/target/coverage-reports/jacoco.exec</destFile>
+ <rules>
+ <rule implementation="org.jacoco.maven.RuleConfiguration">
+ <element>BUNDLE</element>
+ <limits>
+ <!-- Cover methodes >=30%. (the plugin does not support
+ ignore getter and setter and toString etc..) -->
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>METHOD</counter>
+ <value>COVEREDRATIO</value>
+ <minimum>0.00</minimum>
+ </limit>
+ <!-- if-else, swtich etc.. >=70% -->
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>BRANCH</counter>
+ <value>COVEREDRATIO</value>
+ <minimum>0.00</minimum>
+ </limit>
+ <!-- class files >=95% -->
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>CLASS</counter>
+ <value>COVEREDRATIO</value>
+ <minimum>0.00</minimum>
+ </limit>
+ </limits>
+ </rule>
+ </rules>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <!-- attached to Maven test phase -->
+ <execution>
+ <id>report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <dataFile>${basedir}/target/coverage-reports/jacoco.exec</dataFile>
+ <outputDirectory>${basedir}/target/coverage-reports</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>