CAMEL-22752: Add SonarCloud PR analysis workflows#22346
Open
gnodet wants to merge 2 commits intoapache:mainfrom
Open
CAMEL-22752: Add SonarCloud PR analysis workflows#22346gnodet wants to merge 2 commits intoapache:mainfrom
gnodet wants to merge 2 commits intoapache:mainfrom
Conversation
Add two-workflow pattern for secure SonarCloud analysis on pull requests, including PRs from forks: - sonar-build.yml: triggered on pull_request, builds the project and uploads compiled classes + PR metadata as artifacts (no secrets needed) - sonar-scan.yml: triggered on workflow_run completion, downloads artifacts and runs sonar:sonar with access to SONARCLOUD_TOKEN secret This follows the same pattern used by Apache Ignite (IGNITE-20466) and Apache Kvrocks for safe SonarCloud analysis on fork PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
oscerd
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two-workflow pattern for secure SonarCloud analysis on pull requests (including PRs from forks):
sonar-build.yml: triggered onpull_request, builds the project withmvn install -Dquicklyand uploads compiled classes + PR metadata as artifacts. No secrets needed.sonar-scan.yml: triggered onworkflow_runcompletion ofSonarBuild, downloads artifacts and runssonar:sonarin the main repo context with access toSONAR_TOKENsecret.This follows the same pattern used by Apache Ignite (IGNITE-20466) and Apache Kvrocks for safe SonarCloud analysis on fork PRs.
How it works
SonarBuildruns (no secrets, just compiles and uploads artifacts)SonarBuildcompletes →Sonar Quality Pull Request Analysistriggers viaworkflow_run(has access toSONAR_TOKEN)Design decision: separate build vs merging into existing PR build
The
SonarBuildworkflow is kept separate from the existingBuild and testworkflow (pr-build-main.yml). The trade-off:mvn install -Dquickly(lightweight)regen.sh(full regen,git clean -fdx)Merging is possible later if CI cost is a concern. Open to feedback on this.
Prerequisites
SONAR_TOKENsecret: already configured ✅apache_camelunder theapacheorganization: already exists ✅Tested on
Validated end-to-end on gnodet/camel#10 — SonarCloud successfully posted quality gate results on the PR.
Test plan
SONAR_TOKENis available in apache/camel secrets