Hello @Dorian_Burihabwa I think I know what is happening. Is related to this other problem Test results are not being published to sonarcloud - #8 by gastonschabas
The problem is that coverage report is generated directly on the “/runner/_work/” main directory for Github actions using sbt. But when running it using GitHub - SonarSource/sonarcloud-github-action: Integrate SonarCloud code analysis to GitHub Actions a Docker is run and a volume created to sync the code between
-v “/runner/_work/[my-project]/[my-project]”:“/github/workspace”
This is the message that appears when running the step on Github Actions:
Run sonarsource/sonarcloud-github-action@master
/usr/local/bin/docker run --name e2266ba9a69824544d2da867945a369ad22a_3b53db --label 60e226 --workdir /github/workspace --rm -e "JAVA_HOME" -e "JAVA_HOME_17_X64" -e "MSYS" -e "COURSIER_BIN_DIR" -e "GITHUB_TOKEN" -e "SONAR_TOKEN" -e "INPUT_PROJECTBASEDIR" -e "INPUT_ARGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_EVENT_PATH" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "GITHUB_ACTION" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/runner/_work/_temp/_github_home":"/github/home" -v "/runner/_work/_temp/_github_workflow":"/github/workflow" -v "/runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/runner/_work/[my-project]/[my-project]":"/github/workspace" 60e226:6ba9a69824544d2da867945a369ad22a -Dsonar.organization=[my-project] -Dsonar.projectKey=[my-projectkey] -Dsonar.projectName=[my-project] -Dsonar.language=scala -Dsonar.scala.file.suffixes=.scala -Dsonar.sources=src/main -Dsonar.tests=src/test,src/it -Dsonar.scala.coverage.reportPaths=../target/scala-3.2.2/scoverage-report/scoverage.xml -Dsonar.scala.version=3.2.2
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
You can see here the volume created.
Then the sonar scanner is unable to match the format of the coverage file directories that it contains with the current directories for the files in the docker volume and it simply does not account it so coverage is marked to 0%.
Probably changing the volume docker internal directory to match what is used by GitHub actions will solve the problem.
As sbt-sonar plugin has a build-in Sonar scanner, it does not run in a docker container, there is no volume and directory change either, so it works smoothly.
Can anyone help confirm this? Thanks.