Test results are not being published to sonarcloud

Hi everyone. I’m facing the following issue. I have a github repo that runs github actions when a new PR is created. It runs different sbt commands such as linting, unit testing, etc. For some reason I can’t publish my results to Sonar Cloud. The following list contains the details of the context where this is happening.

Also I tried to analyse the code using the automatic analysis, but didn’t work.

Hi @gastonschabas and welcome to the community !

I think there’s a typo on your scala coverage property :

Instead of sonar.scala.scoverage.reportPath it should be : sonar.scala.coverage.reportPaths

See our doc for more explanations : https://sonarcloud.io/documentation/analysis/coverage/


Hi @mickaelcaro, thanks for your answer. I fixed the typo that I had for scala coverage path in PR https://github.com/gastonschabas/rumble-on-scala/pull/13 but I’m still getting no results. The log of the pipeline executed when I pushed the changes shows that the results were published here https://sonarcloud.io/dashboard?id=gastonschabas_rumble-on-scala&pullRequest=13, but nothing has changed.

Hi @gastonschabas
I probably don’t have access but do you see something in the “Code” tab of your project for your PR ?

If not, i would try first to have some code and LOCs detected by SonarCloud before digging into that coverage issue.

Hi @mickaelcaro
I added and pushed new code to each PR
this time sonar code analysis was triggered but it failed. Looks like the new code was detected, but test weren’t. I mean, both new methods are marked as uncovered by tests. If you check the tests, I added coverage for one of them.

Ok i think i got it. Seeing the latest log

00:13:38.413 WARN: Fail to resolve 2 file(s). No coverage data will be imported on the following file(s): /home/runner/work/rumble-on-scala/rumble-on-scala/src/main/scala/com/gaston/adder/Adder.scala;/home/runner/work/rumble-on-scala/rumble-on-scala/src/main/scala/com/gaston/adder/Subtractor.scala

It seems that there is a mismatch between the paths that are inside the coverage report vs what we detected with the scanner.

Could you maybe check on that side ?


Hi @mickaelcaro. I found that sonar.tests where pointing to a wrong path. I fixed that and now the WARN is not being showed anymore. But sonar report still saying that there is no coverage. Not sure what am I missing here.
I run sonarqube community 8.4 in my localhost using docker and the report generated was ok. For some reason in my local environment, sonar-project.properties is not being detected, so I had to send the parameters through command line to make it work. Even though I tried to do the same in github, but it looks like it doesn’t make any difference. It stills saying no lines were covered by the tests.

Hey @mickaelcaro After trying different things, I could solve it. Not sure why https://github.com/SonarSource/sonarcloud-github-action is not working (maybe there is an issue with sbt or scala, not sure). Using the following sbt plugin https://sonar-scala.com/docs/setup/sbt-sonar/ was the only thing that worked. I have to generate a token in sonar cloud and add a new key named SONAR_TOKEN to my secrets in my github repo. This is how my github workflow yaml file looks

name: Continious Integration
      - master
      - '**.md'
    runs-on: ubuntu-latest
    - name: Checkout
      uses: actions/checkout@v2
        fetch-depth: 0
    - name: Cache SBT
      uses: actions/cache@v2
        path: |
        key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
    - name: Setup Scala
      uses: actions/setup-java@v1
        java-version: 11
    - name: Test with Coverage / Static code analyse / Code style
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      run: |
        sbt \
        -Dsonar.host.url=https://sonarcloud.io \
        -Dsonar.organization=gastonschabas \
        -Dsonar.projectKey=gastonschabas_rumble-on-scala \
        -Dsonar.sources=src/main/scala \
        -Dsonar.tests=src/test/scala \
        -Dsonar.scala.scalastyle.reportPaths=target/scalastyle-result.xml \
        -Dsonar.scala.scapegoat.reportPaths=target/scala-2.12/scapegoat-report/scapegoat-scalastyle.xml \
        -Dsonar.scala.coverage.reportPaths=target/scala-2.12/scoverage-report/scoverage.xml \
        clean compile coverage test coverageReport scapegoat scalastyle scalafmtCheckAll scalafmtSbtCheck sonarScan

Thanks for your help and sorry for my late answer

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.