Must-share information (formatted with Markdown):
We have python code in directory, as well as CDK code in another, etc.
CDK code doesn’t have tests, and we don’t expect to add them for now.
Our tooling generates the coverage file, but it takes a while to run the tests w/ coverage, and for other parts of the mono-repo, we don’t want to run the full unit test / coverage build. (takes 20 min.)
If the coverage file is absent for a sonarqube scan, it will error, vs warn. We do pass sonar.CoverageReportPath, but I’d love to override the requirement for the coverage or otherwise fake it, so we can update a CDK file, or another static file w/o running build / test.
A prior post asked about this, and we’ve got conditionals in place in our action to not run the build, but then we get an error from sonarqube.
I could skip the entire scan, but that would be suboptimal, and could allow other quality checks to be skipped.
Is there any way to either skip it on a specific run, or otherwise fake the file effectively, w/o poisoning the data that is stored?
Welcome to the community!
Are you using the Generic Coverage Report format? As pointed out in the thread you linked to, that’s fail-fast.
Rather than skipping analysis, is it possible to conditionally omit the parameter when you don’t have a test report?
Yep, that’s what I’m doing. Setting both the coverage and the python coverage option, as in the example GitHub - SonarSource/sonarqube-scan-action
- name: SonarQube Scan
The problem with doing this is that every time it runs on the main branch w/o coverage, it sets code coverage to 0.
I wouldn’t have expected that from a lack of inclusion. I’d expect coverage to not change. I can understand it, now that I’ve seen it, but it’s less than ideal.
Well… that’s why it’s fail-fast.
If I understood correctly, you scan a mono repo and this mono repo can create coverage files corresponding to the Generic Coverage Report format and coverage.xml for Python.
You are in a context where the Generic Coverage file can be absent and this is making the entire scan fail-fast while this is not the case when the coverage.xml for Python code is absent.
Would that help if we align the behavior of the Generic Coverage Report and the language-specific ones: not fail-fast but just emit a WARN in the log?
You will still have part of your code that will be sometimes covered at X% and the scan after (if the generic or not coverage file is missing), covered at 0%.