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?
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.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
You can use
sed cli utility to correct file paths in your github workflow. For example:
- name: fix code coverage paths
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
You can also leverage the
$GITHUB_WORKSPACE env variable to make the command agnostic of your repo:
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' lcov.info
Thank you so much for this hassle-free solution!
Totally simplified my workflow.
I initially created a temporary directory to store those files, which made my workflow long and unreadable for novices.
This is the ultimate solution
Thanks for sharing, this was a missing link for me as well!