Skip to content

Commit 40f2b51

Browse files
committed
add workflow to activate sonarqube on push
1 parent bb65eac commit 40f2b51

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/sonar.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
branches:
4+
- '**'
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
name: Sonar
9+
jobs:
10+
sonarqube:
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+
- name: Set up JDK 25
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: "temurin"
20+
java-version: 25
21+
overwrite-settings: false
22+
- name: Cache SonarQube packages
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.sonar/cache
26+
key: ${{ runner.os }}-sonar
27+
restore-keys: ${{ runner.os }}-sonar
28+
- name: Cache Maven packages
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.m2/repository
32+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
33+
restore-keys: ${{ runner.os }}-maven
34+
- name: Build and analyze
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
39+
run: |
40+
mkdir -p src/test/resources
41+
echo ${{ secrets.APPLICATION_TEST_PROPERTIES }} | base64 -d > src/test/resources/application-test.properties
42+
mvn clean verify sonar:sonar

src/sonar-project.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sonar.projectKey=spring_boot_java_random_user

0 commit comments

Comments
 (0)