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: script:
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp checkstyle:check - 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 test
- mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp cobertura:cobertura - mvn -Dmaven.repo.local=/tmp/m2/repository -Duser.home=/tmp jacoco:prepare-agent test jacoco:report
- "head target/site/cobertura/coverage.xml | rg --only-matching -r '$1' 'line-rate=\"([0-9.]+)\"' | awk '{ print \"Test Coverage: \" $1 * 100 \"%\" }'" - 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: artifacts:
reports: 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> <version>2.22.2</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.jacoco</groupId>
<artifactId>cobertura-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>2.7</version> <version>0.8.6</version>
<configuration> <executions>
<check/> <execution>
<formats> <goals>
<format>xml</format> <goal>prepare-agent</goal>
</formats> </goals>
</configuration> </execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
@ -283,15 +284,16 @@
<reporting> <reporting>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.jacoco</groupId>
<artifactId>cobertura-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>2.7</version> <version>0.8.6</version>
<configuration> <reportSets>
<check/> <reportSet>
<formats> <reports>
<format>xml</format> <report>report</report>
</formats> </reports>
</configuration> </reportSet>
</reportSets>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>