-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (107 loc) · 3.58 KB
/
Makefile
File metadata and controls
129 lines (107 loc) · 3.58 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
.PHONY: build install test clean
# Build configuration
BINARY_NAME=presto
BUILD_DIR=bin
INSTALL_PATH=/usr/local/bin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Build the binary
build:
@echo "🎵 Building Presto..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v ./cmd/presto
@echo "✅ Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
# Install dependencies
deps:
@echo "📦 Installing dependencies..."
$(GOGET) github.com/spf13/cobra@latest
$(GOGET) github.com/Masterminds/semver/v3@latest
$(GOGET) github.com/schollz/progressbar/v3@latest
$(GOMOD) tidy
@echo "✅ Dependencies installed"
# Install the binary
install: build
@echo "📥 Installing Presto to $(INSTALL_PATH)..."
@sudo cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_PATH)/
@sudo chmod +x $(INSTALL_PATH)/$(BINARY_NAME)
@echo "✅ Presto installed successfully!"
@echo "Run 'presto --version' to verify"
# Run tests
test:
@echo "🧪 Running tests..."
$(GOTEST) -v ./...
# Run tests with coverage
coverage:
@echo "📊 Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "✅ Coverage report: coverage.html"
# Run benchmarks
benchmark:
@echo "⚡ Running benchmarks..."
@./scripts/benchmark.sh
# Clean build artifacts
clean:
@echo "🧹 Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -rf vendor
@rm -f coverage.out coverage.html
@echo "✅ Clean complete"
# Build for all platforms
build-all:
@echo "🎵 Building for all platforms..."
@mkdir -p $(BUILD_DIR)
@echo "Building for macOS (amd64)..."
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/presto
@echo "Building for macOS (arm64)..."
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/presto
@echo "Building for Linux (amd64)..."
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/presto
@echo "Building for Linux (arm64)..."
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/presto
@echo "Building for Windows (amd64)..."
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/presto
@echo "✅ All builds complete!"
# Run the binary
run: build
./$(BUILD_DIR)/$(BINARY_NAME)
# Development mode - build and run
dev:
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/presto && ./$(BUILD_DIR)/$(BINARY_NAME)
# Format code
fmt:
@echo "🎨 Formatting code..."
@go fmt ./...
@echo "✅ Format complete"
# Lint code
lint:
@echo "🔍 Linting code..."
@golangci-lint run
@echo "✅ Lint complete"
# Release (create tag and push)
release:
@echo "🚀 Creating release..."
@read -p "Enter version (e.g., v0.1.0): " version; \
git tag -a $$version -m "Release $$version"; \
git push origin $$version
@echo "✅ Release created! GitHub Actions will build binaries."
# Show help
help:
@echo "Presto Makefile Commands:"
@echo " make build - Build the binary"
@echo " make deps - Install dependencies"
@echo " make install - Install Presto to system"
@echo " make test - Run tests"
@echo " make coverage - Run tests with coverage"
@echo " make benchmark - Run performance benchmarks"
@echo " make clean - Clean build artifacts"
@echo " make build-all - Build for all platforms"
@echo " make run - Build and run"
@echo " make dev - Development mode"
@echo " make fmt - Format code"
@echo " make lint - Lint code"
@echo " make release - Create a new release"