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

chore: add code coverage report #120

Merged
merged 6 commits into from
Aug 30, 2022
Merged

chore: add code coverage report #120

merged 6 commits into from
Aug 30, 2022

Conversation

vmx
Copy link
Contributor

@vmx vmx commented Mar 17, 2022

Generate a code coverage report and add it as artifact as well as
uploading it to CodeCov.

@vmx
Copy link
Contributor Author

vmx commented Mar 17, 2022

I still want to improve it a bit, but I thought I push a first version of it.

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@63c5033). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #120   +/-   ##
=========================================
  Coverage          ?   83.95%           
=========================================
  Files             ?       87           
  Lines             ?    18091           
  Branches          ?        0           
=========================================
  Hits              ?    15189           
  Misses            ?     2902           
  Partials          ?        0           

Generate a code coverage report and add it as artifact as well as
uploading it to CodeCov.

The coverage instrumentation needs at least Rust 1.60, hence the
rust-toolchain was updated to that version.
@vmx vmx marked this pull request as ready for review April 26, 2022 16:49
@vmx
Copy link
Contributor Author

vmx commented Apr 26, 2022

@ZenGround0 @galargh Things work! I'm quite happy with the outcome. The report is uploaded to Codecov and also an artifact is created, in case someone wants the fancy llvm report. I think it would be OK to merge it as it is, though things I'd love to see improved (though I'm not sure if those are possible/worth it:

  • An direct link to the Codecov coverage report directly from a PR (without clicking through the CI things
  • A link to the LLVM created coverage report. One would need to upload it somewhere (e.g. IPFS or GitHub pages)

@galargh
Copy link
Contributor

galargh commented Apr 26, 2022

An direct link to the Codecov coverage report directly from a PR (without clicking through the CI things

I'd expect #120 (comment) to link to codecov. I'll try to look into why the links lead to nowehere.

A link to the LLVM created coverage report. One would need to upload it somewhere (e.g. IPFS or GitHub pages)

This should be a lot easier once github/roadmap#470 is implemented.

@LesnyRumcajs
Copy link
Contributor

Hello! I may be missing something, but have you considered using the simplistic tarpaulin solution like we've done in Forest? We are pretty happy with the codecov reports generated there, and the workflow seems more maintainable. Is it missing some crucial features?

@vmx
Copy link
Contributor Author

vmx commented May 9, 2022

@LesnyRumcajs last time I've uses Tarpaulin, the results were different, while Tarpaulin was wrong. I don't know if that has changed.

@LesnyRumcajs
Copy link
Contributor

@vmx Do you recall what kind of difference have you observed? Is there an issue with that in the Tarpaulin repository?

@vmx
Copy link
Contributor Author

vmx commented May 10, 2022

@vmx Do you recall what kind of difference have you observed?

I can't recall. I think easiest is to just try it out in this repo and see if the output is different.

@vmx
Copy link
Contributor Author

vmx commented May 12, 2022

@LesnyRumcajs I just tried to compare the output with the one from Tarpaulin. But I can't get Tarpaulin working, when running cargo tarpaulin --workspace it fails to compile (Error: "Failed to compile tests! Error: fil_actors_runtime: linking with cc failed: exit status: 1"). I guess it's due to Tarpauling using -Clink-dead-code which currently doesn't work with this code base.

@LesnyRumcajs
Copy link
Contributor

@vmx Thanks for checking this out! Do you know why this flag breaks the compilation?

@vmx
Copy link
Contributor Author

vmx commented May 12, 2022

Do you know why this flag breaks the compilation?

Sounds to me like some library is already compiled with dead code removal, hence the symbols are not there anymore. But linker issues are always tricky and huge time sink. Though in case someone wants to take a look, it's easy to reproduce via RUSTFLAGS='-Clink-dead-code' cargo test --workspace.

@LesnyRumcajs
Copy link
Contributor

@vmx Interesting, thanks for the insights!

But linker issues are always tricky and huge time sink.

Indeed, there be dragons. :)

@galargh
Copy link
Contributor

galargh commented May 20, 2022

I figured out why #120 (comment) doesn't contain the correct links to the reports.

This happens because we run the workflow on push trigger - see

In such a setup, the checkout action only checks out this branch and does not rebase it on the PR target - master in this case. That's why we get ❗ No coverage uploaded for pull request base (master@940d99d). warning and the link under Codecov Report leads nowhere.

To address this we could switch the workflow trigger to pull_request or pull_request_target. We've done a similar change in ref-fvm.

@anorth
Copy link
Member

anorth commented Aug 11, 2022

@vmx I've only skimmed the convo above, but is this something you think is ready to land, or could be soon?

@vmx
Copy link
Contributor Author

vmx commented Aug 12, 2022

@vmx I've only skimmed the convo above, but is this something you think is ready to land, or could be soon?

It was ready from my end (see #120 (comment)), when I handed it over to @galargh.

@vmx
Copy link
Contributor Author

vmx commented Aug 19, 2022

I case someone is looking into this, https://github.com/taiki-e/cargo-llvm-cov also looks quite promising (I haven't used it yet, though).

@galargh
Copy link
Contributor

galargh commented Aug 29, 2022

To address this we could switch the workflow trigger to pull_request or pull_request_target. We've done a similar change in filecoin-project/ref-fvm#467.

It's been waiting for input on the above suggestion. Now, it's been implemented in #510 so I think there are no outstanding issues with it.

Someone just has to resolve the conflicts - there's nothing complicated to resolve, it's just that I don't have write access to this repository.

@anorth
Copy link
Member

anorth commented Aug 29, 2022

Thanks, I've resolved conflicts.

I would prefer much of this were in the Makefile so it was easy for a dev to replicate, but I'll approve this and we can improve later.

@anorth
Copy link
Member

anorth commented Aug 29, 2022

@galargh CI failed, something about GH_TOKEN

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@anorth anorth enabled auto-merge (squash) August 30, 2022 23:10
@anorth anorth merged commit 159a585 into master Aug 30, 2022
@anorth anorth deleted the code-coverage branch August 30, 2022 23:50
Stebalien pushed a commit that referenced this pull request Sep 9, 2022
Generate a code coverage report and add it as artifact as well as
uploading it to CodeCov.

Co-authored-by: raulk <[email protected]>
Co-authored-by: Piotr Galar <[email protected]>
Co-authored-by: Alex <[email protected]>
Stebalien pushed a commit that referenced this pull request Sep 9, 2022
Generate a code coverage report and add it as artifact as well as
uploading it to CodeCov.

Co-authored-by: raulk <[email protected]>
Co-authored-by: Piotr Galar <[email protected]>
Co-authored-by: Alex <[email protected]>
shamb0 pushed a commit to shamb0/builtin-actors that referenced this pull request Jan 31, 2023
Generate a code coverage report and add it as artifact as well as
uploading it to CodeCov.


Co-authored-by: raulk <[email protected]>
Co-authored-by: Piotr Galar <[email protected]>
Co-authored-by: Alex <[email protected]>
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

Successfully merging this pull request may close these issues.

6 participants