Skip to content
Snippets Groups Projects
Commit 61384c5e authored by Fotis Soldatos's avatar Fotis Soldatos
Browse files

ci(automation): integrate visualize_coverage to unit_test job

parent 487277b5
No related branches found
No related tags found
1 merge request!54Release 2.0.0
...@@ -22,7 +22,7 @@ build automation: ...@@ -22,7 +22,7 @@ build automation:
unit_test automation: unit_test automation:
variables: variables:
REPORTS_CONTAINER: "${IMAGE_NAME}-reports" REPORTS_CONTAINER: "${IMAGE_NAME}-reports"
stage: test stage: unit_test
needs: needs:
- build automation - build automation
before_script: before_script:
...@@ -37,6 +37,7 @@ unit_test automation: ...@@ -37,6 +37,7 @@ unit_test automation:
- docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/jacoco.xml ${REPORTS_PATH}/jacoco.xml - docker cp ${REPORTS_CONTAINER}:/app/target/site/jacoco/jacoco.xml ${REPORTS_PATH}/jacoco.xml
- docker cp ${REPORTS_CONTAINER}:/app/target/surefire-reports/ ${REPORTS_PATH}/ - docker cp ${REPORTS_CONTAINER}:/app/target/surefire-reports/ ${REPORTS_PATH}/
- cat ${REPORTS_PATH}/coverage.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/JaCoCo Coverage Total:/' - cat ${REPORTS_PATH}/coverage.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/JaCoCo Coverage Total:/'
- docker run -v "$(pwd)/src/${IMAGE_NAME}:/${IMAGE_NAME}" --rm registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 python /opt/cover2cover.py ${IMAGE_NAME}/reports/jacoco.xml ${IMAGE_NAME}/src/main/java > ${REPORTS_PATH}/cobertura.xml
# Build final image # Build final image
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release
- docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
...@@ -46,11 +47,8 @@ unit_test automation: ...@@ -46,11 +47,8 @@ unit_test automation:
- docker rm -f "$IMAGE_NAME:$IMAGE_TAG" - docker rm -f "$IMAGE_NAME:$IMAGE_TAG"
coverage: '/JaCoCo Coverage Total: ([0-9]{1,3})%/' coverage: '/JaCoCo Coverage Total: ([0-9]{1,3})%/'
artifacts: artifacts:
when: always
paths:
- ${REPORTS_PATH}/jacoco.xml
- ${REPORTS_PATH}/coverage.html
reports: reports:
cobertura: ${REPORTS_PATH}/cobertura.xml
junit: junit:
- ${REPORTS_PATH}/surefire-reports/TEST-*.xml - ${REPORTS_PATH}/surefire-reports/TEST-*.xml
rules: rules:
...@@ -61,26 +59,6 @@ unit_test automation: ...@@ -61,26 +59,6 @@ unit_test automation:
- manifests/${IMAGE_NAME}service.yaml - manifests/${IMAGE_NAME}service.yaml
- .gitlab-ci.yml - .gitlab-ci.yml
visualize_coverage automation:
stage: unit_test
needs:
- unit_test automation
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- stat ${REPORTS_PATH}/jacoco.xml || true
- docker run -v "$(pwd)/src/${IMAGE_NAME}:/${IMAGE_NAME}" --rm registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 python /opt/cover2cover.py ${IMAGE_NAME}/reports/jacoco.xml ${IMAGE_NAME}/src/main/java > ${REPORTS_PATH}/cobertura.xml
artifacts:
reports:
cobertura: ${REPORTS_PATH}/cobertura.xml
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
- changes:
- src/$IMAGE_NAME/**
- manifests/${IMAGE_NAME}service.yaml
- .gitlab-ci.yml
# Deployment of automation service in Kubernetes Cluster # Deployment of automation service in Kubernetes Cluster
deploy automation: deploy automation:
stage: deploy stage: deploy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment