From ac17921a6334ab74da0ecc1d5ef21185dd14986d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Kristoffer=20Tveit?= Date: Wed, 24 Feb 2021 00:03:53 +0100 Subject: [PATCH] Add gitlab coverage report --- .gitlab-ci.yml | 42 ++++++++++++++++++++++++++++++++++++++---- pom.xml | 30 +++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc4e231..0c28876 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,8 +22,11 @@ cache: stages: - build - test + - coverage + - report + - deploy -build-job: +build: stage: build script: - "mvn clean compile $MAVEN_CLI_OPTS" @@ -31,10 +34,9 @@ build-job: paths: - target/ -unittest-job: +unittest: stage: test - dependencies: - - build-job + needs: [build] script: - "mvn package $MAVEN_CLI_OPTS" artifacts: @@ -46,7 +48,39 @@ unittest-job: - target/surefire-reports/TEST-*.xml - target/failsafe-reports/TEST-*.xml +generate-coverage: + stage: coverage + script: + - 'mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report' + artifacts: + paths: + - target/site/ + - target/site/jacoco/jacoco.xml +report-coverage: + stage: report + image: haynes/jacoco2cobertura:1.0.4 + script: + # convert report from jacoco to cobertura + - 'python /opt/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura.xml' + # read the tag and prepend the path to every filename attribute + - 'python /opt/source2filename.py target/site/cobertura.xml' + needs: [generate-coverage] + artifacts: + reports: + cobertura: target/site/cobertura.xml + +pages: + stage: deploy + needs: [generate-coverage] + script: + - mv target/site/* public/ + artifacts: + paths: + - public + expire_in: 30 days + only: + - master # integrationtest-job: # stage: test diff --git a/pom.xml b/pom.xml index 342d0cd..404a641 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,12 @@ maven-surefire-plugin 3.0.0-M5 - --enable-preview + @{argLine} --enable-preview + 1 + true + @@ -101,6 +106,29 @@ app.Main + + + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + + +