diff_cover icon indicating copy to clipboard operation
diff_cover copied to clipboard

GitHub warning annotations

Open timkrins opened this issue 1 year ago • 2 comments

I don't think this is the perfect PR, but more created it as a point of discussion (and for my own use, as it solves my immediate use-case).

Adds a report generator that prints GitHub style annotations to stdout.

Right now, only warning is supported - I couldn't immediately determine how to pass a command line switch to the generator without changing the base class.

Screenshot of diff-cover coverage.lcov --github-warning-annotations running in GitHub actions |--| |Screenshot 2025-01-12 at 10 36 30| |Screenshot 2025-01-12 at 11 15 53|

timkrins avatar Jan 12 '25 11:01 timkrins

So at a high level this seems like a useful feature. I have a hard time thinking about new diff-cover/diff-quality features since I dont really use these tools anymore. I just maintain the project.

But it looks like Github annotations introduce some level of customizability (whats a warning, whats an error, whats a message). My gut is the approach taken here "Everything is a warning" seems reasonable. However, if others start using it I suspect the desire for customization will come up shortly after.

I think im happy to merge in a "everything is a warning" pr. Do yall think there will be much demand for further customization? Do you think we could get away with "look, the flag will do the basics but if you have more complex demands that config needs to be defined in some config file"?

Bachmann1234 avatar Jan 14 '25 02:01 Bachmann1234

For the use case like sqlfluff, both errors and warnings would be ideal.

Being able to add code suggestions is also useful, though I suspect most people will use a tool like reviewdog instead for that.

wyardley avatar Jan 14 '25 02:01 wyardley

Guess who had this same idea today.... [independently] ME! I'll help out, I would like to see this feature soon.

kingbuzzman avatar May 11 '25 09:05 kingbuzzman

Thanks @kingbuzzman

wyardley avatar May 24 '25 00:05 wyardley

@timkrins can you sync with main? Is this something you want to finish? Or would you like it/wouldn't mind if i took over?

kingbuzzman avatar Jun 12 '25 16:06 kingbuzzman

@kingbuzzman awesome regarding the format arguments. I'm a bit slammed atm but I will try and extract some time to rebase!

timkrins avatar Jun 12 '25 19:06 timkrins

No rebase needed, just in github click on the "resolve conflicts" button 😉

kingbuzzman avatar Jun 12 '25 19:06 kingbuzzman

I have rebased on main, and added the annotation format - although right now it is a TODO as I am still a bit unclear on an elegant way to pass the value down to the formatter and then template context.

timkrins avatar Jun 12 '25 21:06 timkrins

@timkrins ^

kingbuzzman avatar Jun 28 '25 22:06 kingbuzzman

@kingbuzzman I'll get to it this week :)

timkrins avatar Jun 28 '25 22:06 timkrins

@timkrins any idea when you'll get around to this? I kind of need this... If you're unwilling, i'll just merge my PR

kingbuzzman avatar Jul 14 '25 10:07 kingbuzzman

@Bachmann1234 this is Bellissimo!!! and should be [squashed] merged as soon as possible 😇

@timkrins thank you so much for your efforts and idea! This is going to be great for me, you have no idea how much code I will delete because of this! ❤️

kingbuzzman avatar Jul 15 '25 10:07 kingbuzzman

Alrighty! Lets go ahead and merge/release this. Thank you for the PR @timkrins and thanks for the review support @kingbuzzman

Bachmann1234 avatar Jul 17 '25 02:07 Bachmann1234

Released! Check out https://pypi.org/project/diff-cover/9.6.0/

Bachmann1234 avatar Jul 17 '25 02:07 Bachmann1234