Code coverage doesn't work with GitHub action

As reported on github code coverage reports don’t work with SonarCloud github action. When running sonar-scanner with identical sonar-project.properties config, everything works as expected but when running it with github action, I get the following error:
WARN: Could not resolve 39 file paths in [/github/workspace/frontend/coverage/lcov.info], first unresolved path: /home/runner/work/myproject/myproject/frontend/src/app/app-routing.module.ts.

Any suggestions how to fix it?

1 Like

I guess the issue is docker’s virtual working dir…

I have same error using github actions

2019-11-21T20:32:44.3692057Z INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
2019-11-21T20:32:44.3698717Z INFO: Sensor SonarTS [typescript] (done) | time=1ms
2019-11-21T20:32:44.3704647Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2019-11-21T20:32:44.3731158Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
2019-11-21T20:32:44.3738771Z INFO: Sensor SonarJS Coverage [javascript]
2019-11-21T20:32:44.3753716Z INFO: Analysing [/github/workspace/coverage/lcov.info]
2019-11-21T20:32:44.3835564Z WARN: Could not resolve 18 file paths in [/github/workspace/coverage/lcov.info], first unresolved path: /home/runner/work/account-management/account-management/src/addresses/address.entity.ts

I have the same error :pensive:

You can use sed cli utility to correct file paths in your github workflow. For example:

 - name: fix code coverage paths
	working-directory: ./coverage
	run: |
	  sed -i 's/\/home\/runner\/work\/<your-repo-name>\/<your-repo-name>\//\/github\/workspace\//g' lcov.info
	  sed -i 's/\/home\/runner\/work\/<your-repo-name>\/<your-repo-name>\//\/github\/workspace\//g' sonar-cloud-reporter.xml