-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (70 loc) · 2.52 KB
/
Copy pathMakefile
File metadata and controls
82 lines (70 loc) · 2.52 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
.PHONY: help build test clean install run lint fmt coverage
BINARY_NAME=cortex
VERSION?=dev
BUILD_DIR=dist
GO_FILES=$(shell find . -name '*.go' -type f)
help:
@echo "🧠 Cortex - Available Commands"
@echo ""
@echo "Development:"
@echo " make build Build binary"
@echo " make test Run tests"
@echo " make run Run without building"
@echo " make fmt Format code"
@echo " make lint Run linters"
@echo ""
@echo "Deployment:"
@echo " make install Install to system"
@echo " make release Build all platforms"
@echo ""
@echo "Cleanup:"
@echo " make clean Remove build artifacts"
@echo ""
build:
@echo "🔨 Building $(BINARY_NAME)..."
@go build -ldflags="-X main.version=$(VERSION)" -o $(BINARY_NAME) cmd/cortex/main.go
@echo "✅ Binary created: ./$(BINARY_NAME)"
test:
@echo "🧪 Running tests..."
@go test -v -race -coverprofile=coverage.txt ./...
@echo "✅ Tests complete"
coverage: test
@echo "📊 Generating coverage report..."
@go tool cover -html=coverage.txt -o coverage.html
@echo "✅ Open coverage.html in browser"
run:
@go run cmd/cortex/main.go
install: build
@echo "📦 Installing $(BINARY_NAME)..."
@sudo mv $(BINARY_NAME) /usr/local/bin/
@echo "✅ Installed to /usr/local/bin/$(BINARY_NAME)"
@echo " Run 'cortex --help' from anywhere"
clean:
@echo "🧹 Cleaning..."
@rm -f $(BINARY_NAME)
@rm -f coverage.txt coverage.html
@rm -rf $(BUILD_DIR)
@go clean -testcache
@echo "✅ Clean complete"
fmt:
@echo "✨ Formatting code..."
@go fmt ./...
@echo "✅ Code formatted"
lint:
@echo "🔍 Running linters..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run ./...; \
else \
echo "⚠️ golangci-lint not installed"; \
echo " Install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
release:
@echo "📦 Building releases..."
@mkdir -p $(BUILD_DIR)
@GOOS=linux GOARCH=amd64 go build -ldflags="-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 cmd/cortex/main.go
@GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 cmd/cortex/main.go
@GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 cmd/cortex/main.go
@GOOS=windows GOARCH=amd64 go build -ldflags="-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe cmd/cortex/main.go
@echo "✅ Releases built in $(BUILD_DIR)/"
@ls -lh $(BUILD_DIR)/
.DEFAULT_GOAL := help