Skip to content

add cache, generate grafana dashboard #2

add cache, generate grafana dashboard

add cache, generate grafana dashboard #2

Workflow file for this run

name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.20'
- run: go version
- name: Check out code
uses: actions/checkout@v2
- name: Build
run: go build -v ./...
- name: Test
run: |
CVPKG=$(go list ./... | grep -v mocks | tr '\n' ',')
go test -p 1 -coverpkg=${CVPKG} -coverprofile=coverage.out -covermode=count ./...
- name: Code Coverage Badge
run: |
set -x
total=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
if (( $(echo "$total <= 50" | bc -l) )) ; then
COLOR=red
elif (( $(echo "$total > 80" | bc -l) )); then
COLOR=green
else
COLOR=orange
fi
curl "https://img.shields.io/badge/coverage-$total%25-$COLOR" > .github/badges/coverage.svg
- name: Commit and push the badge (if it changed)
uses: EndBug/add-and-commit@v9
with:
default_author: github_actor
message: 'commit badge'
add: '*.svg'