ttytm / wthrr-the-weathercrab

🌞 πŸ¦€ πŸŒ™ Weather companion for the terminal. Rust app.
https://crates.io/crates/wthrr
MIT License
390 stars 26 forks source link

[Suggestion] Local Code Coverage #103

Closed kevinmatthes closed 1 year ago

kevinmatthes commented 1 year ago

In the last days, I had been working on a GitHub Action workflow to determine the coverage of Rust projects locally. The result is reported as a comment by the GitHub Actions bot on the respective PR. Local means that you do not need to install any GitHub app like Coveralls or Codecov. Furthermore, old comments are updated such that there is just one coverage report per PR.

It already works stably but it takes about seven minutes because it does not cache the dependencies, yet, at the moment. Are you interested anyway?

ttytm commented 1 year ago

Coverage on the repo is not good atm. Knowing this, I hesitate to add it as I feel it should be improved beforehand.

However, I'm generally interested in it, and I'm sure I'm not the only one if anyone else is reading. Could you share the link to your work 😊?

kevinmatthes commented 1 year ago

This is the repository applying the workflow I mentioned: https://github.com/kevinmatthes/aeruginous-rs. It is my state-of-the-art repository meaning it applies all automation technologies and strategies I developed and / or tested during the last years. Well, except for the Rust code coverage which does not cache, yet (but I am working on it). If you like certain technologies, I can configure them for this repository, as well.

Here is an example of how the workflow will look: https://github.com/kevinmatthes/aeruginous-rs/pull/76. Ironically, this is also the PR were I try to add caching, at the moment. The workflow itself is defined here: https://github.com/kevinmatthes/aeruginous-rs/blob/main/.github/workflows/pr.yml. On each PR which is about to edit Rust code or related files, the code will be formatted using cargo fmt. Afterwards, the coverage is determined using cargo-tarpaulin.

Finally, some words about Aeruginous. It is a toolbox with some useful development utilities I developed. By now, it can mirror a Rust crate's root's documentation to the repository's README and cite other projects in the respective CFF. Other tools are about to be integrated with the next releases.

danieleades commented 1 year ago

What's wrong with using an app like codecov?

As an aside, adding coverage monitoring before having high levels of cover is the best time to add it. That way you can monitor progress and ensure that every PR incrementally improves the coverage

kevinmatthes commented 1 year ago

GitHub Apps are always further options, that is true. But please also take into account that some of them might need assistance by additional GitHub Action workflows for the initial data collection like Coveralls does; you need to collect the code coverage with Tarpaulin, at first, and to upload the data after that as Coveralls does not support Rust out of the box. There are Actions to do so but they still need to be assembled together in a workflow.

A good argument for using a GitHub Action workflow instead of an App is thus that you would need one anyway (depending on the desired GitHub App), making the GitHub App the actual additional overhead.

ttytm commented 1 year ago

As an aside, adding coverage monitoring before having high levels of cover is the best time to add it. That way you can monitor progress and ensure that every PR incrementally improves the coverage

True. Knowing that cov is low and that I won't have the chance to actively improve it is slightly widened context behind my hesitation. I can't make a strong case against it, so if you both think it fits, then let's start here. πŸ™‚πŸ‘ I'll survive the low cov being exposed for a while.

kevinmatthes commented 1 year ago

What would be your favourite solution: a GitHub Action workflow or a GitHub App?

danieleades commented 1 year ago

110 is a copy and paste from one of my repos, for consideration. You'll need to add the 'codecov' app to get PR comments/reports though, as discussed above

maybe hold off adding a coverage badge to the readme for the time being ;)

ttytm commented 1 year ago

What would be your favourite solution: a GitHub Action workflow or a GitHub App?

Thanks, I haven't done anything cov related with rust apps or on github. I'll need to take a closer look to get an opinion.

ttytm commented 1 year ago

I would like to go with what you did in https://github.com/kevinmatthes/aeruginous-rs @kevinmatthes. If its not too much of a hassle, can you prep a nice slice of your work there that fits for wthrr?

I'll certainly use the codecov app for some of my upcoming projects. But getting the chance with something custom and exclusive like aeruginou provides I don't want to miss out on the experience ☺️.

kevinmatthes commented 1 year ago

@tobealive

I will submit my suggestion tomorrow.