CI: Use JaCoCo for test coverage

This commit is contained in:
Arne Keller 2021-01-28 14:44:11 +01:00
parent e114e7e3f5
commit 5f2e07fd82
2 changed files with 25 additions and 21 deletions

View File

@ -2,8 +2,10 @@ build:
script:
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp checkstyle:check
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp test
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp cobertura:cobertura
- "head target/site/cobertura/coverage.xml | rg --only-matching -r '$1' 'line-rate=\"([0-9.]+)\"' | awk '{ print \"Test Coverage: \" $1 * 100 \"%\" }'"
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp jacoco:prepare-agent test jacoco:report
- python3 /opt/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura.xml
- python3 /opt/source2filename.py target/site/cobertura.xml
- "head -n 1 target/site/cobertura.xml | rg --only-matching -r '\$1' 'line-rate=\"([0-9.]+)\"' | awk '{ print \"Test Coverage: \" (\$1 * 100) \"%\" }'"
artifacts:
reports:
cobertura: target/site/cobertura/coverage.xml
cobertura: target/site/cobertura.xml

38
pom.xml
View File

@ -160,15 +160,16 @@
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check/>
<formats>
<format>xml</format>
</formats>
</configuration>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
@ -283,15 +284,16 @@
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check/>
<formats>
<format>xml</format>
</formats>
</configuration>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>