GithubHelp home page GithubHelp 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

alexbeauchemin avatar alecoletti avatar tcarreira avatar acidjazz avatar mfreeman451 avatar

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.