kcov icon indicating copy to clipboard operation
kcov copied to clipboard

kcov with --coveralls-id uploads to coveralls, but file browsing is not available

Open dinkopehar opened this issue 4 years ago • 18 comments

Hello.

I'm trying to use kcov with Crystal lang and locally it works. The command in GitHub Actions is similar to one I use locally:

kcov --coveralls-id=REPO_TOKEN --clean --include-path=$(pwd)/src $(pwd)/coverage ./my_binary

but the problem is, files are available but can't be browsed to see what is covered. image

Do you know solution to this or am I missing something ?

dinkopehar avatar Jun 08 '21 15:06 dinkopehar

Hmm.. I wrote #346 a while ago, so I'm not quite sure what needs to be done to get it working. It sounds to me like some sort of mapping between github and the files in the coverage report is missing, since I guess coveralls will get the actual source files from there.

Do you have a link to your repo?

SimonKagstrom avatar Jun 09 '21 06:06 SimonKagstrom

I just reviewed source code of kcov. I think at the end, using --coveralls-id=XYZ generates JSON which is sent to coveralls.io API. I think it's missing some information.


coverage.zip

In that zip file, a file named coveralls.out is sent to coveralls.io, but it only includes repo-token and files covered. For example, if it included service_pull_request, it could:

The associated pull request ID of the build. Used for updating the status and/or commenting.

Also, git and commit_sha could provide more information. You can read whole API data here

~~Also, if Coveralls Actions works only with lcov output. If you know how to convert kcov output to lcov, that could also work (I see kcov generates several different output for different platforms).~~ Scratch this, kcov is sutible tool for this if source code is modified to include that info.

dinkopehar avatar Jun 09 '21 07:06 dinkopehar

Well, it works with travis-ci, so I think the actual source code itself should not be strictly required:

https://coveralls.io/builds/37528394/source?filename=src%2Fconfiguration.cc

I think in the github actions case it doesn't know about where to find the source file (at github :-)).

Perhaps an option could be to add the source-string in the source file object, so that the source file itself is sent with the request.

SimonKagstrom avatar Jun 09 '21 07:06 SimonKagstrom

I see this in source code of Coveralls writer. Can it be set somehow from kcov ?

dinkopehar avatar Jun 09 '21 09:06 dinkopehar

Yes, through

--configure=coveralls-service-name=XXX

as an argument to kcov.

SimonKagstrom avatar Jun 09 '21 10:06 SimonKagstrom

Sadly, it didn't work.

Reading their API documentation, it states:

While OPTIONAL to see coverage reports at Coveralls, git or commit_sha are REQUIRED to receive coverage reports at your git host (ie. Github). This includes coverage badges, pull request checks and pull request comments. Coverage badges pertain only to the default branch of your repo and therefore require branch data. Coveralls requires git/commit data to send checks and comments to the right pull request.

You can close now if you think this is not needed. Generating reports using kcov will be enough for me to work from that data and send request to their API manually.

By the way, kcov is great so thank you :1st_place_medal:

dinkopehar avatar Jun 10 '21 17:06 dinkopehar

Thanks for testing!

I think adding the source-string to coveralls would be worth trying, so let's keep it open for that.

SimonKagstrom avatar Jun 12 '21 14:06 SimonKagstrom

Is there any update on this ??

Screenshot 2022-02-01 at 5 33 36 PM Screenshot 2022-02-01 at 5 34 41 PM

NetraPK avatar Feb 01 '22 12:02 NetraPK

No, I haven't been working on this, sorry.

The source-string would be a brutal way of doing it but hopefully it would work.

SimonKagstrom avatar Feb 03 '22 07:02 SimonKagstrom

I implemented this, although I haven't tested it against the "real" coveralls myself (only looking in the file output).

It's available in the issue-358-coveralls-source branch if someone likes to test it, and kcov has to be run with

kcov --configure=coveralls-source=1 [other options]

for it to be active. If it appears to work, I'll merge the branch.

SimonKagstrom avatar Feb 11 '22 18:02 SimonKagstrom

Hi, How to use this --configure parameter? kcov --configure=coveralls-source=1 [other options]

Can you elaborate the above line?

NetraPK avatar Feb 22 '22 05:02 NetraPK

Like this, for example

kcov --configure=coveralls-source=1 /tmp/kcov my-program.sh

so this is just another option to kcov, only that the syntax looks a bit strange :-)

SimonKagstrom avatar Feb 22 '22 07:02 SimonKagstrom

One more thing when I run the below command using jenkins pipeline : kcov --coveralls-id=${COVERALLS_TOKEN} --bash-dont-parse-binary-dir --exclude-path=coverage coverage ./script.sh

It is not showing the % of coverage.. Am I missing something? Screenshot 2022-02-22 at 8 38 27 PM

NetraPK avatar Feb 22 '22 15:02 NetraPK

Does it show up in your coveralls.out file if you run it manually?

Are the source lines now visible?

SimonKagstrom avatar Feb 22 '22 15:02 SimonKagstrom

Below is the coveralls.out when I run it manually: { "repo_token": "XXXX", "source_files": [ { "name": "variable.sh", "source_digest": "0xad88bcdb", "coverage": [null,null,1,1,1,1,1,1,3,1,1,1,5,1,1,1,1,1,null,1,0,null,null,1,null,0,0,null,null,0,0,null,null,0,0,null,null,1,1,1,1,null,0,null,null,null,null,2,2,1] }, { "name": "create_admin_user.sh", "source_digest": "0xaad64e55", "coverage": [null,1,null,null,1,1,1,1,null,null,0,0,null,null,null,6,null,null,null,1,null,0,0,0,0,null,null,null,null,2,1,0,null,null,1,null,null,null,1,3,0,0,null,1,null,null,null,null,null,1,3,1,null,null,null,null,null,1,3,1,null,0,0,0,0,null,null,null,null,null,null,1,2,1,2,0,0,0,null,3,1,1,null,null,null,null,null,1,0,0,0,0,null,0,0,null,0,null,1,null,null,null,null,1,2,1,0,null,null,null,null,null,null,0,null,1,null,null,null,1,1,1,1,null,1,1,1,null,1,1,1,null,0,null,null,0,null] } ] }

NetraPK avatar Feb 22 '22 18:02 NetraPK

But is this with --configure=... as above? There should also be a source:-section with the actual script sources.

At least if built from the branch above.

SimonKagstrom avatar Feb 23 '22 14:02 SimonKagstrom