You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by le...@apache.org on 2022/01/07 05:53:12 UTC

[any23] branch master updated: ANY23-546 Implement sonarcloud.io in Any23 continuous integration (#241)

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

lewismc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/any23.git


The following commit(s) were added to refs/heads/master by this push:
     new b61f5b8  ANY23-546 Implement sonarcloud.io in Any23 continuous integration (#241)
b61f5b8 is described below

commit b61f5b8eecbc24b5de54fe1d7b90b35fa12749f8
Author: Lewis John McGibbney <le...@gmail.com>
AuthorDate: Thu Jan 6 21:51:23 2022 -0800

    ANY23-546 Implement sonarcloud.io in Any23 continuous integration (#241)
    
    * ANY23-546 Implement sonarcloud.io in Any23 continuous integration
---
 .github/workflows/master-build.yml | 25 +++++++++++++++++++++----
 README.md                          |  4 ++++
 pom.xml                            | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.yml
index e497ed2..0901082 100644
--- a/.github/workflows/master-build.yml
+++ b/.github/workflows/master-build.yml
@@ -20,20 +20,37 @@ on:
     branches: [ master ]
   pull_request:
     branches: [ master ]
-        
+    types: [opened, synchronize, reopened]
 
 jobs:
   build:
+    name: Build
     runs-on: ubuntu-latest
     strategy:
       matrix:
         java: [ '11' ]
-
     steps:
       - uses: actions/checkout@v2
+        with:
+          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
       - name: Set up JDK ${{ matrix.java }}
         uses: actions/setup-java@v1
         with:
           java-version: ${{ matrix.java }}
-      - name: Build with Maven
-        run: mvn clean formatter:validate verify javadoc:aggregate test
+      - name: Cache SonarCloud packages
+        uses: actions/cache@v1
+        with:
+          path: ~/.sonar/cache
+          key: ${{ runner.os }}-sonar
+          restore-keys: ${{ runner.os }}-sonar
+      - name: Cache Maven packages
+        uses: actions/cache@v1
+        with:
+          path: ~/.m2
+          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+          restore-keys: ${{ runner.os }}-m2
+      - name: Build and analyze
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+        run: mvn -B clean formatter:validate verify javadoc:aggregate org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=apache_any23
\ No newline at end of file
diff --git a/README.md b/README.md
index 4fc1a99..402465a 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,10 @@
 [![Jenkins](https://img.shields.io/jenkins/s/https/ci-builds.apache.org/job/Any23/job/any23-master.svg?maxAge=3600)](https://ci-builds.apache.org//job/Any23/job/any23-master/)
 [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-builds.apache.org/job/Any23/job/any23-master.svg?maxAge=3600)](https://ci-builds.apache.org//job/Any23/job/any23-master/lastBuild/testReport/)
 [![Maven Central](https://img.shields.io/maven-central/v/org.apache.any23/apache-any23.svg?maxAge=86400)](http://search.maven.org/#search|ga|1|g%3A%22org.apache.any23%22)
+[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=apache_any23&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=apache_any23)
+[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=apache_any23&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=apache_any23)
+[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=apache_any23&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=apache_any23)
+[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=apache_any23&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=apache_any23)
 
 Apache Anything To Triples (Any23) is a library and web service that extracts
 structured data in RDF format from a variety of Web documents.
diff --git a/pom.xml b/pom.xml
index 4770bed..bf7c35a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -295,6 +295,7 @@
     <formatter-maven-plugin.version>2.17.1</formatter-maven-plugin.version>
     <ossindex-maven-plugin.version>3.1.0</ossindex-maven-plugin.version>
     <maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
+    <jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
 
     <!--
      | Any23 website has to be stored in SVN
@@ -304,6 +305,13 @@
     <site.urlDeployment>file://${site.filePath}</site.urlDeployment>
     <site.scmPubCheckoutDirectory>${site.filePath}</site.scmPubCheckoutDirectory>
     <assembly.skip>false</assembly.skip>
+    <!-- sonarcloud.io static source code analysis 
+    https://issues.apache.org/jira/browse/ANY23-546 -->
+    <sonar.organization>apache</sonar.organization>
+    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
+    <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
+    <sonar.projectVersion>${project.version}</sonar.projectVersion>
+    <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
   </properties>
 
   <dependencyManagement>
@@ -918,7 +926,7 @@
             Declaring default file encoding: UTF-8
             Enabling assertions.
            -->
-          <argLine>-Dfile.encoding=UTF-8 -ea ${surefire-extra-args}</argLine>
+          <argLine>${argLine} -Dfile.encoding=UTF-8 -ea ${surefire-extra-args}</argLine>
           <includes>
             <include>**/*Test.java</include>
             <include>**/*TestCase.java</include>
@@ -945,6 +953,26 @@
         </executions>
       </plugin>
 
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <version>${jacoco-maven-plugin.version}</version>
+        <executions>
+          <execution>
+            <id>prepare-agent</id>
+            <goals>
+             <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>report</id>
+            <goals>
+             <goal>report</goal>
+            </goals>
+            <phase>verify</phase>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
@@ -1238,6 +1266,7 @@
         <surefire-extra-args>--add-modules java.xml.bind</surefire-extra-args>
       </properties>
     </profile>
+
   </profiles>
 
 </project>