Skip to content

Commit 9eef1e6

Browse files
ci: SonarCloud coverage (#26)
Introduced a new SonarCloud scan step in the GitHub Actions workflow to enhance code quality checks. Updated `pom.xml` to include SonarCloud configuration properties and reorganized Jacoco plugins under a new coverage profile. DSP-120
1 parent bc1e319 commit 9eef1e6

File tree

5 files changed

+138
-73
lines changed

5 files changed

+138
-73
lines changed

.github/workflows/checks.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,31 @@ jobs:
4747
env:
4848
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4949

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+
with:
57+
fetch-depth: 0
58+
- name: Set up JDK
59+
uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7
60+
with:
61+
java-version: "17"
62+
distribution: "temurin"
63+
server-id: github
64+
- name: Maven Test Coverage
65+
env:
66+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
run: mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -P coverage
5069

5170
ci:
5271
needs:
5372
- mavenverify
5473
- pr
74+
- sonarcloud
5575
runs-on: ubuntu-latest
5676
if: always()
5777
steps:

nifi-tdf-nar/pom.xml

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
<groupId>org.apache.nifi</groupId>
3434
<artifactId>nifi-nar-maven-plugin</artifactId>
3535
</plugin>
36+
<plugin>
37+
<groupId>org.jacoco</groupId>
38+
<artifactId>jacoco-maven-plugin</artifactId>
39+
<executions>
40+
<execution>
41+
<id>default-prepare-agent</id>
42+
<phase>none</phase>
43+
</execution>
44+
<execution>
45+
<id>report-aggregate</id>
46+
<phase>none</phase>
47+
</execution>
48+
<execution>
49+
<id>default-report-aggregate</id>
50+
<phase>none</phase>
51+
</execution>
52+
</executions>
53+
</plugin>
3654
</plugins>
3755
</build>
3856
</project>

nifi-tdf-processors/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@
103103
<plugin>
104104
<groupId>org.jacoco</groupId>
105105
<artifactId>jacoco-maven-plugin</artifactId>
106+
<executions>
107+
<execution>
108+
<id>prepare-agent</id>
109+
<goals>
110+
<goal>prepare-agent</goal>
111+
</goals>
112+
<configuration>
113+
<destFile>${project.parent.basedir}/target/jacoco.exec</destFile>
114+
</configuration>
115+
</execution>
116+
<execution>
117+
<id>report</id>
118+
<phase>test</phase>
119+
<goals>
120+
<goal>report</goal>
121+
</goals>
122+
<configuration>
123+
<dataFile>${project.parent.basedir}/target/jacoco.exec</dataFile>
124+
<formats>
125+
<format>XML</format>
126+
</formats>
127+
</configuration>
128+
</execution>
129+
</executions>
106130
</plugin>
107131
</plugins>
108132
</build>

pom.xml

+76-68
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<maven.compiler.source>17</maven.compiler.source>
3434
<maven.compiler.target>17</maven.compiler.target>
3535
<jacoco.line.coverage>.7</jacoco.line.coverage>
36+
<sonar.organization>opentdf</sonar.organization>
37+
<sonar.projectKey>opentdf_nifi</sonar.projectKey>
38+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
39+
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
3640
</properties>
3741
<modules>
3842
<module>nifi-tdf-controller-services-api</module>
@@ -60,7 +64,7 @@
6064
<dependency>
6165
<groupId>io.opentdf.platform</groupId>
6266
<artifactId>sdk</artifactId>
63-
<version>0.6.1</version>
67+
<version>0.7.3</version>
6468
</dependency>
6569
<dependency>
6670
<groupId>org.apache.commons</groupId>
@@ -96,63 +100,6 @@
96100
<version>1.5.1</version>
97101
<extensions>true</extensions>
98102
</plugin>
99-
<plugin>
100-
<groupId>org.jacoco</groupId>
101-
<artifactId>jacoco-maven-plugin</artifactId>
102-
<version>0.8.12</version>
103-
<executions>
104-
<execution>
105-
<id>jacoco-prepare-agent</id>
106-
<goals>
107-
<goal>prepare-agent</goal>
108-
</goals>
109-
</execution>
110-
<execution>
111-
<id>jacoco-prepare-agent-integration</id>
112-
<goals>
113-
<goal>prepare-agent-integration</goal>
114-
</goals>
115-
</execution>
116-
<execution>
117-
<id>jacoco-report</id>
118-
<goals>
119-
<goal>report</goal>
120-
</goals>
121-
<phase>test</phase>
122-
</execution>
123-
<execution>
124-
<id>check</id>
125-
<goals>
126-
<goal>check</goal>
127-
</goals>
128-
<configuration>
129-
<rules>
130-
<rule>
131-
<element>BUNDLE</element>
132-
<limits>
133-
<limit>
134-
<counter>LINE</counter>
135-
<value>COVEREDRATIO</value>
136-
<minimum>${jacoco.line.coverage}</minimum>
137-
</limit>
138-
</limits>
139-
</rule>
140-
</rules>
141-
</configuration>
142-
</execution>
143-
</executions>
144-
</plugin>
145-
<plugin>
146-
<groupId>org.apache.maven.plugins</groupId>
147-
<artifactId>maven-surefire-plugin</artifactId>
148-
<version>3.2.5</version>
149-
<configuration>
150-
<!--When using the maven-surefire-plugin or maven-failsafe-plugin you must not use a forkCount of 0 or set the forkMode to never as this would prevent the execution of the tests with the javaagent set and no coverage would be recorded.-->
151-
<forkCount>1</forkCount>
152-
<!-- this is required for test coverage-->
153-
<!-- <argLine>${argLine}</argLine>-->
154-
</configuration>
155-
</plugin>
156103
</plugins>
157104
</pluginManagement>
158105
<plugins>
@@ -182,16 +129,6 @@
182129
<enabled>true</enabled>
183130
</releases>
184131
</repository>
185-
<repository>
186-
<id>opentdf</id>
187-
<url>https://maven.pkg.github.com/opentdf/java-sdk</url>
188-
<snapshots>
189-
<enabled>true</enabled>
190-
</snapshots>
191-
<releases>
192-
<enabled>true</enabled>
193-
</releases>
194-
</repository>
195132
</repositories>
196133
<profiles>
197134
<profile>
@@ -258,5 +195,76 @@
258195
</plugins>
259196
</build>
260197
</profile>
198+
<profile>
199+
<id>coverage</id>
200+
<build>
201+
<plugins>
202+
<plugin>
203+
<groupId>org.jacoco</groupId>
204+
<artifactId>jacoco-maven-plugin</artifactId>
205+
<version>0.8.12</version>
206+
<executions>
207+
<execution>
208+
<id>jacoco-prepare-agent</id>
209+
<goals>
210+
<goal>prepare-agent</goal>
211+
</goals>
212+
</execution>
213+
<execution>
214+
<id>jacoco-prepare-agent-integration</id>
215+
<goals>
216+
<goal>prepare-agent-integration</goal>
217+
</goals>
218+
</execution>
219+
<execution>
220+
<id>jacoco-report</id>
221+
<goals>
222+
<goal>report</goal>
223+
</goals>
224+
<phase>test</phase>
225+
</execution>
226+
<execution>
227+
<id>check</id>
228+
<goals>
229+
<goal>check</goal>
230+
</goals>
231+
<configuration>
232+
<rules>
233+
<rule>
234+
<element>BUNDLE</element>
235+
<limits>
236+
<limit>
237+
<counter>LINE</counter>
238+
<value>COVEREDRATIO</value>
239+
<minimum>${jacoco.line.coverage}</minimum>
240+
</limit>
241+
</limits>
242+
</rule>
243+
</rules>
244+
</configuration>
245+
</execution>
246+
<execution>
247+
<id>report-aggregate</id>
248+
<phase>verify</phase>
249+
<goals>
250+
<goal>report-aggregate</goal>
251+
</goals>
252+
</execution>
253+
</executions>
254+
</plugin>
255+
<plugin>
256+
<groupId>org.apache.maven.plugins</groupId>
257+
<artifactId>maven-surefire-plugin</artifactId>
258+
<version>3.2.5</version>
259+
<configuration>
260+
<!--When using the maven-surefire-plugin or maven-failsafe-plugin you must not use a forkCount of 0 or set the forkMode to never as this would prevent the execution of the tests with the javaagent set and no coverage would be recorded.-->
261+
<forkCount>1</forkCount>
262+
<!-- this is required for test coverage-->
263+
<argLine>${argLine}</argLine>
264+
</configuration>
265+
</plugin>
266+
</plugins>
267+
</build>
268+
</profile>
261269
</profiles>
262270
</project>

settings.xml

-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,5 @@
77
<username>${env.GITHUB_ACTOR}</username>
88
<password>${env.GITHUB_TOKEN}</password>
99
</server>
10-
<server>
11-
<id>opentdf</id>
12-
<username>${env.GITHUB_ACTOR}</username>
13-
<password>${env.GITHUB_TOKEN}</password>
14-
</server>
1510
</servers>
1611
</settings>

0 commit comments

Comments
 (0)