Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dinkopehar opened this issue Jun 8, 2021 · 16 comments

Comments

@dinkopehar
Copy link

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 ?

@SimonKagstrom
Copy link
Owner

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?

@dinkopehar
Copy link
Author

dinkopehar commented Jun 9, 2021

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.

@SimonKagstrom
Copy link
Owner

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.

@dinkopehar
Copy link
Author

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

@SimonKagstrom
Copy link
Owner

Yes, through

--configure=coveralls-service-name=XXX

as an argument to kcov.

@dinkopehar
Copy link
Author

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 🥇

@SimonKagstrom
Copy link
Owner

Thanks for testing!

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

@NetraPK
Copy link

NetraPK commented Feb 1, 2022

Is there any update on this ??

Screenshot 2022-02-01 at 5 33 36 PM

Screenshot 2022-02-01 at 5 34 41 PM

@SimonKagstrom
Copy link
Owner

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
Copy link
Owner

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.

@NetraPK
Copy link

NetraPK commented Feb 22, 2022

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

Can you elaborate the above line?

@SimonKagstrom
Copy link
Owner

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 :-)

@NetraPK
Copy link

NetraPK commented Feb 22, 2022

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

@SimonKagstrom
Copy link
Owner

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

Are the source lines now visible?

@NetraPK
Copy link

NetraPK commented Feb 22, 2022

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]
}
]
}

@SimonKagstrom
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants