Skip to content

Commit 9f829a6

Browse files
authored
feature: sonar for builds (#801)
1 parent 339d030 commit 9f829a6

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Sonar
2+
3+
env:
4+
MAVEN_ARGS: -V -ntp -e
5+
6+
concurrency:
7+
group: ${{ github.ref }}-${{ github.workflow }}
8+
cancel-in-progress: true
9+
on:
10+
push:
11+
branches: [ main ]
12+
pull_request:
13+
types: [ opened, synchronize, reopened ]
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up Java and Maven
21+
uses: actions/setup-java@v2
22+
with:
23+
distribution: temurin
24+
java-version: 17
25+
cache: 'maven'
26+
- name: Cache SonarCloud packages
27+
uses: actions/cache@v1
28+
with:
29+
path: ~/.sonar/cache
30+
key: ${{ runner.os }}-sonar
31+
restore-keys: ${{ runner.os }}-sonar
32+
- name: Cache Maven packages
33+
uses: actions/cache@v1
34+
with:
35+
path: ~/.m2
36+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
37+
restore-keys: ${{ runner.os }}-m2
38+
- name: Build and analyze
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
41+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
42+
run: mvn -B org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=java-operator-sdk_java-operator-sdk
43+

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<java.version>11</java.version>
4040
<maven.compiler.source>${java.version}</maven.compiler.source>
4141
<maven.compiler.target>${java.version}</maven.compiler.target>
42+
<sonar.organization>java-operator-sdk</sonar.organization>
43+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
4244

4345
<junit.version>5.8.2</junit.version>
4446
<fabric8-client.version>5.11.2</fabric8-client.version>

0 commit comments

Comments
 (0)