Skip to content

Commit 3985900

Browse files
committed
chore(ci): update Maven CI workflow for SonarQube compatibility
- Adjusted artifact handling to include binary class files required by SonarQube. - Set `fetch-depth` to 0 for full Git history to improve Sonar analysis. - Updated JaCoCo XML report path in `pom.xml` for accurate coverage reporting (Sonar needs the full path to the XML file).
1 parent d10c0dc commit 3985900

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/maven_unit_test.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
# Get the build output from the integration test job
148148
- uses: actions/download-artifact@v8
149149
with:
150-
name: java-reportdir
150+
name: java-reportdir
151151
- run: tar -xvf java-reportdir.tar
152152

153153
# Deposit Code Coverage
@@ -162,28 +162,37 @@ jobs:
162162
-DrepoToken=${COVERALLS_SECRET} -DpullRequest=${{ github.event.number }}
163163
jacoco:report coveralls:report
164164
165-
sonarqube:
165+
sonarcloud:
166166
runs-on: ubuntu-latest
167167
needs: integration-test
168168
name: SonarQube Analysis and Coverage
169169
steps:
170170
# TODO: As part of #10618 change to setup-maven custom action
171171
# Basic setup chores
172172
- uses: actions/checkout@v7
173+
with:
174+
# Sonarcube benefits from a full Git history in it's analysis (assign issues, etc)
175+
fetch-depth: 0
173176
- uses: actions/setup-java@v5
174177
with:
175178
java-version: '21'
176179
distribution: temurin
177180
cache: maven
178181

179-
# Get the build output from the integration test job
182+
# Get the coverage output from the integration test job
180183
- uses: actions/download-artifact@v8
181184
with:
182185
name: java-reportdir
183-
- run: tar -xvf java-reportdir.tar
186+
# Get the binary class files as Sonar needs them for analysis
187+
- uses: actions/download-artifact@v8
188+
with:
189+
name: java-artifacts
190+
- run: |
191+
tar -xvf java-builddir.tar
192+
tar -xvf java-reportdir.tar
184193
185194
# Run Sonarcube analysis
186-
- name: Commit Data to SonarCloud
195+
- name: Analyze and commit to SonarCloud
187196
env:
188197
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
189198
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<failsafe.jacoco.args>-Ddummy.jacoco.property=true</failsafe.jacoco.args>
2828

2929
<jacoco.merged.outputdir>${project.reporting.outputDirectory}/jacoco-merged-test-coverage-report</jacoco.merged.outputdir>
30-
<sonar.coverage.jacoco.xmlReportPaths>${jacoco.merged.outputdir}</sonar.coverage.jacoco.xmlReportPaths>
30+
<sonar.coverage.jacoco.xmlReportPaths>${jacoco.merged.outputdir}/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
3131

3232
<!-- By default, this module will produce a WAR file. -->
3333
<!-- This will be switched within the container profile! -->

0 commit comments

Comments
 (0)