Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/incremental-build/incremental-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,27 @@ main() {
$mavenBinary -l "$log" $MVND_OPTS install -pl "$build_pl" || ret=$?
fi

# ── Step 4b: Aggregated core coverage report ──
# When coverage is enabled and core modules were tested, generate the
# aggregated JaCoCo report via the coverage module. This is needed because
# camel-core tests exercise classes from camel-core-model, camel-core-processor,
# etc., so per-module reports alone miss cross-module coverage.
if [[ "${MVND_OPTS:-}" == *"-Dcoverage"* ]]; then
local core_tested=false
for w in $(echo "$final_pl" | tr ',' '\n'); do
if [[ "$w" == core/* ]]; then
core_tested=true
break
fi
done
if [[ "$core_tested" == true ]]; then
echo ""
echo "Core modules affected — generating aggregated coverage report..."
$mavenBinary verify -B -Dcoverage -pl coverage -am -DskipTests \
|| echo "WARNING: Coverage aggregation failed (non-fatal)"
fi
fi

# ── Step 5: Write comment and summary ──
local comment_file="incremental-test-comment.md"
writeComment "$comment_file" "$pl" "$dep_module_ids" "$all_changed_props" "$testedDependents" "$extraModules"
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/sonar-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ concurrency:

jobs:
build:
# Temporarily disabled until SonarCloud quality gate is adjusted (INFRA-27808)
if: false && github.repository == 'apache/camel'
if: github.repository == 'apache/camel'
name: Build for Sonar Analysis
runs-on: ubuntu-latest
steps:
Expand All @@ -59,17 +58,19 @@ 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
# Run tests on PR-affected modules with JaCoCo coverage.
# Per-module reports are generated by jacoco:report (added in parent pom).
# When core modules are affected, the incremental build also generates
# the aggregated coverage report via the coverage module.
- name: Run incremental tests with coverage
uses: ./.github/actions/incremental-build
with:
pr-id: ${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
artifact-upload-suffix: sonar
env:
MVND_OPTS: "-Dcoverage -Dmaven.test.failure.ignore=true"


- name: Prepare compiled classes artifact
shell: bash
Expand Down
7 changes: 7 additions & 0 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4502,6 +4502,13 @@
</excludes>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@

<sonar.java.source>${jdk.version}</sonar.java.source>
<!-- NOTE: this is required to correctly map each module coverage in Sonarqube. The ${maven.multiModuleProjectDirectory} may require some change
when upgrading to Maven 4.x, according to any of the new variables that will replace this one. -->
when upgrading to Maven 4.x, according to any of the new variables that will replace this one.
Two sources: per-module reports (from jacoco:report) and the aggregated report (from coverage module). -->
<sonar.coverage.jacoco.xmlReportPaths>
${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
${project.build.directory}/site/jacoco/jacoco.xml,${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
<sonar.cpd.exclusions>
components/camel-jackson3/**,components/camel-jackson3xml/**,components/camel-test/camel-test-junit6/**
Expand Down
Loading