Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Update README.md

Update README.md #66

Workflow file for this run

name: test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Test
run: |
pkg=$(go list ./... | grep -v /logx | grep -v /mock | tr '\n' ',' )
go test -v -race -coverpkg=$pkg -coverprofile=profile.cov ./...
- name: Coverage
run: go tool cover -html profile.cov -o report.html
- name: GitHub Badge
run: |
total=$(go tool cover -func profile.cov | 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
mkdir -p dist
cp report.html dist/report.html
curl "https://img.shields.io/badge/coverage-$total%25-$COLOR" > dist/badge.svg
cd dist
git init
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Updated coverage"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: coverage
force: true
directory: dist