Skip to content

Commit 6ec6851

Browse files
committed
SonarQube Cloud integration
1 parent 0ad7f8d commit 6ec6851

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: SonarQube
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@v4
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 17
21+
distribution: 'zulu' # Alternative distribution options are available
22+
23+
- name: Cache SonarQube packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.sonar/cache
27+
key: ${{ runner.os }}-sonar
28+
restore-keys: ${{ runner.os }}-sonar
29+
30+
- name: Cache Gradle packages
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/backend/.gradle/caches
34+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
35+
restore-keys: ${{ runner.os }}-gradle
36+
37+
- name: Build and run tests
38+
run: cd backend && ./gradlew build test
39+
40+
- name: SonarQube Scan
41+
uses: SonarSource/sonarqube-scan-action@v5
42+
env:
43+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

backend/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot' version '3.4.4'
44
id 'io.spring.dependency-management' version '1.1.7'
5+
id "org.sonarqube" version "6.0.1.5171"
56
}
67

78
group = 'com.cilantro'
@@ -47,3 +48,11 @@ dependencies {
4748
tasks.named('test') {
4849
useJUnitPlatform()
4950
}
51+
52+
sonar {
53+
properties {
54+
property "sonar.projectKey", "blueheron786_jee-react-vite-site-quickstart"
55+
property "sonar.organization", "blueheron786"
56+
property "sonar.host.url", "https://sonarcloud.io"
57+
}
58+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.cilantro.backend;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.boot.test.context.SpringBootTest;
5+
6+
@SpringBootTest
7+
class BackendApplicationTests {
8+
9+
@Test
10+
void contextLoads() {
11+
}
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
spring:
2+
datasource:
3+
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
4+
driver-class-name: org.h2.Driver
5+
username: sa
6+
password: password
7+
jpa:
8+
database-platform: org.hibernate.dialect.H2Dialect
9+
hibernate:
10+
ddl-auto: create-drop
11+
jwt:
12+
secret-key: "testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt" # Must be Base64 encoded
13+
expiration-ms: 86400000 # 24 hours

sonar-project.properties

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sonar.projectKey=blueheron786_jee-react-vite-site-quickstart
2+
sonar.organization=blueheron786
3+
sonar.java.binaries=backend/build/classes/java/main
4+
5+
6+
# This is the name and version displayed in the SonarCloud UI.
7+
#sonar.projectName=jee-react-vite-site-quickstart
8+
#sonar.projectVersion=1.0
9+
10+
11+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
12+
#sonar.sources=.
13+
14+
# Encoding of the source code. Default is default system encoding
15+
#sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)