Hi all,

You may have noticed that SonarCloud comments on IoTDB PRs previously
always displayed 0.0% Coverage on New Code, even when the PR had full unit
test coverage on Codecov.

We investigated this and addressed the underlying gaps in PR #19376 [1]:
*Root Causes*

   1. *Disconnected CI jobs:* In .github/workflows/sonar-codecov.yml,
   codecov and sonar ran independently in parallel. The sonar job ran mvn
   verify sonar:sonar -DskipTests without receiving the JaCoCo XML report
   generated by codecov.
   2. *Broken report path & server-side exclusion:* pom.xml set
   sonar.coverage.jacoco.xmlReportPaths to
   target/jacoco-merged-reports/jacoco.xml (which does not exist in
   submodules), while SonarCloud's project UI also had
sonar.coverage.exclusions
   = *, **/*, causing all modules to report zero coverable lines.
   3. *Incomplete coverage aggregation:*
   code-coverage/copy-code-coverage-sources.sh only collected coverage from
   iotdb-core/* and iotdb-client/*, omitting modules under iotdb-api/*,
   iotdb-core/metrics/*, library-udf, and external-service-impl/*.

*What Changed (PR #19376)*

   - *Reuse JaCoCo report from codecov in sonar:* codecov now uploads
   code-coverage/target/jacoco-merged-reports/jacoco.xml as a 1-day
   workflow artifact, and sonar (needs: [codecov]) downloads it outside the
   workspace (${{ runner.temp }}/sonar-coverage/jacoco.xml) and passes it
   via -Dsonar.coverage.jacoco.xmlReportPaths=...—avoiding duplicate unit
   test execution.
   - *Graceful fallback on codecov failure:* The sonar job uses !cancelled()
   gating and only passes the coverage report when available, so static
   analysis still runs even if a unit test fails in codecov.
   - *Fixed pom.xml Sonar coverage properties:* Added
   
<sonar.coverage.exclusions>**/generated-sources/**</sonar.coverage.exclusions>
   to override the server-side *, **/* setting, and updated
   sonar.coverage.jacoco.xmlReportPaths to resolve the merged report across
   all submodules.
   - *Expanded JaCoCo collection:* Updated
   code-coverage/copy-code-coverage-sources.sh to include iotdb-api/*,
   iotdb-core/metrics/*, library-udf, and external-service-impl/* (skipping
   generated-only modules such as external-service-impl/rest-openapi).

*Verification & What to Expect*

   - Verified end-to-end on a temporary verification PR (#19380 [2]):
   SonarCloud PR decoration now reports real New Code coverage (100.0%
   Coverage on New Code instead of 0.0%), and the expanded aggregation also
   raised merged project coverage on Codecov from 49.60% to 49.92% (+1,398
   covered lines).
   - *CI timing trade-off:* Because sonar now reuses the JaCoCo report from
   codecov, SonarCloud results on PRs with Java changes will appear after
   codecov finishes rather than running in parallel. PRs without analyzable
   src/main/java changes continue to skip the SonarCloud scan as before.
   - (Optional note for SonarCloud admins: pom.xml already overrides the
   legacy sonar.coverage.exclusions = *, **/* setting, and it can also be
   removed from the SonarCloud UI at convenience.)

Feedback and suggestions are welcome!


[1] iotdb#19376 <https://github.com/apache/iotdb/pull/19376>

[2] iotdb#19380 <https://github.com/apache/iotdb/pull/19380>



Best regards,

-----------------------

Yuan Tian

Reply via email to