VeryGoodOpenSource / very_good_coverage

GitHub Action which helps enforce code coverage threshold using lcov created by Very Good Ventures 🦄
MIT License
159 stars 18 forks source link

Add Comments to PRs with Coverage Details #101

Open mtwichel opened 2 years ago

mtwichel commented 2 years ago

Is your feature request related to a problem? Please describe. I really like the new feature where the lines missed will print in the output of the actions; however, I find it kinda annoying to go into the action details and click through to find what I am looking for.

Describe the solution you'd like I think it would be really cool if the action could be optionally configured to write a comment on your PR with a brief report of your coverage stats. We could include if it passed, what percentage it calculated, and list any lines missed. When you re-ran the action, it would update the comment with the new details, so it wouldn't pollute the PR.

The feature is inspired by how the firebase hosting deploy action adds a comment with a preview URL. I think we can also take queues from their code for how to accomplish it.

I would propose adding new inputs as well:

Describe alternatives you've considered One alternative I've played with is adding outputs to the existing action - that way, subsequent steps could post the comment (like using this action). That works well enough (I have a fork working now), but it really requires a fair bit of work to make your workflow work (for example, conditionally writing a new comment vs update existing; formatting with markdown, ect). I'd rather have it contained in an action to make it easy to add to lots of projects.

Of course, I could make a separate action that takes outputs from VGC as inputs and writes the comments. I think that would be a viable option, but would suffer discoverability and would be a fair bit more work to set up.

Thanks as always VGV! I'm happy to help make this a reality, but I think there's some debate on the best way to set this up :)

mtwichel commented 2 years ago

Of course, I could make a separate action that takes outputs from VGC as inputs and writes the comments. I think that would be a viable option, but would suffer discoverability and would be a fair bit more work to set up.

If we go this route, on the step that calls the new action, we would have to add

if: ${{ always() }}

This is because if you're below the coverage threshold, VGC will error and cause the workflow to terminate. Adding this line to the step forces it to run anyways (but the workflow still fails).

Not a big deal, but maybe a bit annoying to remember every time?

jolexxa commented 2 years ago

Great idea! We can also draw inspiration from the comment posted by this coverage action: https://github.com/zgosalvez/github-actions-report-lcov

felangel commented 1 year ago

Could use https://github.com/leancodepl/dart-problem-matcher for inspiration as well

DFelten commented 1 year ago

The option to display the information as a job summary would also be great.

alestiago commented 1 year ago

Could use codecov for inspiration as well