I would like to share a quick tip about adding badges to Github README for Go Benchmark tests.
Generally the benchmarks output is posted as it is on the README by repo owners. Example:
1000       8069938 ns/op     7360722 B/op      19794 allocs/op
2000       8272545 ns/op     7370076 B/op      19794 allocs/op
Using the following action - it can be both measured and tracked over lifetime of a project.
Using it as a Badge in README
Using it as Tiny Widget in README
Using it as PR Comment
You can even view the history of all the benchmark tests within the PR for all commits, such as:
Method on how to add this is simple:
- uses: kevincobain2000/action-coveritup@v2
  with:
    type: allocs-per-op
    command: go test -count 1 -bench=. ./... -benchmem|grep allocs|awk '{ print $(--NF)}'
    record: score
    metric: alloc
This method doesn't require publishing the results to separate gh-pages and has instant feedback feature which is helpful to the code reviewer when reviewing the code changes instantly.
Similarly - other metrics can also be recorded for test scores or lint errors etc.
Full details link: https://coveritup.app/
Full action's docs: https://github.com/kevincobain2000/action-coveritup
Live Demo pull req link: https://github.com/kevincobain2000/gobrew/pull/191
I hope you found something new in this post.
Thanks for reading.
 






 
    
Top comments (0)