-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (47 loc) · 1.8 KB
/
Makefile
File metadata and controls
58 lines (47 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# push-validator-cli Makefile
COVERAGE_DIR := .coverage
COVERAGE_PROFILE := $(COVERAGE_DIR)/coverage.out
COVERAGE_HTML := $(COVERAGE_DIR)/coverage.html
PACKAGES := ./cmd/... ./internal/...
MIN_COVERAGE ?= 10
.PHONY: test coverage coverage-html coverage-check coverage-summary clean-coverage build lint help
## test: Run all tests with race detection
test:
go test -v -race $(PACKAGES)
## coverage: Run tests with coverage and show per-package breakdown
coverage: clean-coverage
@mkdir -p $(COVERAGE_DIR)
go test -v -race -covermode=atomic -coverprofile=$(COVERAGE_PROFILE) $(PACKAGES)
@echo ""
@echo "=== Coverage Summary ==="
@go tool cover -func=$(COVERAGE_PROFILE) | grep total:
@echo ""
@echo "=== Per-Package Coverage ==="
@go tool cover -func=$(COVERAGE_PROFILE)
@echo ""
@echo "Coverage profile: $(COVERAGE_PROFILE)"
## coverage-html: Generate HTML coverage report and open it
coverage-html: coverage
go tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
@echo "HTML report: $(COVERAGE_HTML)"
@command -v open >/dev/null 2>&1 && open $(COVERAGE_HTML) || true
## coverage-check: Verify coverage meets minimum threshold
coverage-check: coverage
@bash scripts/check-coverage.sh $(MIN_COVERAGE)
## coverage-summary: Print only the total coverage percentage
coverage-summary:
@mkdir -p $(COVERAGE_DIR)
@go test -covermode=atomic -coverprofile=$(COVERAGE_PROFILE) $(PACKAGES) > /dev/null 2>&1
@go tool cover -func=$(COVERAGE_PROFILE) | grep total: | awk '{print $$3}'
## clean-coverage: Remove coverage artifacts
clean-coverage:
@rm -rf $(COVERAGE_DIR)
## build: Build the push-validator binary
build:
go build -o push-validator ./cmd/push-validator/
## lint: Run golangci-lint
lint:
golangci-lint run ./...
## help: Show available targets
help:
@grep -E '^## ' Makefile | sed 's/## //' | column -t -s ':'