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

Add code coverage tooling to the CI #172

Closed
ethanfrey opened this issue Dec 11, 2020 · 4 comments · Fixed by #715
Closed

Add code coverage tooling to the CI #172

ethanfrey opened this issue Dec 11, 2020 · 4 comments · Fixed by #715
Assignees
Milestone

Comments

@ethanfrey
Copy link
Member

It would be great to see the code coverage on the contract code from the unit tests. To see if critical checks/branches are properly covered.

One popular tool seems to be tarpaulin. But I am open to any other tool as well. (Note tarpaulin has a caveat about signals which is needed for any of the wasm/vm tests, but not when running contracts as native rust).

Deliverable:

  • A command to get code coverage for each contract (bonus: also the packages)
  • A way to visualize it locally (even if just text)
  • Automated upload to a web service in CI (eg. https://coveralls.io or https://codecov.io)

It would nice to run this locally as well. You can look at #171 as a possible way for scripts to work in CI as well as locally.

@ethanfrey
Copy link
Member Author

ethanfrey commented Dec 11, 2020

My quick local trial:

cargo install cargo-tarpaulin
cd cosmwasm-plus/contracts/cw3-flex-multisig

# this print out info on all files in all crates
cargo tarpaulin -v

# this still covers all crates (how to disable workspace?) but also shows html overview
cargo tarpaulin -v --lib -o html
xdg-open tarpaulin-report.html

# this seems to run tests in each crate one after another and get better coverage for all packages
cargo tarpaulin -v --lib --workspace -o html 
xdg-open tarpaulin-report.html

The last one actually gives nice results to help me finish up covering cw4-stake. Most of the missed functions were on my TODO list, but not all. (nb: code coverage of the repo is a bit over 90% - quick nice, but I am happy to try to bump it a bit higher)

@ethanfrey
Copy link
Member Author

After working with the cw4-stake contact a fair bit, I think the following is quite nice (add --workspace to show for all contracts):

cargo tarpaulin --lib --ignore-tests -o html

Or for everything

cargo tarpaulin --lib --ignore-tests --workspace -o html

@maurolacy
Copy link
Contributor

Nice. We can run this as part of the CI, and publish a report somewhere.

@ethanfrey
Copy link
Member Author

@maurolacy this might be an interesting task for Bart if he has experience with any such tooling.

CI stuff, but it does give insight into the project structure

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 a pull request may close this issue.

2 participants