Setup Sonar check for master and Github pull requests (#18629)

* Setup Sonar check for master and Github pull requests

Signed-off-by: Sergii Kabashniuk <skabashniuk@redhat.com>
7.24.x
Sergii Kabashniuk 2020-12-17 13:21:41 +02:00 committed by GitHub
parent 3b9601c6c4
commit 51493229b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 0 deletions

36
.github/workflows/sonar.yaml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Sonar
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Sonar
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- 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 verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Psonar -Pintegration

42
pom.xml
View File

@ -1478,5 +1478,47 @@
<skipTests>true</skipTests>
</properties>
</profile>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules />
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>eclipse</sonar.organization>
</properties>
</profile>
</profiles>
</project>

View File

@ -33,6 +33,7 @@
<com.google.guava.version>20.0</com.google.guava.version>
<log4j.version>1.2.17</log4j.version>
<org.testng.version>6.8.21</org.testng.version>
<sonar.skip>true</sonar.skip>
</properties>
<dependencyManagement>
<dependencies>