The problem is that the sonar scanner is run in an environment where the project lies in β/github/workspace/β.
The sonarcloud-github-action action starts the scanner in a docker container and the Github worker mounts the project to β/github/workspace/β in the started docker containers.
On the contrary, the tests are run in an environment where β/home/runner/work/{repo-name}/{repo-name}β is the project path. This is the default ubuntu working directory the Github worker runs in and the checkout action loads the files to. When the worker starts a container it mounts that workspace directory to β/github/workspace/β.