diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc6a0ef1..6cc9f81c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: hooks: - id: make-check name: make check - description: Run project checks, gofmt, golangci-lint, tests and coverage + description: Run project checks, gofmt, golangci-lint, tests entry: make check language: system pass_filenames: false diff --git a/Makefile b/Makefile index 10488dc9..00a86d7e 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ GREEN := $(shell printf "\033[32m") RED := $(shell printf "\033[31m") RESET := $(shell printf "\033[0m") -COVERAGE_REQUIRED := 55 MOCKGEN_VERSION := 0.5.2 LINTER_VERSION := 2.1.6 @@ -27,11 +26,8 @@ modtidy: .PHONY: test test: ## We have several race condition warnings (as expected), but those will be fixed on the next PRs - ## GO_ENABLED=1 go test -race -count=1 -vet all -coverprofile=cover.out.tmp ./... - go test -count=1 -vet all -coverprofile=cover.out.tmp ./... - grep -v -e "_mock\.go:" -e "/mocks/" -e "/docs/" cover.out.tmp > cover.out - go tool cover -func=cover.out - rm cover.out.tmp + ## CGO_ENABLED=1 go test -race -count=1 -vet all -coverprofile=cover.out ./... + go test -count=1 -vet all -coverprofile=cover.out ./... save: build docker save $(image_name) > $(image_file_name) @@ -45,17 +41,7 @@ build-local: generate: check-mockgen-version go generate ./... -check: lint test coverage-check - -.PHONY: coverage-check -coverage-check: test - @coverage=$$(go tool cover -func=cover.out | grep '^total:' | awk '{print $$3}' | sed 's/%//g'); \ - if awk "BEGIN {exit !($$coverage < $(COVERAGE_REQUIRED))}"; then \ - echo "error: coverage ($$coverage%) must be at least $(COVERAGE_REQUIRED)%"; \ - exit 1; \ - else \ - echo "test coverage: $$coverage% (threshold: $(COVERAGE_REQUIRED)%)"; \ - fi +check: lint test .PHONY: test-coverage test-coverage: test coverage-check diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..65930235 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,33 @@ +coverage: + ignore: + # Exclude main.go since we mostly use it for Dependency Injection + - "main.go" + - "cmd/main.go" + + # Test files - these shouldn't be included in coverage + - "**/*_test.go" + + # Mock files - generated code for testing + - "**/*_mock.go" + - "**/mocks" + + # Vendor directory - third-party dependencies + - "**/vendor/**" + + # Documentation and examples + - "**/docs" + - "**/examples/**" + + # Build and CI related files + - "**/.ci/**" + - "**/tools.go" # Build tools imports + + # Test utilities and fixtures + - "**/testdata/**" + - "**/fixtures/**" + - "**/tests/**" # If this contains test utilities rather than actual tests + + status: + project: + default: + target: 70% \ No newline at end of file