From 5f2e07fd82519fe62d05cd5e876a68f116d93227 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 28 Jan 2021 14:44:11 +0100 Subject: [PATCH] CI: Use JaCoCo for test coverage --- .gitlab-ci.yml | 8 +++++--- pom.xml | 38 ++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4d02ff..b493f11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/pom.xml b/pom.xml index 7851b52..099b987 100644 --- a/pom.xml +++ b/pom.xml @@ -160,15 +160,16 @@ 2.22.2 - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - - xml - - + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + + prepare-agent + + + @@ -283,15 +284,16 @@ - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - - xml - - + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + + report + + +