Skip to content

Commit

Permalink
Configure Sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Apr 14, 2024
1 parent 26a35d5 commit e877fa4
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/sonar_jdk17_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: SonarCloud analysis with JDK 17 on Ubuntu

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
branches:
- master

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
cache: maven

- name: Build with Maven/JDK 17, test with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn --batch-mode --file pom.xml --activate-profiles sonarcloud clean verify
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<dep.junit.version>5.10.2</dep.junit.version>

<dep.plugin.sortpom.version>3.4.1</dep.plugin.sortpom.version>
<dep.plugin.sonar.version>3.10.0.2594</dep.plugin.sonar.version>

<basepom.check.skip-checkstyle>false</basepom.check.skip-checkstyle>
<basepom.check.skip-pmd>false</basepom.check.skip-pmd>
Expand Down Expand Up @@ -272,6 +273,7 @@
</plugin>

</plugins>

</build>

<profiles>
Expand Down Expand Up @@ -304,6 +306,40 @@
</distributionManagement>
</profile>

<profile>
<!-- mvn verify -P sonarcloud -->
<id>sonarcloud</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<sonar.skip>false</sonar.skip>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>spannm</sonar.organization>
<!-- sonar.token>YOUR_TOKEN_HERE</sonar.token -->

<basepom.test.skip>true</basepom.test.skip>
<basepom.check.skip-all>true</basepom.check.skip-all>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${dep.plugin.sonar.version}</version>
<executions>
<execution>
<goals>
<goal>sonar</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>release</id>
<activation>
Expand Down

0 comments on commit e877fa4

Please sign in to comment.