CAMEL-22752: Add SonarCloud PR analysis workflows#22346
CAMEL-22752: Add SonarCloud PR analysis workflows#22346gnodet 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>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
squakez
left a comment
There was a problem hiding this comment.
A few considerations:
- the sonar scan is not running, so cannot evaluate how long this is taking to complete a code analysis and what kind of data we have there.
- How do we evaluate the success metric of an analysis? we miss to get back the result of the execution and, above all, a comparison with a scan on the branch where we're asking to merge.
- AFAIK the sonar token is not going to be available for the PR for security reason, not sure the trick to bypass it via a task succession is really going to work.
- Number of execution the sonar server can handle: I doubt we can handle tens of execution per day on the server (we have many PRs pushed daily, above all lately...). The operation is costly and we may be capped on the sonar server for sure.
|
CAMEL-22752 was closed, so, I don't understand the insistence of picking up closed issues and working on tasks that have clearly marked as no longer needed. In order to provide more context, I've created a new issue CAMEL-23274 where I explain which could be the potential alternative viable approaches: there are important constraints to evaluate though. However, the priority is lower and we have much more important tasks to dedicate our effort IMO. |
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