Skip to content

Commit 01a1627

Browse files
gnodetclaude
andauthored
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 <noreply@anthropic.com>
1 parent edfd783 commit 01a1627

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/sonar-build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ jobs:
5858
- name: Build with Maven
5959
run: ./mvnw install -B -Dquickly
6060

61+
# Run core tests with JaCoCo and generate aggregated coverage report.
62+
# The source modules must be in the reactor so report-aggregate can
63+
# map execution data from camel-core tests to their classes.
64+
# TODO: Once incremental-build.sh supports module detection in the sonar
65+
# workflow, replace the hardcoded -pl with detected affected modules
66+
# to get coverage on components too (see PR #22247).
67+
- name: Run tests with coverage and generate report
68+
run: >
69+
./mvnw verify -B -Dcoverage
70+
-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
71+
-Dmaven.test.failure.ignore=true
72+
6173
- name: Prepare compiled classes artifact
6274
shell: bash
6375
run: find . -name "target" -type d | tar -czf target.tar.gz -T -

coverage/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,7 @@
26502650
<!-- Workaround to multi-release jar https://github.com/jacoco/jacoco/issues/407 -->
26512651
<excludes>
26522652
<exclude>**/CamelThreadFactory*</exclude>
2653+
<exclude>**/ContextValueFactory*</exclude>
26532654
</excludes>
26542655
</configuration>
26552656
</execution>

0 commit comments

Comments
 (0)