-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (73 loc) · 3.06 KB
/
Makefile
File metadata and controls
96 lines (73 loc) · 3.06 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
# Declare all phony targets (targets that don't create files)
.PHONY: all bench cyclo default demo-colors demo-list demo-progress demo-table fmt help lint profile test test-race tools vet
default: help
# ============================================================================
# Main targets
# ============================================================================
## all: Run all checks: tests and benchmarks
all: test bench
# ============================================================================
# Testing targets
# ============================================================================
## bench: Run benchmark tests with memory profiling
bench:
go test -bench=. -benchmem
## test: Run tests with coverage (runs fmt, vet, lint, and cyclo first)
test: fmt vet lint cyclo
go test -cover -coverprofile=.coverprofile ./...
## test-no-lint: Run tests with coverage (runs fmt, vet, and cyclo first)
test-no-lint: fmt vet cyclo
go test -cover -coverprofile=.coverprofile ./...
## test-race: Run tests and progress demo with race detector
test-race:
go test -race ./...
go run -race ./cmd/demo-progress
# ============================================================================
# Code quality targets
# ============================================================================
## cyclo: Check cyclomatic complexity (warns if complexity > 13)
cyclo:
gocyclo -over 13 ./*/*.go
## fmt: Format code and organize imports
fmt:
go fmt ./...
gosimports -w .
## lint: Run golangci-lint static analysis
lint:
golangci-lint run ./...
## vet: Run go vet static analysis
vet:
go vet ./...
# ============================================================================
# Demo targets
# ============================================================================
## demo-colors: Run the colors demo
demo-colors:
go run cmd/demo-colors/demo.go
## demo-list: Run the list demo
demo-list:
go run cmd/demo-list/demo.go
## demo-progress: Run the progress demo
demo-progress:
go run cmd/demo-progress/demo.go
## demo-table: Run the table demo
demo-table:
go run cmd/demo-table/demo.go
# ============================================================================
# Utility targets
# ============================================================================
## help: Display help information for all available targets
help:
@echo "\033[1mAvailable targets:\033[0m"
@awk '/^# [A-Z].*targets$$/ {gsub(/^# /, ""); print "\n\033[1;36m" $$0 "\033[0m"} /^##/ {gsub(/^##\s*/, ""); idx=match($$0, /: /); if(idx) {target=substr($$0,1,idx-1); desc=substr($$0,idx+2); printf " \033[36mmake\033[0m \033[32m%-15s\033[0m \033[33m- %s\033[0m\n", target, desc}}' $(MAKEFILE_LIST)
## profile: Run profiling script
profile:
sh profile.sh
## tools: Install required development tools
tools: tools-ci
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2
## tools-ci: Install required development tools for CI
tools-ci:
go install github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0
go install github.com/mattn/goveralls@v0.0.12
go install github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8