Skip to content

Commit 85272ce

Browse files
gnodetclaude
andcommitted
CAMEL-23274: Add incremental coverage to SonarCloud PR analysis
Build on top of the core coverage from the base PR by adding per-module coverage for PR-affected components using the incremental-build action. Changes: - parent/pom.xml: Add jacoco:report goal to coverage profile so each tested module generates its own XML report at target/site/jacoco/jacoco.xml - pom.xml: Update sonar.coverage.jacoco.xmlReportPaths to include both per-module reports and the aggregated core report - sonar-build.yml: Add incremental-build step with -Dcoverage in MVND_OPTS to test PR-affected modules with JaCoCo - coverage/pom.xml: Add ContextValueFactory to MRJAR excludes Coverage strategy: - Core: aggregated report via coverage module (camel-core tests exercise classes across multiple core source modules) - Components: per-module reports (each component has its own classes and tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bd07701 commit 85272ce

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

.github/workflows/sonar-build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ 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+
# Core modules need the aggregated report because camel-core tests
63+
# exercise classes from camel-core-model, camel-core-processor, etc.
64+
- name: Run core tests with coverage
65+
run: >
66+
./mvnw verify -B -Dcoverage
67+
-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
68+
-Dmaven.test.failure.ignore=true
69+
70+
# Run tests on PR-affected modules with JaCoCo coverage.
71+
# Each component module generates its own per-module report
72+
# (target/site/jacoco/jacoco.xml) covering its own classes.
73+
- name: Run incremental tests with coverage
74+
uses: ./.github/actions/incremental-build
75+
with:
76+
pr-id: ${{ github.event.pull_request.number }}
77+
github-token: ${{ secrets.GITHUB_TOKEN }}
78+
artifact-upload-suffix: sonar
79+
env:
80+
MVND_OPTS: "-Dcoverage -Dmaven.test.failure.ignore=true"
81+
6182
- name: Prepare compiled classes artifact
6283
shell: bash
6384
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>

parent/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,13 @@
44964496
</excludes>
44974497
</configuration>
44984498
</execution>
4499+
<execution>
4500+
<id>report</id>
4501+
<phase>verify</phase>
4502+
<goals>
4503+
<goal>report</goal>
4504+
</goals>
4505+
</execution>
44994506
</executions>
45004507
</plugin>
45014508
<plugin>

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@
121121
<project.build.outputTimestamp>2026-02-17T16:11:10Z</project.build.outputTimestamp>
122122

123123
<!-- NOTE: this is required to correctly map each module coverage in Sonarqube. The ${maven.multiModuleProjectDirectory} may require some change
124-
when upgrading to Maven 4.x, according to any of the new variables that will replace this one. -->
124+
when upgrading to Maven 4.x, according to any of the new variables that will replace this one.
125+
Two sources: per-module reports (from jacoco:report) and the aggregated report (from coverage module). -->
125126
<sonar.coverage.jacoco.xmlReportPaths>
126-
${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
127+
${project.build.directory}/site/jacoco/jacoco.xml,${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
127128
</sonar.coverage.jacoco.xmlReportPaths>
128129

129130
<cyclonedx-maven-plugin-version>2.9.1</cyclonedx-maven-plugin-version>

0 commit comments

Comments
 (0)