diff --git a/.github/workflows/action.yml b/.github/workflows/actions.yml similarity index 66% rename from .github/workflows/action.yml rename to .github/workflows/actions.yml index 13577f3..c625473 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/actions.yml @@ -33,8 +33,18 @@ jobs: - name: Update dependencies run: go mod tidy - - name: Test - run: go test ./... -v + - name: Test with Coverage + run: go test ./... -coverprofile=coverage.txt -covermode=atomic + + - name: Check Coverage + run: | + go tool cover -func=coverage.txt -o coverage-summary.txt + COVERAGE=$(go tool cover -func=coverage.txt | grep total: | awk '{print substr($3, 1, length($3)-1)}') + echo "Total test coverage: $COVERAGE%" + if (( $(echo "$COVERAGE < 70" |bc -l) )); then + echo "Test coverage is below 70%" + exit 1 + fi env: GO111MODULE: on diff --git a/README.md b/README.md index 9a79fee..fb9ec1e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ The `httpclient-call-go` library simplifies making HTTP calls to various API services efficiently and straightforwardly. It is designed to seamlessly integrate into any Go project requiring HTTP API interactions. +![Actions](https://github.com/pzentenoe/httpclient-call-go/actions/workflows/actions.yml/badge.svg) +![Build](https://github.com/pzentenoe/httpclient-call-go/actions/workflows/actions.yml/badge.svg) ### Buy Me a Coffee