-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add Jacoco #274
Conversation
There was a problem hiding this 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
.circleci/config.yml
Outdated
docker stop mms | ||
mkdir -p jacocoOutput | ||
docker cp mms:/mms/jacocoOutput/jacoco-it.exec ./jacocoOutput/jacoco-it.exec | ||
cp -r ./*/build/classes/* TEMPORARYclassfiles/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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 |
Added commands to Dockerfile to generate jacoco .exec file, and commands to .circleci/config.yml to generate xml report from .exec file
Fixes #255