Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jacoco #274

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to replace -checkout with attach_workspace at line 63 to carry over files from build step (you can see steps that are failing on the conversation page, the link will take you to circleci page that shows more details as it runs)

rm -r TEMPORARYclassfiles

- sonarcloud/scan

deploy_snapshot:
Expand Down Expand Up @@ -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]+)?/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double check the javaagent location inside the container, the copy step copies it into this directory

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think line 8's copy is actually redundant since line 2 already copies everything

EXPOSE 8080
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading