fix(ci): add coverage check
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 11s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 7s
Lint Markdown files / Run markdown linter (push) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 31s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 23s

This commit is contained in:
2025-10-28 19:12:43 +01:00
parent d3473751cc
commit a74c429696
2 changed files with 12 additions and 1 deletions

View File

@@ -40,3 +40,14 @@ jobs:
- env:
GOPROXY: ${{ vars.GOPROXY }}
run: make test/unit
- id: coverage
name: Check coverage
run: |
coverage="$(make test/coverage | grep total | awk '{ print substr($3, 1, length($3)-1); }')"
echo "total_coverage=$coverage" >> $GITHUB_OUTPUT
echo "Total coverage: ${coverage}%"
- name: Fail if coverage is to low
run: |
if (( $(echo "${total_coverage} < 50" | bc -l) )); then
echo "ERROR: Coverage (${total_coverage}%) is below the threshold (50%)."
fi

View File

@@ -52,7 +52,7 @@ PHONY+=test/coverage
test/coverage: test/unit
CGO_ENABLED=0 \
GOPROXY=$(shell go env GOPROXY) \
go tool cover -html=coverage.txt
go tool cover -func=coverage.txt
# GOLANGCI-LINT
# ==============================================================================