Sonar on Github Actions with Python Coverage "source" Issue

I am using Github actions to run tests for my python project. I am using coverage to generate coverage report (with pytest). Everything (path) is based locally on the machine Github Actions is running on (/home/runner/work/repo).

On the coverage report, it has an attribute source which list the source of the code

	<sources>
		<source>/home/runner/work/repo</source>
	</sources>

But when running the Sonar scan using Github Actions (SonarSource/sonarcloud-github-action@master), it is executed in a docker container, with the volume of the “source” mounted to a separate location
Log from the docker commend on Github Action

-v "/home/runner/work/repo":"/github/workspace"

When the Soner Scanner is running, it is reporting that the source path is invalid because it is using the github local path, not the path relative to the docker container.

WARN: Invalid directory path in 'source' element: /home/runner/work/repo

I previously have it setup in CircleCI and it ran without issue because it downloads the scanner locally and run it, but with the switch to the Github Actions, the way it execute changed, causing the coverage report to not being recognized by Sonar Scanner due to the path change.

I created a work around for now to resolve this issue, but I think sonar might need to change how coverage report read and process the “source” in the coverage report generated by Python (in github actions)

      - name: Override Coverage Source Path for Sonar
        run: sed -i "s/<source>\/home\/runner\/work\/repo<\/source>/<source>\/github\/workspace<\/source>/g" /home/runner/work/repo/path/to/coverage.xml