I have a project with both frontend and backend code. The CI pipeline conditionally runs the tests/coverage report generation steps for the frontend or backend only if there has been changes in those directories. If both directories have changes, then both the frontend and backend coverage reports are generated and the subsequent sonarqube static analysis step correctly calculates the coverage.
However, if one or both of the steps are skipped, the absence of the coverage reports will cause sonarqube to default that none of the files in the skipped portions have been covered. Is there a way to set up sonarqube to just fall back to the previously calculated coverage value if the coverage report isn’t generated?
What are my options here? Do I need to custom generate the sonar-project.properties file to only scan the directories that have been changed in the commit/branch?
Is this true for all pipeline runs, or only those on PRs (basically, does your main branch always get a full run of both frontend/backend after a merge)?
Right now, this is true for all pipeline runs. However, if I can’t determine a way to conditionally calculate coverage based on code changes. I’ll probably at least force all steps to run on the main branch builds to get an accurate coverage picture for the main branch.
The reason I asked about PRs vs. Main Branch is that for PRs, it would be fairly non-disruptive to exclude (or only include) the projects affected in the PR. Essentially what you’ve suggested here.
This wouldn’t work so well for main branch analysis.
When do you build your entire project? Only at release time?