Skip to content

Commit 8212555

Browse files
committed
Add sonar coverage reporting to master build
1 parent 0280663 commit 8212555

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

.github/workflows/maven.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
env:
1313
OSS_USERNAME: ${{ secrets.OSS_USERNAME }}
1414
OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}
15+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1516

1617
jobs:
1718
build:
@@ -40,7 +41,11 @@ jobs:
4041
restore-keys: |
4142
${{ runner.os }}-maven-
4243
- name: Run tests
43-
run: ./mvnw -V -B -ntp -ff verify
44+
run: ./mvnw -V -B -ntp -ff verify jacoco:report
45+
- name: Static Analysis (Sonar)
46+
# Sonar will require at least Java 11 soon.
47+
if: matrix.java_version == '11'
48+
run: ./mvnw -B -ntp -ff jacoco:report-aggregate org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=OpenAPITools_openapi-diff -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.branch.name=${GITHUB_REF##*/}
4449
- name: Release Snapshot
4550
if: matrix.java_version == '11'
4651
run: ./mvnw -V -B -ntp -ff deploy

pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@
306306
<version>1.6.8</version>
307307
<extensions>true</extensions>
308308
</plugin>
309+
<plugin>
310+
<groupId>org.jacoco</groupId>
311+
<artifactId>jacoco-maven-plugin</artifactId>
312+
<version>0.8.6</version>
313+
</plugin>
309314
</plugins>
310315
</pluginManagement>
311316
<plugins>
@@ -347,6 +352,51 @@
347352
</execution>
348353
</executions>
349354
</plugin>
355+
<plugin>
356+
<groupId>org.jacoco</groupId>
357+
<artifactId>jacoco-maven-plugin</artifactId>
358+
<executions>
359+
<execution>
360+
<id>jacoco-initialize</id>
361+
<goals>
362+
<goal>prepare-agent</goal>
363+
</goals>
364+
</execution>
365+
<execution>
366+
<id>jacoco-site</id>
367+
<phase>test</phase>
368+
<goals>
369+
<goal>report</goal>
370+
</goals>
371+
</execution>
372+
<execution>
373+
<id>default-check</id>
374+
<goals>
375+
<goal>check</goal>
376+
</goals>
377+
<configuration>
378+
<rules>
379+
<rule>
380+
<element>PACKAGE</element>
381+
<limits>
382+
<limit>
383+
<counter>LINE</counter>
384+
<value>COVEREDRATIO</value>
385+
<minimum>0</minimum>
386+
</limit>
387+
</limits>
388+
</rule>
389+
</rules>
390+
</configuration>
391+
</execution>
392+
</executions>
393+
<configuration>
394+
<excludes>
395+
<!-- Example: -->
396+
<!-- <exclude>**/gradle-wrapper.jar</exclude> -->
397+
</excludes>
398+
</configuration>
399+
</plugin>
350400
</plugins>
351401
</build>
352402
</project>

0 commit comments

Comments
 (0)