Skip to content

Commit 5e362f5

Browse files
committed
update Makefile
1 parent 3ca151b commit 5e362f5

File tree

1 file changed

+58
-15
lines changed

1 file changed

+58
-15
lines changed

Makefile

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,84 @@
1-
.PHONY: all profile test
1+
# Declare all phony targets (targets that don't create files)
2+
.PHONY: all bench cyclo default demo-colors demo-list demo-progress demo-table fmt help profile test test-race tools vet
23

4+
# ============================================================================
5+
# Main targets
6+
# ============================================================================
7+
8+
## default: Run tests (default target)
39
default: test
410

11+
## all: Run all checks: tests and benchmarks
512
all: test bench
613

7-
tools:
8-
go install github.com/fzipp/gocyclo/cmd/[email protected]
9-
go install github.com/rinchsan/gosimports/cmd/[email protected]
14+
# ============================================================================
15+
# Testing targets
16+
# ============================================================================
1017

18+
## bench: Run benchmark tests with memory profiling
1119
bench:
1220
go test -bench=. -benchmem
1321

22+
## test: Run tests with coverage (runs fmt, vet, and cyclo first)
23+
test: fmt vet cyclo
24+
go test -cover -coverprofile=.coverprofile ./...
25+
26+
## test-race: Run progress demo with race detector
27+
test-race:
28+
go run -race ./cmd/demo-progress/demo.go
29+
30+
# ============================================================================
31+
# Code quality targets
32+
# ============================================================================
33+
34+
## cyclo: Check cyclomatic complexity (warns if complexity > 13)
1435
cyclo:
1536
gocyclo -over 13 ./*/*.go
1637

38+
## fmt: Format code and organize imports
39+
fmt:
40+
go fmt ./...
41+
gosimports -w .
42+
43+
## vet: Run go vet static analysis
44+
vet:
45+
go vet ./...
46+
47+
# ============================================================================
48+
# Demo targets
49+
# ============================================================================
50+
51+
## demo-colors: Run the colors demo
52+
demo-colors:
53+
go run cmd/demo-colors/demo.go
54+
55+
## demo-list: Run the list demo
1756
demo-list:
1857
go run cmd/demo-list/demo.go
1958

59+
## demo-progress: Run the progress demo
2060
demo-progress:
2161
go run cmd/demo-progress/demo.go
2262

63+
## demo-table: Run the table demo
2364
demo-table:
2465
go run cmd/demo-table/demo.go
2566

26-
fmt:
27-
go fmt ./...
28-
gosimports -w .
67+
# ============================================================================
68+
# Utility targets
69+
# ============================================================================
2970

71+
## help: Display help information for all available targets
72+
help:
73+
@echo "\033[1mAvailable targets:\033[0m"
74+
@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)
75+
76+
## profile: Run profiling script
3077
profile:
3178
sh profile.sh
3279

33-
test: fmt vet cyclo
34-
go test -cover -coverprofile=.coverprofile ./...
35-
36-
test-race:
37-
go run -race ./cmd/demo-progress/demo.go
38-
39-
vet:
40-
go vet ./...
80+
## tools: Install required development tools
81+
tools:
82+
go install github.com/fzipp/gocyclo/cmd/[email protected]
83+
go install github.com/rinchsan/gosimports/cmd/[email protected]
4184

0 commit comments

Comments
 (0)