-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (88 loc) · 3.4 KB
/
Copy pathMakefile
File metadata and controls
106 lines (88 loc) · 3.4 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
.PHONY: build run test clean install-deps help check-metrics test-load
BINARY_NAME=golem
BUILD_DIR=./bin
CMD_DIR=cmd/golem
CONFIG_FILE=config.json
build:
@echo "Building $(BINARY_NAME)..."
go build -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR)/main.go
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
run: build
@echo "Starting $(BINARY_NAME)..."
$(BUILD_DIR)/$(BINARY_NAME)
test:
@echo "Running tests..."
go test -v ./...
test-coverage:
@echo "Running tests with coverage..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
clean:
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f coverage.out coverage.html
rm -rf testing/results/*
@echo "Clean complete"
install-deps:
@echo "Installing dependencies..."
go mod download
go mod tidy
@echo "Dependencies installed"
check-metrics:
@echo "Checking metrics endpoint..."
@curl -s http://localhost:8000/metrics | grep golem_ || echo "GOLEM not running or metrics not available"
check-file-metrics:
@echo "Checking file-specific metrics..."
@curl -s http://localhost:8000/metrics | grep golem_file || echo "File metrics not found"
fmt:
@echo "Formatting code..."
go fmt ./...
@echo "Format complete"
vet:
@echo "Running go vet..."
go vet ./...
@echo "Vet complete"
lint: fmt vet
dev: build
@echo "Starting in development mode..."
./$(BINARY_NAME) -port 8000
setup-testing:
@echo "Setting up testing infrastructure..."
mkdir -p testing/results
mkdir -p test-files
@echo "Creating test files..."
dd if=/dev/zero of=test-files/1mb.bin bs=1M count=1 2>/dev/null || true
dd if=/dev/zero of=test-files/10mb.bin bs=1M count=10 2>/dev/null || true
dd if=/dev/zero of=test-files/100mb.bin bs=1M count=100 2>/dev/null || true
@echo "Testing setup complete"
test-load:
@echo "Running load test (requires wrk)..."
@command -v wrk >/dev/null 2>&1 || { echo "wrk not installed. Install: sudo apt install wrk"; exit 1; }
@[ -f testing/simple-test.lua ] || { echo "testing/simple-test.lua not found"; exit 1; }
wrk -t2 -c10 -d30s -s testing/simple-test.lua http://localhost:8000
install-tools:
@echo "Checking and installing required tools..."
@command -v wrk >/dev/null 2>&1 || echo "wrk not found. Install: sudo apt install wrk"
@command -v jq >/dev/null 2>&1 || echo "jq not found. Install: sudo apt install jq"
@command -v python3 >/dev/null 2>&1 || echo "python3 not found. Install: sudo apt install python3"
all: clean lint test build
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " run - Build and run"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage report"
@echo " clean - Remove binary and test results"
@echo " install-deps - Download Go dependencies"
@echo " check-metrics - Check if metrics endpoint is working"
@echo " check-file-metrics - Check file-specific metrics"
@echo " fmt - Format code"
@echo " vet - Run go vet"
@echo " lint - Run fmt and vet"
@echo " dev - Run in development mode"
@echo " setup-testing - Create testing infrastructure"
@echo " test-load - Run load test with wrk"
@echo " install-tools - Check for required tools"
@echo " all - Clean, lint, test, and build"
@echo " help - Show this help message"