Add sonar-project.properties for Java coverage on 7.4.x#1432
Open
Nitin Singh (nitsingh-ui) wants to merge 13 commits into7.4.xfrom
Open
Add sonar-project.properties for Java coverage on 7.4.x#1432Nitin Singh (nitsingh-ui) wants to merge 13 commits into7.4.xfrom
Nitin Singh (nitsingh-ui) wants to merge 13 commits into7.4.xfrom
Conversation
This adds SonarQube configuration to enable coverage reporting for Java code. Changes: - Add sonar-project.properties configured for Java - Set coverage path to JaCoCo XML reports - Configure Java binaries path for analysis The file was missing on 7.4.x branch, causing 0% coverage reports even though JaCoCo is generating coverage data during builds. Background: - JaCoCo generates coverage: utility-belt/target/site/jacoco/jacoco.xml - Java tests run: 16 tests in utility-belt module - Python tests are disabled (test Docker images, not code) This follows the pattern from schema-registry and other Java projects. Fixes: SonarQube coverage reporting Tested: Verified JaCoCo generates coverage in Semaphore builds
Enable SonarQube for common-docker with coverage exclusions for generated files, build artifacts, and test files to ensure accurate coverage reporting. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Python tests are disabled (docker.skip-test=true) and are Docker integration tests, not code tests. Excluding .py files focuses coverage on Java code only. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add || true to test-results artifact push in both AMD and ARM blocks to prevent race condition when blocks run in parallel. This ensures both blocks continue to push their target directories even if test-results push fails due to duplicate artifact. Without this fix, whichever block finishes second fails on test-results push and skips pushing its target directory, causing SonarQube to fail with 404 artifact not found error. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update paths to match artifact directory structure after pulling target-AMD and target-ARM artifacts in after_pipeline SonarQube job. Before: **/target/classes (doesn't exist after artifact pull) After: target-AMD/**/classes,target-ARM/**/classes This fixes the error: "No files nor directories matching '**/target/classes'" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Match schema-registry pattern using: - sonar.java.binaries=. (current directory) - sonar.coverage.jacoco.xmlReportPaths=**/jacoco.xml (glob pattern) This allows SonarQube to discover binaries and coverage reports regardless of artifact directory structure (target-AMD/target-ARM). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Move test exclusions from sonar.exclusions to coverage.exclusions only. This allows SonarQube to analyze test code for quality issues while excluding tests from coverage percentage calculation. Before: Tests completely excluded from all analysis After: Tests analyzed for code smells/bugs, excluded from coverage only Matches schema-registry proven pattern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Create jacoco-aggregate-common-docker module to generate XML coverage reports required by SonarQube. This module: - Aggregates coverage from utility-belt (only module with Java tests) - Generates jacoco.xml in parent target/site/jacoco/ directory - Runs during verify phase via report-aggregate goal Matches schema-registry pattern for multi-module coverage aggregation. Fixes: No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add explicit jacoco-maven-plugin configuration to parent pom.xml with: - prepare-agent: Attaches JaCoCo agent to test JVM - generate-code-coverage-report: Runs report goal to generate coverage This ensures JaCoCo generates both HTML and XML reports at module level, which the jacoco-aggregate module can then aggregate. Matches schema-registry parent POM pattern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add <relativePath>../pom.xml</relativePath> to parent section to tell Maven to use the local parent POM instead of trying to download from remote repositories. Fixes error: Non-resolvable parent POM for jacoco-aggregate-common-docker and 'parent.relativePath' points at wrong local POM Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove jacoco-aggregate-common-docker module that was causing build failure during ci-update-version phase. The module couldn't resolve parent POM before it was installed in the reactor. Use simpler approach: JaCoCo plugin in parent POM generates XML reports directly in each module's target/site/jacoco/ directory. The report goal generates both HTML and XML by default. SonarQube can find reports with sonar.coverage.jacoco.xmlReportPaths=**/jacoco.xml Fixes: Non-resolvable parent POM for jacoco-aggregate-common-docker Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…validation Created a simple Calculator utility with 9 methods and 100% test coverage to verify SonarQube is properly detecting and reporting code coverage for new code changes. This will help validate that: - JaCoCo is generating coverage data correctly - SonarQube scanner is finding the coverage reports - PR decoration shows coverage metrics for new code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add copyright header to both files - Fix indentation from 4 spaces to 2 spaces to match project style - Resolve all checkstyle errors for clean build Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
This PR adds
sonar-project.propertiesto enable SonarQube coverage reporting for Java code on the 7.4.x branch.Problem
sonar-project.propertiesfile is missing on 7.4.x (exists on master but configured for Python)utility-belt/target/site/jacoco/jacoco.xmlbut SonarQube doesn't know where to find itSolution
Add
sonar-project.propertiesconfigured for Java:sonar.language=java(changed from Python on master)sonar.coverage.jacoco.xmlReportPaths=**/target/site/jacoco/jacoco.xmlsonar.java.binaries=**/target/classesVerification
From build logs, we confirmed:
utility-belt/target/site/jacoco/jacoco.xmlAfter this PR:
Testing Plan
References
docker.skip-test=truein io.confluent:common parent POM