This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 01a1627ba395 CAMEL-23274: Enable JaCoCo coverage in SonarCloud PR 
analysis (#22468)
01a1627ba395 is described below

commit 01a1627ba395d5bebcce343ed1659367a7e0a116
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Apr 7 13:28:52 2026 +0200

    CAMEL-23274: Enable JaCoCo coverage in SonarCloud PR analysis (#22468)
    
    The SonarCloud PR analysis always reported 0% coverage because the
    sonar-build workflow built with -Dquickly (skipping all tests) and
    never activated the coverage profile.
    
    Add a second Maven step that runs core module tests with -Dcoverage,
    then generates the aggregated JaCoCo report via the coverage module.
    All core source modules are included in the reactor so report-aggregate
    can map execution data from camel-core tests to their classes.
    
    Also add ContextValueFactory to the JaCoCo multi-release JAR excludes
    in coverage/pom.xml (same issue as the existing CamelThreadFactory
    exclude).
    
    Tested locally: produces a 12 MB aggregated report with ~63% line
    coverage across 2452 classes in 13 core modules.
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .github/workflows/sonar-build.yml | 12 ++++++++++++
 coverage/pom.xml                  |  1 +
 2 files changed, 13 insertions(+)

diff --git a/.github/workflows/sonar-build.yml 
b/.github/workflows/sonar-build.yml
index bbff7b1ebfae..882bc2d58adf 100644
--- a/.github/workflows/sonar-build.yml
+++ b/.github/workflows/sonar-build.yml
@@ -58,6 +58,18 @@ jobs:
       - name: Build with Maven
         run: ./mvnw install -B -Dquickly
 
+      # Run core tests with JaCoCo and generate aggregated coverage report.
+      # The source modules must be in the reactor so report-aggregate can
+      # map execution data from camel-core tests to their classes.
+      # TODO: Once incremental-build.sh supports module detection in the sonar
+      #       workflow, replace the hardcoded -pl with detected affected 
modules
+      #       to get coverage on components too (see PR #22247).
+      - name: Run tests with coverage and generate report
+        run: >
+          ./mvnw verify -B -Dcoverage
+          -pl 
core/camel-api,core/camel-util,core/camel-support,core/camel-management-api,core/camel-management,core/camel-base,core/camel-base-engine,core/camel-core-engine,core/camel-core-languages,core/camel-core-model,core/camel-core-processor,core/camel-core-reifier,core/camel-core,coverage
+          -Dmaven.test.failure.ignore=true
+
       - name: Prepare compiled classes artifact
         shell: bash
         run: find . -name "target" -type d | tar -czf target.tar.gz -T -
diff --git a/coverage/pom.xml b/coverage/pom.xml
index 8a1f698bb057..77e8d32d263f 100644
--- a/coverage/pom.xml
+++ b/coverage/pom.xml
@@ -2650,6 +2650,7 @@
                                     <!-- Workaround to multi-release jar 
https://github.com/jacoco/jacoco/issues/407 -->
                                     <excludes>
                                         
<exclude>**/CamelThreadFactory*</exclude>
+                                        
<exclude>**/ContextValueFactory*</exclude>
                                     </excludes>
                                 </configuration>
                             </execution>

Reply via email to