diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c675ff5..f936396 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,22 @@ jobs: with: go-version-file: go.mod cache: true - - run: go test ./... + + - name: Run tests + run: go test -v -coverprofile=coverage.out ./... + + - name: Show coverage report + run: go tool cover -func=coverage.out + + - name: Enforce 60% coverage threshold + run: | + COVERAGE=$(go tool cover -func=coverage.out | grep '^total:' | awk '{print $3}' | tr -d '%') + echo "Total coverage: ${COVERAGE}%" + if awk "BEGIN { exit !($COVERAGE < 60) }"; then + echo "FAIL: coverage ${COVERAGE}% is below the required 60%" + exit 1 + fi + echo "OK: coverage ${COVERAGE}% meets the 60% threshold" build: name: Build