Added code coverage badge in readme

This commit is contained in:
Marc Ole Bulling
2021-04-19 16:39:24 +02:00
parent abec640d64
commit 08c27d09c7
5 changed files with 25 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
# Gokapi
[![Go Report Card](https://goreportcard.com/badge/github.com/forceu/gokapi)](https://goreportcard.com/report/github.com/forceu/gokapi)
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-62%25-brightgreen.svg?longCache=true&style=flat)</a>
[![Docker Pulls](https://img.shields.io/docker/pulls/f0rc3/gokapi.svg)](https://hub.docker.com/r/f0rc3/gokapi/)

View File

@@ -1,8 +1,9 @@
module SingleDownload
module Gokapi
go 1.16
require (
github.com/otiai10/copy v1.5.1
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
)

View File

@@ -1,4 +1,5 @@
#!/bin/sh
#Called by go generate
#Sets the version number in the template automatically
sed -i 's/{{define "version"}}.*{{end}}/{{define "version"}}'$1'{{end}}/g' ../../internal/webserver/web/templates/string_constants.tmpl
sed -i 's/{{define "version"}}.*{{end}}/{{define "version"}}'$1'{{end}}/g' ../../internal/webserver/web/templates/string_constants.tmpl
echo "Set version in web template"

14
build/updateCoverage.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
#Called by go generate
#Creates the coverage for the README.md file if gopherbadger is installed
cd ../../
#Grep is used to hide output
which gopherbadger > /dev/null
if [ $? -eq 0 ]; then
gopherbadger -png=false -md=README.md -tags "test" > /dev/null
rm coverage.out
echo "Updated coverage in readme file"
else
echo "Gopherbadger not installed, not updating coverage"
fi

View File

@@ -66,3 +66,9 @@ const logo = `
██  ██ ██  ██ ██  ██  ██   ██ ██      ██ 
 ██████   ██████  ██  ██ ██  ██ ██  ██ 
`
// Generates coverage badge
//go:generate sh "../../build/updateCoverage.sh"
// Copy go mod file to docker image builder
//go:generate cp "../../go.mod" "../../build/go.mod"