chore: run SonarCloud analysis immediately on PRs#496
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restructures CI so SonarCloud analysis runs as its own early job in the main CI/CD workflow rather than being executed as a step inside the reusable test workflow.
Changes:
- Add a dedicated
sonarcloudjob to.github/workflows/ci-cd.ymland gate downstream checks on it. - Remove Sonar scan execution (and the
SONAR_TOKENsecret wiring) from the reusable.github/workflows/_test.ymlworkflow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| .github/workflows/ci-cd.yml | Introduces a standalone Sonar scan job and makes later workflow gates depend on it. |
| .github/workflows/_test.yml | Removes Sonar scan from the test workflow and drops the related secret input. |
Comments suppressed due to low confidence (1)
.github/workflows/_test.yml:268
- This comment still says “all reporting steps (Codecov, SonarQube, artifact upload)”, but the SonarQube scan step was removed from this workflow. Please update the wording so it matches the actual steps (or reference the new
sonarcloudjob if that’s what you intend).
# Single gate that fails the job if any test suite failed. Kept last so
# that all reporting steps (Codecov, SonarQube, artifact upload) always
# run to completion before the job is marked as failed.
af3857f to
c2794f1
Compare
|
PR Review: SonarCloud Analysis Optimization ✅SummaryThis PR successfully refactors the SonarCloud integration to run as an independent job in the main CI/CD pipeline instead of being embedded within the test workflow. This is an excellent architectural improvement that provides: ✅ Immediate feedback - SonarCloud analysis starts immediately without waiting for tests Critical Checks: PASSED ✅1. Commit Convention ✅
2. CI Status ✅All checks are passing:
3. Documentation Alignment ✅The changes align with .github/CLAUDE.md:
Technical Analysis1. Workflow Changes (.github/workflows/ci-cd.yml)Added: Independent sonarcloud:
needs: [get-commit-message]
# Runs in parallel with lint, audit, test, codeql
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # ✅ Correct: For PR decorations
statuses: write # ✅ Correct: For commit status checksBenefits:
Updated: needs: [get-commit-message, lint, audit, test, codeql, sonarcloud]✅ Correct: Medical device compliance reporting now waits for SonarCloud (quality gate requirement) 2. Test Workflow Simplification (.github/workflows/_test.yml)Removed: SonarQube Scan Step (lines 267-274 deleted) - - name: SonarQube Scan
- if: ...
- uses: SonarSource/sonarqube-scan-action@...
- env:
- GITHUB_TOKEN: ...
- SONAR_TOKEN: ...✅ Correct: Test workflow no longer responsible for SonarCloud analysis Removed: SONAR_TOKEN Secret Input (lines 28-29 deleted) ✅ Correct: Token now passed directly in ci-cd.yml job (line 156) 3. SonarCloud Configuration (sonar-project.properties)Removed: Coverage Report Path (line 9 deleted) -sonar.python.coverage.reportPaths=reports/coverage.xmlImpact Analysis: According to SonarQube documentation, However, this may be intentional because:
Recommendation: If coverage in SonarCloud is desired, you have two options: Option A: Add coverage as a separate job (after tests complete) sonarcloud_coverage:
needs: [test, sonarcloud]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@...
with:
fetch-depth: 0
- name: Download coverage artifacts
uses: actions/download-artifact@...
with:
name: test-results-ubuntu-latest
- name: SonarCloud with Coverage
uses: SonarSource/sonarqube-scan-action@...
env:
SONAR_TOKEN: ...Option B: Keep current approach (faster feedback, use Codecov for coverage) Given the PR goal of "immediate analysis", Option B (current approach) is correct. Architecture Compliance ✅CI/CD Pipeline UpdateBefore: After: ✅ Improvement: SonarCloud is now a first-class citizen in the quality gate pipeline Performance ImpactTimeline Comparison: Before:
After:
✅ 15 minute improvement in code quality feedback! Security & Compliance ✅Permissions Reviewpermissions:
contents: read # ✅ Minimal: Read code only
pull-requests: write # ✅ Required: Decorate PRs with findings
statuses: write # ✅ Required: Update commit status✅ Follows principle of least privilege Secret Handling
Medical Device Compliance (Ketryx)
Recommendations1. Update .github/CLAUDE.md Workflow Diagram (Optional)The workflow architecture diagram could be updated to show SonarCloud as a parallel job, but this is NOT blocking - the change is already documented in the secrets section. 2. Consider Adding Coverage Back (Optional)If SonarCloud coverage metrics are valuable, consider a follow-up PR to:
Trade-off: Immediate feedback (current) vs. Coverage metrics (future) Conclusion✅ APPROVE - This PR is production-ready with excellent engineering quality:
The only trade-off is losing coverage data in SonarCloud, but this is acceptable given:
Next Steps
Excellent work! This refactoring significantly improves the CI/CD pipeline efficiency while maintaining code quality standards. 🎉 Sources |
Codecov Report✅ All modified and coverable lines are covered by tests. |



We use CodeCov for coverage checks, therefore SonarCloud does not need to wait until tests have finished to run.