gha-common / go-beautiful-html-coverage

A GitHub Action to track code coverage in your pull requests, with a beautiful HTML preview, for free.
https://gha-common.github.io/go-beautiful-html-coverage/go-test-app-01/head/head.html#file1
MIT License
4 stars 0 forks source link

Is incremental coverage supported? #35

Closed xhd2015 closed 1 month ago

xhd2015 commented 1 month ago

Xgo is working on a similar tool, the UI is still under refactoring. And I see this repository is doing this.

Are you going to support incremental coverage and CLI tool to display locally?

https://github.com/xhd2015/xgo/pull/106

xhd2015 commented 1 month ago

Chances are, maybe xgo can opt in into this tool?

kilianc commented 1 month ago

sure, what are the requirements?

xhd2015 commented 1 month ago

sure, what are the requirements?

When working a large code base, reviewing coverage of each file sucks as there were too many files.

Incremental coverage is a way to improve this experience. It filters out files not changed compared with master or main, which can be achieved by doing a git diff. And more, it should also filter out lines not changed within updated file.

This way, only changed code need a care on coverage.

How do you think?

kilianc commented 1 month ago

Understood, let me think about how to do it. see https://github.com/gha-common/go-beautiful-html-coverage/issues/15

kilianc commented 1 month ago

@xhd2015 can you open a pr here to create cover.out with your tool here? I want to see what it looks like.

edit --

doesn't look like your tool does the incremental part, is the .out file generated by go tool?

xhd2015 commented 1 month ago

@xhd2015 can you open a pr here to create cover.out with your tool here? I want to see what it looks like.

edit --

doesn't look like your tool does the incremental part, is the .out file generated by go tool?

Sure, let me do this later.

Actually it does, but that part of code is still being open-sourcing. So now only binary is released.But soon the code will be opened.

kilianc commented 1 month ago

would simply diffing main.out and current.out work?

xhd2015 commented 1 month ago

would simply diffing main.out and current.out work?

Maybe. I can try that

xhd2015 commented 1 month ago

can you open a pr here to create cover.out with your tool here? I want to see what it looks like.

@kilianc I think I misunderstood you. The xgo tool does not generate a cover profile. Actually it converts that profile into a web-based UI in combination with git diff, hence the so called incremental.

kilianc commented 1 month ago

I think that diffing the cover.out and then creating the html will work. I am a bit sick but I will be able to write some tests in the next few days.

kilianc commented 1 month ago

it works: https://github.com/gha-common/go-beautiful-html-coverage/pull/39

kilianc commented 1 month ago

making some progress on having dark and light themes from github and refining the UI.

image

I don't think it will be as feature rich as the one you posted tho.

xhd2015 commented 1 month ago

making some progress on having dark and light themes from github and refining the UI.

image

I don't think it will be as feature rich as the one you posted tho.

Amazing! At least this is the first step to make it work!

kilianc commented 1 month ago

Just merged into main, I need to add a "incremental button" to the UI and then I'll focus on the CLI.

@xhd2015 how do you get information about your base branch in your tooling? For example in feature-a branch, how do you compare it main? do you checkout main and run the tests? Is the coverage saved somewhere?

If this was a cli, like go run go-beautiful-html-coverage what would be the arguments?

xhd2015 commented 1 month ago

Just merged into main, I need to add a "incremental button" to the UI and then I'll focus on the CLI.

@xhd2015 how do you get information about your base branch in your tooling? For example in feature-a branch, how do you compare it main? do you checkout main and run the tests? Is the coverage saved somewhere?

If this was a cli, like go run go-beautiful-html-coverage what would be the arguments?

This part of diffing is not open sourced yet, I'll work on this later.

Basically it just uses the exec.Command to spawn some git diff process and capture the output.

kilianc commented 1 month ago

but that's not enough to diff the coverage, a change on foo.go#13 might affect coverage of func Bar in bar.go#56. The diff won't help you understand the impact of your code changes on coverage.

You need a full coverage diff against the base branch of your PR. When running locally, where do you get the coverage from? run the tests on main and cache them?

xhd2015 commented 1 month ago

Oh so you are right, I missed the affect-chain problems... Currently only static diff is considered

kilianc commented 1 month ago

closing this for now