Skip to content

Commit a38c87c

Browse files
committed
Integrate with SonarCloud
1 parent 9c33e86 commit a38c87c

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: SonarCloud
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
8+
jobs:
9+
build:
10+
name: Build and analyze
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: 17
20+
distribution: 'zulu' # Alternative distribution options are available
21+
- name: Cache SonarCloud packages
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.sonar/cache
25+
key: ${{ runner.os }}-sonar
26+
restore-keys: ${{ runner.os }}-sonar
27+
- name: Cache Gradle packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.gradle/caches
31+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
32+
restore-keys: ${{ runner.os }}-gradle
33+
- name: Build and analyze
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: ./gradlew build sonar --info

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id("io.spring.dependency-management") version "1.1.4"
55
kotlin("jvm") version "1.9.22"
66
id("com.adarshr.test-logger") version "4.0.0"
7+
id("org.sonarqube") version "4.4.1.3373"
78
}
89

910
group = "io.github.tobi.laa"
@@ -13,6 +14,14 @@ java {
1314
sourceCompatibility = JavaVersion.VERSION_17
1415
}
1516

17+
sonar {
18+
properties {
19+
property("sonar.projectKey", "tobias-laa_spring-boot-embedded-redis")
20+
property("sonar.organization", "tobias-laa")
21+
property("sonar.host.url", "https://sonarcloud.io")
22+
}
23+
}
24+
1625
repositories {
1726
mavenCentral()
1827
}

0 commit comments

Comments
 (0)