-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (63 loc) · 2.22 KB
/
Makefile
File metadata and controls
74 lines (63 loc) · 2.22 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.PHONY: all fmt mod lint test test-race test-coverage build-examples clean help
# Default target
all: help
# Initialization
setup:
@echo "=> Install Go dependencies..."
@go mod download
@echo "=> Install pre-commit hooks..."
@if ! command -v pre-commit >/dev/null 2>&1; then \
echo "❌ ERROR: Pre-commit is not installed. Please install it via 'pip install pre-commit' or 'brew install pre-commit' first."; \
exit 1; \
fi
@pre-commit install
@echo "✅ Environment setup successful! You are now ready to contribute code."
# Format the entire Go source code
fmt:
@echo "==> Formatting code..."
go fmt ./...
# Tidy and verify module dependencies
mod:
@echo "==> Tidying and verifying module dependencies..."
go mod tidy
go mod verify
# Run golangci-lint
lint:
@echo "==> Running linter..."
golangci-lint run --timeout=5m ./...
PACKAGES := $(shell go list ./... | grep -v /cmd/examples | grep -v "test")
# Run all unit test
test:
@echo "==> Running tests..."
go test -v $(PACKAGES)
# Run tests with data race detector
test-race:
@echo "=> Running tests with Race Detector..."
go test -race -v $(PACKAGES)
# Run tests and generate coverage report
test-coverage:
@echo "==> Running tests with coverage..."
go test -v -race -coverprofile=coverage.out $(PACKAGES)
go tool cover -html=coverage.out -o coverage.html
@echo "==> Coverage report generated at coverage.html"
@TOTAL=$$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'); \
echo "📊 Total Test Coverage: $$TOTAL%"; \
if awk "BEGIN {exit !($$TOTAL < 80.0)}"; then \
echo "❌ ERROR: Test Coverage ($$TOTAL%) is below the 80.0% threshold. Please write more tests!"; \
exit 1; \
else \
echo "✅ EXCELLENT: Test Coverage meets production standards!"; \
fi
# Build all examples to ensure they compile
build-examples:
@echo "==> Building examples..."
go build -o /dev/null ./cmd/examples/...
# Clean build artifacts
clean:
@echo "==> Cleaning..."
go clean
rm -f coverage.out coverage.html
# Show this help menu
help:
@echo "llmgo Makefile Commands:"
@awk '/^#/ { desc = substr($$0, 2); sub(/^ /, "", desc); next } /^[a-zA-Z_-]+:/ && desc { sub(/:.*/, "", $$1); printf " \033[36m%-20s\033[0m %s\n", $$1, desc; desc = "" }' $(MAKEFILE_LIST)