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

Add Jacoco #274

wants to merge 6 commits into from

Conversation

karicordes
Copy link
Contributor

Added commands to Dockerfile to generate jacoco .exec file, and commands to .circleci/config.yml to generate xml report from .exec file

Fixes #255

Copy link
Collaborator

@dlamoris dlamoris left a comment

Choose a reason for hiding this comment

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

also can you add the line
sonar.coverage.jacoco.xmlReportPaths=jacocoOutput/jacocoXMLReport
in sonar-project.properties, this should let sonarcloud find the report

docker stop mms
mkdir -p jacocoOutput
docker cp mms:/mms/jacocoOutput/jacoco-it.exec ./jacocoOutput/jacoco-it.exec
cp -r ./*/build/classes/* TEMPORARYclassfiles/
Copy link
Collaborator

Choose a reason for hiding this comment

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

because the class files aren't actually built here, you want to run the cli report in the scan job, after the the run step - instead of checkout in scan, you can attach workspace (like the deploy_snasphot job)
also you want to get only the build/classes/java/main so it doesn't count test files

Copy link
Collaborator

Choose a reason for hiding this comment

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

add requires: build_and_test to scan in the workflows section so scan comes after build_and_test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Thank you!

./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)

@@ -5,5 +5,6 @@ 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"]
COPY jacocoJars/jacocoagent.jar ./jacocoagent.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

@dlamoris
Copy link
Collaborator

the sonarcloud context wasn't working with a pr from a fork, i pushed this branch to the main repo with #275 will merge that instead

@dlamoris dlamoris closed this Mar 12, 2024
@karicordes karicordes deleted the jacoco branch March 12, 2024 22:13
@dlamoris dlamoris mentioned this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add jacoco
2 participants