How to Combine Multi-Language Analysis in One Scan
Sonar auto-detects languages from file extensions in sonar.sources; add each language coverage path to score them together.
Point sonar.sources at all language roots. Sonar runs the matching analyzers automatically. Add a coverage report path property per language so every part of the repo contributes to the gate.
sonar-project.properties
sonar-project.properties
sonar.projectKey=my-org_my-repo
sonar.sources=frontend/src,backend,cmd
sonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info
sonar.python.coverage.reportPaths=backend/coverage.xml
sonar.go.coverage.reportPaths=cmd/coverage.outWorkflow
.github/workflows/ci.yml
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: (cd frontend && npm ci && npm test -- --coverage)
- run: (cd backend && pytest --cov --cov-report=xml)
- run: (cd cmd && go test ./... -coverprofile=coverage.out)
- uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}Gotchas
- Generate every coverage report before the single scan step, or that language shows zero coverage.
- Compiled languages may need their build to run first so the analyzer sees bytecode or build output.
Related guides
How to Analyze a Monorepo With Multiple Sonar ProjectsScan a monorepo by running one SonarQube analysis per package with its own project key, or by defining module…
How to Import Test Coverage Into SonarQubeFeed test coverage into SonarQube by generating an lcov, cobertura, or JaCoCo report and pointing the matchin…