Skip to content

Commit 90bbbc5

Browse files
ci: SonarCloud coverage (#195)
Introduce a new Maven profile for JaCoCo test coverage reporting in the `pom.xml`. Additionally, update the GitHub Actions workflow to include a SonarCloud scan that uses the JaCoCo coverage data. DSP-119 DSP-120
1 parent e9dc738 commit 90bbbc5

File tree

3 files changed

+101
-2
lines changed

3 files changed

+101
-2
lines changed

.github/workflows/checks.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,31 @@ jobs:
4242
distribution: "adopt"
4343
server-id: github
4444
- name: Maven Verify
45-
run: |
46-
mvn --batch-mode verify
45+
run: mvn --batch-mode verify
46+
env:
47+
BUF_INPUT_HTTPS_USERNAME: opentdf-bot
48+
BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }}
49+
50+
sonarcloud:
51+
name: SonarCloud Scan
52+
runs-on: ubuntu-22.04
53+
steps:
54+
- name: Check out repository
55+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
56+
- uses: bufbuild/buf-setup-action@2211e06e8cf26d628cda2eea15c95f8c42b080b3
57+
with:
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Set up JDK
60+
uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7
61+
with:
62+
java-version: "17"
63+
distribution: "temurin"
64+
server-id: github
65+
- name: Maven Test Coverage
4766
env:
4867
BUF_INPUT_HTTPS_USERNAME: opentdf-bot
4968
BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }}
69+
run: mvn --batch-mode clean verify -P coverage
5070

5171
platform-integration:
5272
runs-on: ubuntu-22.04
@@ -257,6 +277,7 @@ jobs:
257277
- platform-integration
258278
- platform-xtest
259279
- mavenverify
280+
- sonarcloud
260281
- pr
261282
runs-on: ubuntu-latest
262283
if: always()

pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,5 +342,54 @@
342342
</plugins>
343343
</build>
344344
</profile>
345+
<profile>
346+
<id>coverage</id>
347+
<modules>
348+
<module>sdk</module>
349+
</modules>
350+
<properties>
351+
<sonar.organization>opentdf</sonar.organization>
352+
<sonar.projectKey>opentdf_java-sdk</sonar.projectKey>
353+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
354+
</properties>
355+
<build>
356+
<plugins>
357+
<plugin>
358+
<groupId>org.jacoco</groupId>
359+
<artifactId>jacoco-maven-plugin</artifactId>
360+
<version>0.8.12</version>
361+
<executions>
362+
<execution>
363+
<id>prepare-agent</id>
364+
<goals>
365+
<goal>prepare-agent</goal>
366+
<goal>report-aggregate</goal>
367+
</goals>
368+
</execution>
369+
<execution>
370+
<id>report</id>
371+
<phase>test</phase>
372+
<goals>
373+
<goal>report</goal>
374+
</goals>
375+
<configuration>
376+
<dataFile>${project.parent.basedir}/target/jacoco.exec</dataFile>
377+
<formats>
378+
<format>XML</format>
379+
</formats>
380+
</configuration>
381+
</execution>
382+
<execution>
383+
<id>post-test-report</id>
384+
<phase>prepare-package</phase>
385+
<goals>
386+
<goal>report</goal>
387+
</goals>
388+
</execution>
389+
</executions>
390+
</plugin>
391+
</plugins>
392+
</build>
393+
</profile>
345394
</profiles>
346395
</project>

sdk/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,35 @@
275275
</execution>
276276
</executions>
277277
</plugin>
278+
<plugin>
279+
<groupId>org.jacoco</groupId>
280+
<artifactId>jacoco-maven-plugin</artifactId>
281+
<version>0.8.12</version>
282+
<executions>
283+
<execution>
284+
<id>prepare-agent</id>
285+
<goals>
286+
<goal>prepare-agent</goal>
287+
</goals>
288+
<configuration>
289+
<destFile>${project.parent.basedir}/target/jacoco.exec</destFile>
290+
</configuration>
291+
</execution>
292+
<execution>
293+
<id>report</id>
294+
<phase>test</phase>
295+
<goals>
296+
<goal>report</goal>
297+
</goals>
298+
<configuration>
299+
<dataFile>${project.parent.basedir}/target/jacoco.exec</dataFile>
300+
<formats>
301+
<format>XML</format>
302+
</formats>
303+
</configuration>
304+
</execution>
305+
</executions>
306+
</plugin>
278307
</plugins>
279308
</build>
280309
</project>

0 commit comments

Comments
 (0)