Giter Club home page Giter Club logo

gobadge's Introduction

GOBadge

Coverage

๐Ÿ‘† Easily create and insert coverage badge (or any other badge) in your readme with go

Using https://shields.io, the executable will generate a coverage badge based on the coverage output. The badge will be inserted on the second line of the readme if it doesn't exist, and will be updated if already present.

How to use

Install the executable

go install github.com/AlexBeauchemin/gobadge@latest

Make sure you generate a coverage file with your total coverage, something like

go test ./... -covermode=count -coverprofile=coverage.out fmt
go tool cover -func=coverage.out -o=coverage.out

Your output should looks like this, with the total as the last line

...
github.com/AlexBeauchemin/go-coverage-badge/gobadge.go:36:	retrieveTotalCoverage	87.5%
github.com/AlexBeauchemin/go-coverage-badge/gobadge.go:53:	updateReadme		80.0%
total:								(statements)		67.4%

Then run the executable

gobadge -filename=coverage.out

Flags

Flag Default Description
filename output.out File to scan for the coverage total
label Coverage Left-side content of the badge
value Right-side content of the badge
yellow 30 At what percentage the badge will become yellow instead of red
green 70 At what percentage the badge becomes green instead of yellow
color Force a color for the badge
target README.md Where to insert the badge
link Optional URL when you click the badge

Examples

gobadge -filename=coverage.out
gobadge -label="Go Coverage" -value=55.6% -color=blue -target=OTHER_README.md
gobadge -yellow=60 -green=80
gobadge -color=ff69b4
gobadge -link=https://github.com/project/repo/actions/workflows/test.yml

TODO

  • Add a silent mode with no output to console/stdout
  • Allow to specify a line number in the target file for badge creation
  • Allow to specify a template to look for in the target file for badge creation

gobadge's People

Contributors

acidjazz avatar alexbeauchemin avatar mfreeman451 avatar tcarreira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gobadge's Issues

Ability to specify a link

i'd like to link my test actions from the badge:

[![Coverage](https://img.shields.io/badge/Coverage-9.8%25-red)](https://github.com/my/repo/actions/workflows/test.yml)

Ideally if you can preserve/save the original link that would be awesome - but an optional parameter like -link will work as well

Support for other README file formats

GitHub support a variety of file formats for project README files, so it would be nice to add support for more than just markdown.

The syntax expected should be able to be inferred from the file extension of the target as there are a limited set of extensions GitHub will recognise in their renderer. Though ofc. there could also be an additional param added to override that, if you care to support people doing weird things.

If you don't have the time to work on this kind of thing right now, and are open to pull requests, I could possibly take a swing at the code required for this (probably starting with asciidoc as I know it is relatively similar to markdown).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.