istanbul icon indicating copy to clipboard operation
istanbul copied to clipboard

Add relative option to lcov format files.

Open miguelrincon opened this issue 7 years ago • 38 comments

When using coverage with lcov files, reports are created using absolute paths.

There is a good reason to want to generate the report using relative paths. This is both for security reasons and when using an external service in another location such as SonarQube in long delivery pipelines.

This PR offers the option to create the reports with relative paths, this option is turned off by default.

Refers to #104

miguelrincon avatar Mar 01 '17 08:03 miguelrincon

Looking forward to seeing this released. It'll clean up the need to do post-processing on the generated lcov file.

titocr avatar May 16 '17 17:05 titocr

I have a real need for this as well. I hope to see it merged soon.

Isabello avatar Jun 09 '17 11:06 Isabello

Hi, is there any update as to when this is likely to be released, we're having issues with sonarqube and istanbul because of absolute vs relative paths ?

TimHeap46 avatar Sep 07 '17 14:09 TimHeap46

As a workaround I'm using sed to modify the file after it's been generated. Something like this:

# convert absolute paths to relative before sonar runs
sed -i 's|SF:/part_of_path_i_want_to_go_away/|SF:|g' coverage/report-lcov/lcov.info

titocr avatar Sep 07 '17 22:09 titocr

You are the man, that’s been driving me insane all week ☺ Any plans to implement a permanent solution ?

From: titocr [email protected] Reply-To: gotwarlost/istanbul [email protected] Date: Thursday, 7 September 2017 at 23:39 To: gotwarlost/istanbul [email protected] Cc: Tim Heap [email protected], Manual [email protected] Subject: [EXTERNAL] Re: [gotwarlost/istanbul] Add relative option to lcov format files. (#771)

As a workaround I'm using sed to modify the file after it's been generated. Something like this:

convert absolute paths to relative before sonar runs

sed -i 's|SF:/part_of_path_i_want_to_go_away/|SF:|g' coverage/report-lcov/lcov.info

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gotwarlost/istanbul/pull/771#issuecomment-327945992, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGqbywr8S63WDYxEKC8o4coNUWWDekUCks5sgHCkgaJpZM4MPWw5.


This message is intended for the stated addressee(s) only and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of BGL Group Limited and its subsidiaries . Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately.

Please scan all attachments for viruses.

TimHeap46 avatar Sep 08 '17 16:09 TimHeap46

Glad to help. As for a permanent fix, as I understand it, it's sitting here with the commit @miguelrincon did. I'm just waiting on it like everyone else ;-)

titocr avatar Sep 09 '17 17:09 titocr

Yes I saw that post ☺

