# Code coverage doesn't work with GitHub action

**URL:** <https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747>\
**Category:** SonarQube Cloud\
**Tags:** github-actions, sonarqube-cloud\
**Created:** [November 18, 2019, 12:13pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747 "2019-11-18T12:13:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakimio](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hakimio/32/7642_2.png) [@hakimio](https://community.sonarsource.com/u/hakimio)\
**Post date:** [November 18, 2019, 12:13pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/1 "2019-11-18T12:13:31Z")

</div>

As reported on [github](https://github.com/SonarSource/docker-sonarqube/issues/328) code coverage reports don’t work with [SonarCloud github action](https://github.com/SonarSource/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?

---

<div class="post-metadata">

**Author:** ![hakimio](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hakimio/32/7642_2.png) [@hakimio](https://community.sonarsource.com/u/hakimio)\
**Post date:** [November 18, 2019, 12:47pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/2 "2019-11-18T12:47:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![is-daimonos](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@is-daimonos](https://community.sonarsource.com/u/is-daimonos)\
**Post date:** [November 21, 2019, 10:26pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/3 "2019-11-21T22:26:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![algra4](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@algra4](https://community.sonarsource.com/u/algra4)\
**Post date:** [November 23, 2019, 5:59pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/5 "2019-11-23T17:59:13Z")

</div>

I have the same error 😔

---

<div class="post-metadata">

**Author:** ![hakimio](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/hakimio/32/7642_2.png) [@hakimio](https://community.sonarsource.com/u/hakimio)\
**Post date:** [November 23, 2019, 8:16pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6 "2019-11-23T20:16:52Z")

</div>

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

```auto
 - 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

```

---

<div class="post-metadata">

**Author:** ![sylfabre](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sylfabre/32/20691_2.png) [@sylfabre](https://community.sonarsource.com/u/sylfabre)\
**Post date:** [March 28, 2021, 6:43pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/7 "2021-03-28T18:43:45Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![ranjithgn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ranjithgn/32/26518_2.png) [@ranjithgn](https://community.sonarsource.com/u/ranjithgn)\
**Post date:** [October 13, 2021, 9:53pm UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/8 "2021-10-13T21:53:23Z")

</div>

Thank you so much for this hassle-free solution!

---

<div class="post-metadata">

**Author:** ![Evans\_Onoka](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/evans_onoka/32/27866_2.png) [@Evans\_Onoka](https://community.sonarsource.com/u/Evans_Onoka)\
**Post date:** [November 30, 2021, 7:28am UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/9 "2021-11-30T07:28:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RCheesley](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rcheesley/32/29722_2.png) [@RCheesley](https://community.sonarsource.com/u/RCheesley)\
**Post date:** [July 18, 2022, 10:12am UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/10 "2022-07-18T10:12:15Z")

</div>

Thanks for sharing, this was a missing link for me as well!

---

<div class="post-metadata">

**Author:** ![brunnsbe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/brunnsbe/32/41389_2.png) [@brunnsbe](https://community.sonarsource.com/u/brunnsbe)\
**Post date:** [January 27, 2023, 7:56am UTC](https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/11 "2023-01-27T07:56:05Z")

</div>

I also bumped into this same issue but with Gitlab and SimpleCov for Ruby files.  
I’ve tried with both correct absolute and relative paths but still getting the same error:  
`[WARNING] File './backend/app/checkpoint_util.rb' is present in coverage report but cannot be found in filesystem` or with absolute path `[WARNING] File '/builds/Dev/project/backend/app/checkpoint_util.rb' is present in coverage report but cannot be found in filesystem`.  
Any tips or ideas how to solve it?
