We’re running into an issue where our quality gate is not failing as expected in a subproject inside a monorepo.
Repository structure
One parent repo with two monorepo projects within (let’s call them project A and B)
Project A has a 100% code coverage quality gate
Project B has an 80% code coverage quality gate
These were setup using the “convert to monorepo” instructions here
ALM used: Bitbucket Cloud
CI system used: Bitbucket Cloud
Scanner command used when applicable:
sonarsource/sonarcloud-scan:2.0.0
sonarsource/sonarcloud-quality-gate:0.1.6
We’re running these in a bitbucket-pipelines.yml file like this:
- pipe: sonarsource/sonarcloud-scan:2.0.0 # Use separate project settings for CBS code
variables:
EXTRA_ARGS: '-Dproject.settings=sonar-project-A.properties'
- pipe: sonarsource/sonarcloud-quality-gate:0.1.6
variables:
EXTRA_ARGS: '-Dproject.settings=sonar-project-A.properties'
Languages of the repository: Python
Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
The Summary page for a branch on Project A shows only 84.6% coverage on 11 new lines
And this page also shows that the quality gate passed
We expected Project A to fail the 100% code coverage quality gate
Welcome to the community and thanks for so thoroughly filling out the post template! This is probably the best I’ve ever seen.
You start by mentioning that you have 2 projects in your monorepo but only seem concerned about Project A. I take it that means Project B is fine?
For Project A, can you check the ‘Information’ link at the bottom-left of the page to see which Quality Gate was applied and whether it was the one you expected?
On Project A, the ‘Information’ link shows a 100% Code Coverage required quality gate, and it’s been that way for a few months now.
Also, now that the scan and gate on Project A has run on a few other branches – the gate has failed on those other branches when coverage has been too low.
And so far, we haven’t noticed issues with Project B either.
No, we’re still having intermittent failures on both Project A and Project B. Most of the time the quality gate passes or fails correctly on both of the projects.
But once in a while, we’re still seeing the gate pass even when code coverage is too low. Sometimes on Project A and sometimes on Project B.
How many lines are in the change set / New Code definition when this happens? I’m willing to bet you’re falling afoul of what I call the “fudge factor”.