From: titocr [email protected] Reply-To: gotwarlost/istanbul [email protected] Date: Saturday, 9 September 2017 at 18:06 To: gotwarlost/istanbul [email protected] Cc: Tim Heap [email protected], Manual [email protected] Subject: [EXTERNAL] Re: [gotwarlost/istanbul] Add relative option to lcov format files. (#771)

Glad to help. As for a permanent fix, as I understand it, it's sitting here with the commit @miguelrinconhttps://github.com/miguelrincon did. I'm just waiting on it like everyone else ;-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gotwarlost/istanbul/pull/771#issuecomment-328290494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGqby8VRQnSiCvukEP8ZROXpyE5K9Rlrks5sgsWfgaJpZM4MPWw5.


This message is intended for the stated addressee(s) only and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of BGL Group Limited and its subsidiaries . Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately.

Please scan all attachments for viruses.

TimHeap46 avatar Sep 10 '17 15:09 TimHeap46

Hi, still struggling with getting this working on CI. If I have a file called lcov.info which contains this line : SF:deploy/app/shared/services/sharedServicesModule.js

And I simply want to remove the deploy/ part so it becomes SF:app/shared/services/sharedServicesModule.js then this should work, right ?

sed -i 's|SF:deploy/|SF:|g'

From: titocr [email protected] Reply-To: gotwarlost/istanbul [email protected] Date: Saturday, 9 September 2017 at 18:06 To: gotwarlost/istanbul [email protected] Cc: Tim Heap [email protected], Manual [email protected] Subject: [EXTERNAL] Re: [gotwarlost/istanbul] Add relative option to lcov format files. (#771)

Glad to help. As for a permanent fix, as I understand it, it's sitting here with the commit @miguelrinconhttps://github.com/miguelrincon did. I'm just waiting on it like everyone else ;-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gotwarlost/istanbul/pull/771#issuecomment-328290494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGqby8VRQnSiCvukEP8ZROXpyE5K9Rlrks5sgsWfgaJpZM4MPWw5.


This message is intended for the stated addressee(s) only and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of BGL Group Limited and its subsidiaries . Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately.

Please scan all attachments for viruses.

TimHeap46 avatar Sep 11 '17 08:09 TimHeap46

Our CI is jenkins and this is the line I use (changed only the last part of the path). I had to try a couple different things before discovering what path was needed.

sed -i 's|SF:/opt/jenkins/workspace/myProject/|SF:|g' coverage/report-lcov/lcov.info

An altered line in lcov.info, before and after:

SF:/opt/jenkins/workspace/myProject/src/app/config/app_config.js

SF:src/app/config/app_config.js

Hope that helps.

titocr avatar Sep 11 '17 14:09 titocr

Thanks I have this working now.

From: titocr [email protected] Reply-To: gotwarlost/istanbul [email protected] Date: Monday, 11 September 2017 at 15:59 To: gotwarlost/istanbul [email protected] Cc: Tim Heap [email protected], Manual [email protected] Subject: [EXTERNAL] Re: [gotwarlost/istanbul] Add relative option to lcov format files. (#771)

Our CI is jenkins and this is the line I use (changed only the last part of the path). I had to try a couple different things before discovering what path was needed.

sed -i 's|SF:/opt/jenkins/workspace/myProject/|SF:|g' coverage/report-lcov/lcov.info

An altered line in lcov.info, before and after:

SF:/opt/jenkins/workspace/myProject/src/app/config/app_config.js SF:src/app/config/app_config.js

Hope that helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gotwarlost/istanbul/pull/771#issuecomment-328556689, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGqby67cPJIEaRtInSBNN3rwyys80LJ-ks5shUq9gaJpZM4MPWw5.


This message is intended for the stated addressee(s) only and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of BGL Group Limited and its subsidiaries . Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately.

Please scan all attachments for viruses.

TimHeap46 avatar Sep 11 '17 15:09 TimHeap46

Hi, does Istanbul run on windows for c sharp code , and if not are there any plans for it in the future ? looking at ways of surfacing code coverage with sonarqube for some of our projects.

From: titocr [email protected] Reply-To: gotwarlost/istanbul [email protected] Date: Monday, 11 September 2017 at 15:59 To: gotwarlost/istanbul [email protected] Cc: Tim Heap [email protected], Manual [email protected] Subject: [EXTERNAL] Re: [gotwarlost/istanbul] Add relative option to lcov format files. (#771)

Our CI is jenkins and this is the line I use (changed only the last part of the path). I had to try a couple different things before discovering what path was needed.

sed -i 's|SF:/opt/jenkins/workspace/myProject/|SF:|g' coverage/report-lcov/lcov.info

An altered line in lcov.info, before and after:

SF:/opt/jenkins/workspace/myProject/src/app/config/app_config.js SF:src/app/config/app_config.js

Hope that helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gotwarlost/istanbul/pull/771#issuecomment-328556689, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGqby67cPJIEaRtInSBNN3rwyys80LJ-ks5shUq9gaJpZM4MPWw5.


This message is intended for the stated addressee(s) only and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of BGL Group Limited and its subsidiaries . Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately.

Please scan all attachments for viruses.

TimHeap46 avatar Sep 18 '17 13:09 TimHeap46

I would love to see this merged. Our build pipeline includes running tests on one docker container and using instanbul to report coverage in another machine using sonarqube.

We really need this option.

csotiriou avatar Mar 21 '18 10:03 csotiriou

Would also like this change

jmpresso avatar May 10 '18 17:05 jmpresso

any idea if this is likely to happen any time soon ?

TimHeap46 avatar May 11 '18 07:05 TimHeap46

Looks like this repository has been deprecated, nyc is the replacement for this tool, but it too, does not support relative paths.

So I've solved this for myself like some others in this thread with sed, however instead of making the path relative, just encase that brakes something else, I update the path to be absolute to the current directory with sed -i "s|SF:/app|SF:$(pwd)|g" lcov.info

TheJefe avatar Jun 20 '18 14:06 TheJefe

In a Typescript Angular 6 project I needed to make the path to be that of the Docker image used for the sonar-scanner. Since the path could change in the build pipeline (BitBucker) I used the following sed expression:

sed -i "s|SF:/.*/my-project/|SF:/root/src/|g" test-reports/lcov.info

where /root/src is the name of the mapped folder of the current folder in the Docker container that was started by the following command:

docker run -ti -v $(pwd):/root/src newtmitch/sonar-scanner

ozoli avatar Sep 07 '18 10:09 ozoli

This is such a small change. What's the blocker? Lack of maintainers?

aleclarson avatar Nov 06 '18 13:11 aleclarson

Hey, it would be a very useful change, what is blocking ?

melonwannajack avatar Nov 22 '18 13:11 melonwannajack

I would love to see this merged too !

AlexisNoAccor avatar Dec 08 '18 22:12 AlexisNoAccor

Anything new for this PR ? It would be really useful to have this option !

It's not that I don't like sed but... 😅

sybers avatar Feb 19 '19 15:02 sybers

2 years and still not merged 🤦‍♂️

matiasdecarli avatar Apr 03 '19 21:04 matiasdecarli

What's stopping this from being merged? I really need this feature.

itolu94 avatar Jun 07 '19 19:06 itolu94

Someone really enjoys using sed and hacks... :(

FlorinAsavoaie avatar Oct 10 '19 18:10 FlorinAsavoaie

On Github (with actions), I successfully used sed -i "s|SF:/.*/src/|SF:/github/workspace/src/|g" coverage/lcov.info

Thank you @ozoli

atwright147 avatar Oct 24 '19 22:10 atwright147

I've put a hack for this in our CI in 2017, it's still an issue now...

JackLeo avatar Dec 03 '19 16:12 JackLeo

I've added the sed hack as well, but it'd be nice to get this merged...

calvin-barker avatar Feb 12 '20 02:02 calvin-barker

I'd really like to have this 2-year old (and counting) much needed fix to be merged, also! Any way to speed that up?

gmauch avatar Feb 14 '20 13:02 gmauch

When will this be merged, it's been more than 2 years ?

Thilaknath avatar Feb 26 '20 18:02 Thilaknath

3+ years and finally approved, Please merge it in

kishanchaitanya avatar Apr 02 '20 23:04 kishanchaitanya

I started to use sed as a work-around and this is approved. lol

fatihdestegul avatar May 28 '20 15:05 fatihdestegul