No code coverage with phpUnit

Hey Guillaume,

Sorry for the late reply here.

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/”.

One possible solution is to adapt the paths in the generated coverage file before the SonarCloud action is run. Example: Code coverage doesn't work with GitHub action

I hope that helps!

Best,
Karim.

4 Likes