-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (74 loc) · 2.13 KB
/
Copy pathMakefile
File metadata and controls
86 lines (74 loc) · 2.13 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
.PHONY: help test build install clean fmt vet ci quick-check
# Binary name and install location
BINARY_NAME := gt-telegram
BUILD_DIR := bin
INSTALL_DIR := $(HOME)/.local/bin
VERSION := 0.3.1
# Default target
help:
@echo "Available targets:"
@echo ""
@echo "Development:"
@echo " make build - Build binary"
@echo " make install - Build and install to ~/.local/bin"
@echo " make fmt - Format Go code"
@echo " make vet - Run go vet"
@echo " make clean - Remove build artifacts"
@echo " make tidy - Tidy dependencies"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests"
@echo " make test-race - Run tests with race detector"
@echo ""
@echo "Quality:"
@echo " make quick-check - Fast pre-commit checks (fmt, vet, test, build)"
@echo " make ci - Full CI checks locally"
@echo ""
# Build binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
go build -ldflags="-X main.Version=$(VERSION) -X main.Build=$$(git rev-parse --short HEAD)" -o $(BUILD_DIR)/$(BINARY_NAME) .
ifeq ($(shell uname),Darwin)
@codesign -s - -f $(BUILD_DIR)/$(BINARY_NAME) 2>/dev/null || true
@echo "Signed $(BINARY_NAME) for macOS"
endif
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
# Install binary to ~/.local/bin
install: build
@mkdir -p $(INSTALL_DIR)
@rm -f $(INSTALL_DIR)/$(BINARY_NAME)
@cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
@echo "Installed $(BINARY_NAME) to $(INSTALL_DIR)/$(BINARY_NAME)"
# Run all tests
test:
@echo "Running tests..."
go test ./... -v
# Run tests with race detector
test-race:
@echo "Running tests with race detector..."
go test ./... -v -race
# Format Go code
fmt:
@echo "Formatting Go code..."
gofmt -s -w -e .
# Run go vet
vet:
@echo "Running go vet..."
go vet ./...
# Tidy dependencies
tidy:
@echo "Tidying dependencies..."
go mod tidy
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -rf $(BUILD_DIR)/
rm -rf dist/
go clean
# Quick pre-commit checks
quick-check: fmt vet test build
@echo "Quick checks passed"
# Full CI checks locally
ci: fmt vet test-race build
@echo "CI checks passed"