Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maheshrayas/action-coverage-badge

Updates img.shields.io coverage percentage dynamically
https://github.com/maheshrayas/action-coverage-badge

Last synced: 15 days ago
JSON representation

Updates img.shields.io coverage percentage dynamically

Awesome Lists containing this project

README

        


action-coverage-badger






## Motivation

Img shields can display coverage badge when you pass the percentage in the url (https://img.shields.io/badge/coverage-24%25-red). This URL can be pasted in README.md in html tag `` which would display a Github Badge. Since the url is static with the coverage percentage hardcoded we needed a mechanism to dynamically update the test coverage % whenever a code is added or removed.

This GHA will be triggered whenever a change is pushed to default branch. It reads the cover.json, updates the coverage % in the README.md, create a PR to default branch and automerges.

## Configuration in GHA workflow for Go Coverage

Refer to the example on how to setup the github action
https://github.com/maheshrayas/go-badger-test

### Makefile

```bash
.PHONY: dependencies
## Install dependencies
dependencies:
go get -u github.com/jstemmer/go-junit-report \
&& go get github.com/axw/gocov/gocov \

build: dependencies
go build ./...

test: build
rm -rf cover.* cover
mkdir -p cover
go test ./... -v -coverprofile ./cover.out
gocov convert cover.out > cover.json
```

```bash
name: updated pr
on:
pull_request:
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
go-version: 1.16.7
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run tests
id: test
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: |
make test
- name: release-notifier
uses: maheshrayas/action-coverage-badge@v1
with:
token: '${{ secrets.GITHUB_TOKEN }}'
user:
email:
```

## Supported Languages

* Go

## TODO

* Support other languages