-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (73 loc) · 2.73 KB
/
Copy pathMakefile
File metadata and controls
91 lines (73 loc) · 2.73 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
.PHONY: help build test clean install lint fmt vet coverage run
# Variables
BINARY_NAME=gong
BUILD_DIR=bin
CMD_DIR=cmd/gong
GO=go
GOFLAGS=-v
LDFLAGS=-ldflags "-s -w"
# Colors for output
GREEN=\033[0;32m
NC=\033[0m # No Color
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " ${GREEN}%-15s${NC} %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the binary
@echo "Building ${BINARY_NAME}..."
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
build-all: ## Build for all platforms
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./$(CMD_DIR)
GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR)
GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./$(CMD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR)
@echo "Build complete for all platforms"
test: ## Run tests
@echo "Running tests..."
$(GO) test -v -race -coverprofile=coverage.out ./...
coverage: test ## Run tests with coverage report
@echo "Generating coverage report..."
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
bench: ## Run benchmarks
@echo "Running benchmarks..."
$(GO) test -bench=. -benchmem ./...
lint: ## Run linter (requires golangci-lint)
@echo "Running linter..."
@which golangci-lint > /dev/null || (echo "golangci-lint not found. Install from https://golangci-lint.run/usage/install/" && exit 1)
golangci-lint run ./...
fmt: ## Format code
@echo "Formatting code..."
$(GO) fmt ./...
@echo "Formatting complete"
vet: ## Run go vet
@echo "Running go vet..."
$(GO) vet ./...
tidy: ## Tidy go modules
@echo "Tidying go modules..."
$(GO) mod tidy
@echo "Tidy complete"
clean: ## Clean build artifacts
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@echo "Clean complete"
install: build ## Install the binary to GOPATH/bin
@echo "Installing ${BINARY_NAME}..."
$(GO) install ./$(CMD_DIR)
@echo "Install complete"
run: build ## Build and run the binary
@$(BUILD_DIR)/$(BINARY_NAME)
deps: ## Download dependencies
@echo "Downloading dependencies..."
$(GO) mod download
@echo "Dependencies downloaded"
verify: fmt vet lint test ## Run all checks (format, vet, lint, test)
@echo "All checks passed!"
.DEFAULT_GOAL := help