Skip to content

Commit 0fdbb91

Browse files
committed
Sonar
1 parent 8c636ef commit 0fdbb91

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

.github/workflows/build-sonar.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ jobs:
6060
-Dmaven.wagon.http.retryHandler.count=3
6161
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
6262
63-
- name: Archive build artifacts
64-
uses: actions/upload-artifact@v3
65-
if: always()
66-
with:
67-
name: Build debug files
68-
path: |
69-
**/target/rat.txt
70-
**/target/surefire-reports/*
7163
7264
- name: Validate PR
7365
id: validate_pr
@@ -84,7 +76,6 @@ jobs:
8476
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
8577
run: >-
8678
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -fae -T 2 -B -V
87-
-Dmaven.repo.local=$HOME/.m2/repository11
8879
-DcloudBuild
8980
-Pcoverage
9081
-Dmaven.wagon.http.retryHandler.count=3
@@ -93,23 +84,3 @@ jobs:
9384
-Dsonar.pullrequest.branch=${{ steps.validate_pr.outputs.pr-branch }}
9485
-Dsonar.pullrequest.base=${{ steps.validate_pr.outputs.pr-base }}
9586
-Dsonar.branch.name=${{ github.event.workflow_run.head_branch }}
96-
97-
- name: Archive build artifacts
98-
uses: actions/upload-artifact@v3
99-
if: always()
100-
with:
101-
name: Build debug files
102-
path: |
103-
**/target/rat.txt
104-
**/target/surefire-reports/*
105-
106-
- name: Surefire Report
107-
# Pinned 3.5.2 version
108-
uses: mikepenz/action-junit-report@16a9560bd02f11e7e3bf6b3e2ef6bba6c9d07c32
109-
if: always()
110-
with:
111-
report_paths: '**/target/surefire-reports/TEST-*.xml'
112-
github_token: ${{ secrets.GITHUB_TOKEN }}
113-
detailed_summary: true
114-
commit: ${{ github.event.workflow_run.head_sha }}
115-
check_name: Sonar Build Test Report

.github/workflows/build.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,40 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-maven-${{ github.workflow }}
4545
46+
- name: Cache SonarCloud packages
47+
uses: actions/cache@v3
48+
with:
49+
path: ~/.sonar/cache
50+
key: ${{ runner.os }}-sonar
51+
restore-keys: ${{ runner.os }}-sonar
52+
4653
- name: Build with Maven
47-
run: mvn clean compile test -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25
54+
run: mvn clean verify -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon
55+
.httpconnectionManager.ttlSeconds=25
56+
57+
- name: Validate PR
58+
id: validate_pr
59+
# For whatever reason we get PR 69 for develop branch with both head and base as develop.
60+
if: ${{ github.event.workflow_run.pull_requests[0].head.ref != github.event.workflow_run.pull_requests[0].base.ref }}
61+
run: |
62+
echo ":set-output pr-key=${{ github.event.workflow_run.pull_requests[0].number }}"
63+
echo ":set-output pr-branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}"
64+
echo ":set-output pr-base=${{ github.event.workflow_run.pull_requests[0].base.ref }}"
65+
66+
- name: Sonar report
67+
env:
68+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
69+
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
70+
run: >-
71+
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -fae -T 2 -B -V
72+
-DcloudBuild
73+
-Pcoverage
74+
-Dmaven.wagon.http.retryHandler.count=3
75+
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
76+
-Dsonar.pullrequest.key=${{ steps.validate_pr.outputs.pr-key }}
77+
-Dsonar.pullrequest.branch=${{ steps.validate_pr.outputs.pr-branch }}
78+
-Dsonar.pullrequest.base=${{ steps.validate_pr.outputs.pr-base }}
79+
-Dsonar.branch.name=${{ github.event.workflow_run.head_branch }}
4880
4981
- name: Archive build artifacts
5082
uses: actions/upload-artifact@v3

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<jacoco.version>0.8.8</jacoco.version>
6666

6767
<sonar.organization>data-integrations</sonar.organization>
68-
<sonar.projectKey>data-integrations_${project.artifactId}</sonar.projectKey>
68+
<sonar.projectKey>${sonar.organization}_${project.artifactId}</sonar.projectKey>
6969
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
7070
<sonar.coverage.jacoco.xmlReportPaths>
7171
${maven.multiModuleProjectDirectory}/delta-coverage/target/site/jacoco-aggregate/jacoco.xml

0 commit comments

Comments
 (0)