diff --git a/.gitea/workflows/golang-tests.yaml b/.gitea/workflows/golang-tests.yaml index b861bb5..4e4ff1c 100644 --- a/.gitea/workflows/golang-tests.yaml +++ b/.gitea/workflows/golang-tests.yaml @@ -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 diff --git a/Makefile b/Makefile index bad33ab..156a6f0 100644 --- a/Makefile +++ b/Makefile @@ -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 # ==============================================================================