|
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 |
2 | 3 |
|
| 4 | +# ============================================================================ |
| 5 | +# Main targets |
| 6 | +# ============================================================================ |
| 7 | + |
| 8 | +## default: Run tests (default target) |
3 | 9 | default: test |
4 | 10 |
|
| 11 | +## all: Run all checks: tests and benchmarks |
5 | 12 | all: test bench |
6 | 13 |
|
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 | +# ============================================================================ |
10 | 17 |
|
| 18 | +## bench: Run benchmark tests with memory profiling |
11 | 19 | bench: |
12 | 20 | go test -bench=. -benchmem |
13 | 21 |
|
| 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) |
14 | 35 | cyclo: |
15 | 36 | gocyclo -over 13 ./*/*.go |
16 | 37 |
|
| 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 |
17 | 56 | demo-list: |
18 | 57 | go run cmd/demo-list/demo.go |
19 | 58 |
|
| 59 | +## demo-progress: Run the progress demo |
20 | 60 | demo-progress: |
21 | 61 | go run cmd/demo-progress/demo.go |
22 | 62 |
|
| 63 | +## demo-table: Run the table demo |
23 | 64 | demo-table: |
24 | 65 | go run cmd/demo-table/demo.go |
25 | 66 |
|
26 | | -fmt: |
27 | | - go fmt ./... |
28 | | - gosimports -w . |
| 67 | +# ============================================================================ |
| 68 | +# Utility targets |
| 69 | +# ============================================================================ |
29 | 70 |
|
| 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 |
30 | 77 | profile: |
31 | 78 | sh profile.sh |
32 | 79 |
|
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] |
41 | 84 |
|
0 commit comments