Skip to content

Commit bb795c0

Browse files
committed
Add java-sonar, that checks Java code with Sonar
1 parent 5dc1066 commit bb795c0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

java/java-sonar.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 Fabrício Barros Cabral
2+
# SPDX-License-Identifier: MIT
3+
---
4+
name: java-sonar
5+
'on':
6+
push:
7+
branches:
8+
- main
9+
jobs:
10+
java-sonar:
11+
timeout-minutes: 15
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: Setup Java SDK
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: 11
20+
distribution: 'temurin'
21+
- name: Configure Maven cache
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.m2/repository
25+
key: ubuntu-jdk-11-maven-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: ubuntu-jdk-11-maven-
27+
- name: Configure Sonar cache
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.sonar/cache
31+
key: ${{ runner.os }}-sonar
32+
restore-keys: ${{ runner.os }}-sonar
33+
- name: Run sonar
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: |
38+
mvn --batch-mode verify -Pjacoco -Dinvoker.skip \
39+
&& mvn --batch-mode verify -Psonar -Dinvoker.skip \
40+
-Dsonar.qualitygate.wait=true

0 commit comments

Comments
 (0)