Skip to content

Commit

Permalink
✅ [CI] Added Sonar analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <[email protected]>
  • Loading branch information
Coduz committed Dec 13, 2024
1 parent e545dbb commit 51e541d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/sonarCloud-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Sonar Scan

on:
push:
branches:
- 'develop'
- 'release-**'
pull_request:
branches:
- 'develop'
- 'release-**'

jobs:
build:
name: Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'zulu'
- name: Set up Node 16
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install Swagger CLI # Installs Swagger CLI to bundle OpenAPI files
run: 'npm install -g @apidevtools/swagger-cli'
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
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 }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B compile -PsonarScan

30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<karaf-maven-plugin.version>4.4.2</karaf-maven-plugin.version>
<license-maven-plugin.version>1.9</license-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.6.5</nexus-staging-maven-plugin.version>
<sonar-maven-plugin.version>5.0.0.4389</sonar-maven-plugin.version>
<sql-maven-plugin.version>1.5</sql-maven-plugin.version>
<surefire.version>3.0.0-M7</surefire.version>

Expand All @@ -177,7 +178,10 @@
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<timestamp>${maven.build.timestamp}</timestamp>

<!-- Sonar Configuration-->
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>eclipse_kapua</sonar.projectKey>
<sonar.organization>eclipse-github</sonar.organization>
</properties>

<build>
Expand Down Expand Up @@ -501,6 +505,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down Expand Up @@ -2837,6 +2846,27 @@
</plugins>
</build>
</profile>

<profile>
<id>sonarScan</id>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<licenses>
Expand Down
2 changes: 0 additions & 2 deletions simulator-kura/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua</artifactId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>kapua-simulator-kura</artifactId>
<description>This is a framework for simulating Eclipse Kura IoT gateway instances</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<docker.account>kapua</docker.account>
<osgi.version>6.0.0</osgi.version>
</properties>
Expand Down

0 comments on commit 51e541d

Please sign in to comment.