-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (103 loc) · 4.16 KB
/
Makefile
File metadata and controls
136 lines (103 loc) · 4.16 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
127
128
129
130
131
132
133
134
135
136
.PHONY: all build test test-verbose coverage clean fmt vet lint help bench bench-long perftest perftest-sizes perftest-large indexperf indexperf-large protocolperf protocolperf-quick
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
GOVET=$(GOCMD) vet
# Binary name
BINARY_NAME=spocp
COVERAGE_FILE=coverage.out
COVERAGE_HTML=coverage.html
# Binary output directory
BIN_DIR=bin
# Server binaries
SERVER_BINARY=$(BIN_DIR)/spocpd
CLIENT_BINARY=$(BIN_DIR)/spocp-client
# Packages
PACKAGES=$(shell $(GOCMD) list ./...)
all: test build ## Run tests and build
build: ## Build the library (verify it compiles)
@echo "Building..."
$(GOBUILD) -v ./...
build-server: ## Build spocpd server binary to bin/
@echo "Building spocpd server..."
@mkdir -p $(BIN_DIR)
$(GOBUILD) -o $(SERVER_BINARY) ./cmd/spocpd
build-client: ## Build spocp-client binary to bin/
@echo "Building spocp-client..."
@mkdir -p $(BIN_DIR)
$(GOBUILD) -o $(CLIENT_BINARY) ./cmd/spocp-client
build-tools: build-server build-client ## Build all server tools to bin/
test: ## Run tests
@echo "Running tests..."
$(GOTEST) -v -race ./...
test-short: ## Run tests in short mode
@echo "Running tests (short mode)..."
$(GOTEST) -short ./...
test-verbose: ## Run tests with verbose output
@echo "Running tests (verbose)..."
$(GOTEST) -v -race -count=1 ./...
coverage: ## Generate test coverage report
@echo "Generating coverage report..."
$(GOTEST) -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GOCMD) tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
@echo "Coverage report generated: $(COVERAGE_HTML)"
coverage-cli: ## Show test coverage in terminal
@echo "Generating coverage report..."
$(GOTEST) -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
$(GOCMD) tool cover -func=$(COVERAGE_FILE)
clean: ## Remove build artifacts, coverage reports, and log files
@echo "Cleaning..."
$(GOCLEAN)
rm -f $(COVERAGE_FILE) $(COVERAGE_HTML)
rm -rf bin/
rm -f *.log
fmt: ## Format code
@echo "Formatting code..."
$(GOFMT) ./...
vet: ## Run go vet
@echo "Running go vet..."
$(GOVET) ./...
lint: fmt vet ## Run all linters
tidy: ## Tidy go modules
@echo "Tidying go modules..."
$(GOMOD) tidy
check: fmt vet test ## Format, vet, and test
bench: ## Run benchmarks
@echo "Running benchmarks..."
$(GOTEST) -bench=. -benchmem ./...
bench-long: ## Run benchmarks with longer duration
@echo "Running benchmarks (longer)..."
$(GOTEST) -bench=. -benchmem -benchtime=10s ./...
perftest: ## Run performance testing tool (1000 rules, 10000 queries)
@echo "Running performance test..."
$(GOCMD) run cmd/perftest/main.go -rules 1000 -queries 10000
perftest-sizes: ## Run performance tests across multiple ruleset sizes
@echo "Running performance test (multiple sizes)..."
$(GOCMD) run cmd/perftest/main.go -sizes -queries 5000
perftest-large: ## Run performance test with large ruleset (50k rules)
@echo "Running performance test (large)..."
$(GOCMD) run cmd/perftest/main.go -rules 50000 -queries 1000
indexperf: ## Compare indexed vs non-indexed performance (10k rules)
@echo "Running index performance comparison..."
$(GOCMD) run cmd/indexperf/main.go -rules 10000 -queries 10000 -stats
indexperf-large: ## Compare indexed vs non-indexed with large ruleset (50k rules)
@echo "Running index performance comparison (large)..."
$(GOCMD) run cmd/indexperf/main.go -rules 50000 -queries 5000 -tags 20 -stats
protocolperf: ## Compare Direct vs TCP vs HTTP/AuthZen performance
@echo "Running protocol performance comparison..."
$(GOCMD) run cmd/protocolperf/main.go -rules 1000 -queries 10000
protocolperf-concurrent: ## Compare protocols with concurrent clients
@echo "Running protocol performance comparison (concurrent)..."
$(GOCMD) run cmd/protocolperf/main.go -rules 1000 -queries 10000 -concurrent 4
deps: ## Download dependencies
@echo "Downloading dependencies..."
$(GOMOD) download
verify: ## Verify dependencies
@echo "Verifying dependencies..."
$(GOMOD) verify
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'