ci: add SonarCloud analysis with JaCoCo coverage - #109
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds SonarCloud analysis (project
nyg_kraken-api-java) with JaCoCo coverage, following the setup used in jmxsh and wiktionary-to-kindle.Changes
jacoco-maven-plugin0.8.15 (prepare-agent, andreportin the defaultverifyphase) andsonar-maven-plugin5.7.0.6970, pinned so Renovate can bump it. Adds the SonarCloud organization, project key and host URL. The JaCoCo XML report path uses${project.build.directory}, which resolves per module, so thelibrarymodule reports its ownlibrary/target/site/jacoco/jacoco.xml.examplesmodule: setssonar.skip. It is demo code, has no tests and is not published, so analysing it would only pull coverage down.pr-build.ymlbecomesjava-ci.yaml(namedJava CI, like the other repositories). It now also runs on pushes tomaster, which gives SonarCloud the main-branch baseline that PRs are compared against, and onworkflow_dispatch. It checks out the full history (fetch-depth: 0) for new-code detection, caches Maven dependencies and runsmvn clean verifyinstead ofpackage, because the JaCoCo report is created inverify. The job is still namedbuild.AGENTS.md: updates the CI description.Design notes
mvn clean verify sonar:sonarinvocation, not in two steps as in wiktionary-to-kindle. That project has one module. Here, a standalonemvn sonar:sonarwould have to resolve thekraken-apisnapshot for theexamplesmodule, but the snapshot is neither in the runner's local repository nor packaged in that Maven session.sonar:sonargoal is only added whenSONAR_TOKENis set, so PRs from forks and Dependabot, which get no secrets, still build and test.<argLine>, so it picks up the JaCoCo agent through theargLineproperty thatprepare-agentsets.Validation
mvn clean verify sonar:sonar -Dsonar.skip=truelocally on Temurin 25: all 594 tests pass andlibrary/target/site/jacoco/jacoco.xmlis generated (95.5% line coverage, 85.5% branch coverage). Theexamplesmodule produces no report because it has no tests. The Sonar plugin resolves and runs from the reactor root.