I’ve seen a few posts like this so apologies for adding another to the pile; I wasn’t able to get things working following along. My coverage.xml is being created during CI and pushed back to the branch. The file is being created and added as expected, Coverage XML written to file tests/_coverage/coverage.xml, but SonarCloud doesnt seem to find it. I’ve specified the path in the .sonarcloud.properties file with sonar.python.coverage.reportPaths=**/tests/_coverage/*.xml. I’ve tried a few combinations
Full .sonarcloud.properties
sonar.projectKey=Snayff_notquiteparadise
sonar.organization=snayff
# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=notquiteparadise
#sonar.projectVersion=1.0
# Path is relative to the .sonarcloud.properties file. Replace "\" by "/" on Windows.
sonar.inclusions=**/scripts/**
sonar.exclusions=**/docs/**,**/logs/**,.mypy_cache/**,.github/**,assets/**
sonar.test.inclusions=**/tests/**
sonar.python.coverage.reportPaths=**/tests/_coverage/*.xml
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
# other
sonar.showProfiling=true
sonar.verbose=true
Ah, OK, thank you! So I have tried to use the Action but am currently finding that the directories specified in the sonar-project.properties are not found. I’ve tried setting the projectBaseDir to . as I thought that might be it.
Caused by: The folder 'tests/**' does not exist for 'Snayff_notquiteparadise' (base directory = /github/workspace)
I’m glad you found another workaround to your problem. For the record, I’ll try to give you pointers into getting this to work entirely with SonarCloud.
In the last example, your properties settings seem a bit weird to me.
You have this error in your logs: 10:17:11.703 ERROR: Invalid value of sonar.tests for Snayff_notquiteparadise
Also I believe if you want to refer to a folder, you don’t need to add /** at its end, as the subdirectories are automatically included.
So my suggestion would be to try to replace sonar.test.inclusions=tests/** with sonar.tests=tests instead.
If you do that, when importing your code coverage, you might also encounter a problem with incorrect file paths in your coverage file, which you can fix following the advice from this thread:
Here’s a sample Python project that deals with this: