diff --git a/.circleci/config.yml b/.circleci/config.yml index c573fef52..54171256a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,6 +24,9 @@ jobs: name: "Create and start all services from the docker-compose configuration" command: | cp example/src/main/resources/application.properties.example ./example/src/main/resources/application.properties + mkdir -p jacocoJars + curl -L -o ./jacocoJars/jacocoagent.jar "https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.7/org.jacoco.agent-0.8.7-runtime.jar" + curl -L -o ./jacocoJars/jacococli.jar "https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jacoco.cli-0.8.7-nodeps.jar" docker-compose up --build -d docker run --network container:mms curlimages/curl --retry 8 --retry-delay 10 --retry-max-time 90 --retry-connrefused http://mms:8080/healthcheck @@ -43,6 +46,10 @@ jobs: docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run artifacts.postman_collection.json -e test-env.json --delay-request 500 docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run elastic.postman_collection.json -e test-env.json --delay-request 500 docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run groups.postman_collection.json -e test-env.json --delay-request 500 + + docker stop mms + mkdir -p jacocoOutput + docker cp mms:/mms/jacocoOutput/jacoco-it.exec ./jacocoOutput/jacoco-it.exec - persist_to_workspace: root: /home/circleci/ @@ -53,10 +60,17 @@ jobs: executor: openjdk_executor working_directory: /home/circleci/mms steps: - - checkout + - attach_workspace: + at: ~/ - run: name: Build classes to scan - command: ./gradlew build -x test + command: | + ./gradlew build -x test + mkdir -p TEMPORARYclassfiles + cp -r */build/classes/java/main/* TEMPORARYclassfiles/ + java -jar jacocoJars/jacococli.jar report jacocoOutput/jacoco-it.exec --classfiles TEMPORARYclassfiles/ --xml ./jacocoOutput/jacocoXMLReport + rm -r TEMPORARYclassfiles + - sonarcloud/scan deploy_snapshot: @@ -87,6 +101,8 @@ workflows: tags: only: /[0-9.]+(-(a|b|rc)[0-9]+)?/ - scan: + requires: + - build_and_test filters: tags: only: /[0-9.]+(-(a|b|rc)[0-9]+)?/ diff --git a/Dockerfile b/Dockerfile index e027f83cd..d7fdacdfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,5 @@ RUN ./gradlew --no-daemon bootJar --warning-mode all RUN find . -type f -name example-*.jar -not -iname '*javadoc*' -not -iname '*sources*' -exec cp '{}' '/app.jar' ';' ENV JDK_JAVA_OPTIONS "-XX:MaxRAMPercentage=90.0" -ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "-jar", "/app.jar"] +ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "-javaagent:jacocoJars/jacocoagent.jar=destfile=jacocoOutput/jacoco-it.exec,output=file", "-jar", "/app.jar"] EXPOSE 8080 diff --git a/sonar-project.properties b/sonar-project.properties index b3bfa8103..581029b1d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,3 +2,4 @@ sonar.projectKey=Open-MBEE_exec-mms sonar.organization=openmbee sonar.language=java sonar.java.binaries=**/build/classes/java/main +sonar.coverage.jacoco.xmlReportPaths=jacocoOutput/jacocoXMLReport \ No newline at end of file