I’m facing a persistent issue with SonarCloud failing to import my Python coverage report (backend/coverage.xml) in a GitHub Actions workflow for my FastAPI project (noobsquad). The errors are:
The following error(s) occurred while trying to import coverage report:
Invalid directory path in 'source' element: /home/runner/work/noobsquad/noobsquad/backend
Cannot resolve the file path 'main.py' of the coverage report, the file does not exist in all 'source'.
Cannot resolve 38 file paths, ignoring coverage measures for those files
This results in 0% coverage in SonarCloud, despite tests running successfully and generating backend/coverage.xml. I’ve tried multiple approaches to fix the paths, but the issue persists. I’d appreciate any help!
My project structure (Simplified)
noobsquad/
├── backend/
│ ├── main.py
│ ├── api/
│ │ └── v1/
│ │ └── endpoints/
│ │ └── auth.py
│ ├── tests/
│ │ └── test_auth.py
│ └── requirements.txt
├── frontend/
├── sonar-project.properties
├── .coveragerc
└── .github/
└── workflows/
└── sonarcloud.yml