✨ (ci): Add SonarQube analysis + JaCoCo coverage on main
Changes
3 files changed, +63 -1
MODIFY
.github/workflows/jvm.yml
+27 -0
@@ -18,6 +18,33 @@
18
18
- name: Run JVM tests
19
19
run: ./mvnw -B test
20
20
21
+ sonar:
22
+ # SonarQube Community Build analyses the main branch only (no PR decoration),
23
+ # so this runs on push-to-main after tests pass. `verify` regenerates the
24
+ # combined JaCoCo report the scanner picks up via sonar.coverage.jacoco.xmlReportPaths.
25
+ if: github.ref == 'refs/heads/main'
26
+ runs-on: ubuntu-latest
27
+ needs: [jvm-tests]
28
+ steps:
29
+ - uses: actions/checkout@v7
30
+ with:
31
+ # Full history so Sonar can attribute new code / blame correctly.
32
+ fetch-depth: 0
33
+ - uses: actions/setup-java@v5
34
+ with:
35
+ distribution: temurin
36
+ java-version: '21'
37
+ cache: maven
38
+ - name: Sonar analysis
39
+ env:
40
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41
+ SONAR_HOST_URL: https://sonar.ha1nz.de
42
+ run: >-
43
+ ./mvnw -B verify
44
+ org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
45
+ -Dsonar.projectKey=git-shark
46
+ -Dsonar.projectName=git-shark
47
+
21
48
jvm-image-smoke:
22
49
# The documented Compose setup relies on the image shipping /data mount points
23
50
# owned by the runtime UID (185) so freshly created named volumes inherit that
MODIFY
README.md
+3 -1
@@ -256,7 +256,9 @@
256
256
257
257
- `.github/workflows/jvm.yml` — JVM tests on every push/PR; on main, builds and pushes the
258
258
JVM container image to GHCR as a multi-arch manifest (linux/amd64 + linux/arm64, via
259
- Buildx/QEMU).
259
+ Buildx/QEMU), and runs a SonarQube Community Build analysis against `sonar.ha1nz.de`
260
+ (test coverage via the combined JaCoCo report at `target/jacoco-report/jacoco.xml`).
261
+ Community Build analyses the main branch only, so the `sonar` job is gated to main.
260
262
- `.github/workflows/native.yml` — native build + integration tests on every push/PR; on
261
263
main, builds and pushes the native container image to GHCR with a `-native` tag suffix
262
264
(linux/amd64 only).
MODIFY
pom.xml
+33 -0
@@ -25,6 +25,9 @@
25
25
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
26
26
<skipITs>true</skipITs>
27
27
<surefire-plugin.version>3.5.6</surefire-plugin.version>
28
+ <jacoco.version>0.8.13</jacoco.version>
29
+ <!-- Combined coverage report consumed by SonarQube (git-shark project). -->
30
+ <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/jacoco-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
28
31
</properties>
29
32
30
33
<dependencyManagement>
@@ -152,6 +155,14 @@
152
155
<artifactId>quarkus-junit</artifactId>
153
156
<scope>test</scope>
154
157
</dependency>
158
+ <!-- Auto-generates JaCoCo coverage for @QuarkusTest classes (report in target/jacoco-report).
159
+ Plain unit tests are covered by the jacoco-maven-plugin agent below; both write to the
160
+ same target/jacoco-quarkus.exec, which this extension turns into one combined report. -->
161
+ <dependency>
162
+ <groupId>io.quarkus</groupId>
163
+ <artifactId>quarkus-jacoco</artifactId>
164
+ <scope>test</scope>
165
+ </dependency>
155
166
<dependency>
156
167
<groupId>io.quarkus</groupId>
157
168
<artifactId>quarkus-test-security</artifactId>
@@ -230,6 +241,28 @@
230
241
</systemPropertyVariables>
231
242
</configuration>
232
243
</plugin>
244
+ <!-- Captures coverage for the non-@QuarkusTest unit tests. Sets the `argLine` property
245
+ consumed by surefire's @{argLine}; excludes *QuarkusClassLoader so it does not
246
+ double-instrument @QuarkusTest classes (those are handled by the quarkus-jacoco
247
+ extension). Appends to the shared jacoco-quarkus.exec the extension reports on. -->
248
+ <plugin>
249
+ <groupId>org.jacoco</groupId>
250
+ <artifactId>jacoco-maven-plugin</artifactId>
251
+ <version>${jacoco.version}</version>
252
+ <executions>
253
+ <execution>
254
+ <id>default-prepare-agent</id>
255
+ <goals>
256
+ <goal>prepare-agent</goal>
257
+ </goals>
258
+ <configuration>
259
+ <exclClassLoaders>*QuarkusClassLoader</exclClassLoaders>
260
+ <destFile>${project.build.directory}/jacoco-quarkus.exec</destFile>
261
+ <append>true</append>
262
+ </configuration>
263
+ </execution>
264
+ </executions>
265
+ </plugin>
233
266
<plugin>
234
267
<artifactId>maven-failsafe-plugin</artifactId>
235
268
<version>${surefire-plugin.version}</version>