-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (104 loc) · 3.5 KB
/
Makefile
File metadata and controls
126 lines (104 loc) · 3.5 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Makefile for Golang package
# Variables
BINARY_NAME=gencache
VERSION?=1.0
GOOS?=$(shell go env GOOS)
# Go commands
GO=go
GOTEST=$(GO) test
GOMOD=$(GO) mod
GOGET=$(GO) get
GOVET=$(GO) vet
GOFMT=gofmt
GOLINT=golangci-lint
.PHONY: test coverage run lint fmt vet tidy vendor help benchmark benchmark-cpu benchmark-mem godoc godoc-server clean test-integration test-benchmark
# Default target
all: lint test
# Run tests
test:
@echo "Running tests (excluding tests/)..."
@find . -type d -not -path './tests*' -not -path './.git*' | xargs -I {} $(GO) test -v -race -timeout=5m {}
# Run integration tests
test-integration:
@echo "Running integration tests..."
@$(GOTEST) -v -race -timeout=5m ./tests/integration/...
# Run benchmark tests
test-benchmark:
@echo "Running benchmark tests..."
@$(GOTEST) -bench=. -benchmem -timeout=5m ./tests/benchmark/...
# Run tests with coverage
coverage:
@echo "Running tests with coverage..."
@$(GOTEST) -v -coverprofile=coverage.out ./...
@$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated at coverage.html"
# Run benchmarks
benchmark:
@echo "Running all benchmarks..."
@$(GOTEST) -bench=. -benchmem ./...
# Run CPU benchmarks
benchmark-cpu:
@echo "Running CPU benchmarks..."
@$(GOTEST) -bench=. -benchmem -cpuprofile=cpu.out ./...
@$(GO) tool pprof -top cpu.out
# Run memory benchmarks
benchmark-mem:
@echo "Running memory benchmarks..."
@$(GOTEST) -bench=. -benchmem -memprofile=mem.out ./...
@$(GO) tool pprof -top mem.out
# Run linter
lint:
@echo "Running linter..."
@$(GOLINT) run ./...
# Format code
fmt:
@echo "Formatting code..."
@$(GOFMT) -s -w .
# Run go vet
vet:
@echo "Running go vet..."
@$(GOVET) ./...
# Update go.mod
tidy:
@echo "Tidying modules..."
@$(GOMOD) tidy
# Download dependencies to vendor directory
vendor:
@echo "Vendoring dependencies..."
@$(GOMOD) vendor
# Install development tools
install-tools:
@echo "Installing development tools..."
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
@go install github.com/golang/mock/mockgen@latest
@go install golang.org/x/tools/cmd/goimports@latest
# Generate GoDoc HTML documentation
godoc:
@echo "Static HTML generation is no longer supported by godoc."
@echo "Use 'make godoc-server' and browse http://localhost:6060 instead."
godoc-server:
@echo "Starting local GoDoc server at http://localhost:6060 ..."
@go install golang.org/x/tools/cmd/godoc@latest
@godoc -http=:6060
# Display help information
help:
@echo "Available targets:"
@echo " test - Run all tests"
@echo " test-integration - Run integration tests"
@echo " test-benchmark - Run benchmark tests"
@echo " coverage - Run tests and generate coverage report"
@echo " benchmark - Run all benchmarks"
@echo " benchmark-cpu - Run CPU benchmarks with profiling"
@echo " benchmark-mem - Run memory benchmarks with profiling"
@echo " lint - Run linter"
@echo " fmt - Format code"
@echo " vet - Run go vet"
@echo " tidy - Update go.mod"
@echo " vendor - Download dependencies to vendor directory"
@echo " install-tools - Install development tools"
@echo " godoc - (Info only) Static HTML generation is not supported; use godoc-server"
@echo " godoc-server - Run a local GoDoc server at http://localhost:6060"
@echo " help - Display this help"
clean:
go clean -testcache -modcache -cache
find . -type f -name '*.out' -delete