Current state of code coverage in Rust - June 2023

There was a previous discussion at

What are the current options available for SaaS tracking of code coverage, and what are any gotchas?

I briefly used codecov.io for private Rust projects on GitHub about 2 years ago, but have no experience with it on Public repos. Rust - Codecov links to GitHub - codecov/example-rust which is mostly 4 years old, and doesnt use the newer source-based code coverage . But https://github.com/jwodder/rust-coverage-test/blob/grcov-codecov/.github/workflows/test.yml looks like it does support it.

I've recently found out that DeepSource.io doesnt support OSS with Pull Requests from forks. How to use DeepSource coverage on public repositories - Help Wanted - DeepSource Discuss

I also could find any documentation on whether coveralls supports token-less coverage uploads.

SonarCloud still doesnt support Rust. Add Rust language support - New rules / language support - Sonar Community

GitLab appears to be able to store code coverage directly in GitLab according to Test coverage visualization | GitLab . Does that work with Rust ?

Phabricator has an API for storing and retrieving coverage data per changeset, and ⚓ T13125 Plans: Code coverage reporting outlines their future plans.

Are there other SaaS for tracking coverage data? Especially any that support Rust?

I've been successfully able to set up code coverage reporting on public repositories with CodeCov. See my project dyn-iter for example. In particular, this piece of Gitlab CI seems to work for me.

coverage:
  stage: test
  interruptible: true
  before_script:
    - rustup show
    - rustc --version
    - cargo --version
    - curl --location --output /tmp/tarpaulin.tar.gz https://github.com/xd009642/tarpaulin/releases/download/0.25.2/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz
    - tar --extract --verbose --gzip --file /tmp/tarpaulin.tar.gz --directory /usr/local/bin/
    - cargo tarpaulin --version
  script:
    - cargo tarpaulin --all-features --workspace --out Xml
    - bash <(curl -s https://codecov.io/bash)
  cache:
    key: "${CI_COMMIT_REF_NAME}"
    paths:
      - target/

I remember having tried to setup code coverage on Gitlab directly too, but without any success.

2 Likes

We use the following code in Ratatui to upload code coverage to codecov.io in a github action using source based coverage

The resulting code coverage dashboard is at https://app.codecov.io/gh/tui-rs-revival/ratatui/

Take a look at any recent PRs in our repo for details on how codecov.io interacts Pull requests · tui-rs-revival/ratatui · GitHub to

2 Likes

Thanks to what was posted by @joshka, I've been able to adapt it in a more general scripting solution (to avoid dependency on Github Actions). In my case, it's Gitlab CI, but the script should be easily adaptable anywhere.

And coverage is available here (yes, coverage of this project is bad :stuck_out_tongue:).

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.