-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (113 loc) · 4.15 KB
/
Copy pathMakefile
File metadata and controls
131 lines (113 loc) · 4.15 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
130
131
.PHONY: build run clean install test lint fmt help release
BINARY_NAME=vex
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "2.0.2")
BUILD_DIR=dist
GO_FILES=$(shell find . -name '*.go' -type f)
# Build the application
build:
@echo "Building $(BINARY_NAME) v$(VERSION)..."
@go build -ldflags="-s -w -X main.version=$(VERSION)" -o $(BINARY_NAME) .
@echo "Build complete!"
# Build optimized release binary
build-release:
@echo "Building optimized release..."
@go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BINARY_NAME) .
@echo "Release build complete!"
# Run with sample data
run: build
@./$(BINARY_NAME) sample_data.csv
# Run tests
test:
@echo "Running tests..."
@go test -v -race -cover ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
@go test -race -coverprofile=coverage.out -covermode=atomic ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Format code
fmt:
@echo "Formatting code..."
@go fmt ./...
@echo "Code formatted!"
# Lint code
lint:
@echo "Linting code..."
@golangci-lint run --enable-all --disable exhaustruct,exhaustivestruct,gochecknoglobals,gochecknoinits
@echo "Linting complete!"
# Install dependencies
deps:
@echo "Installing dependencies..."
@go mod download
@go mod tidy
@echo "Dependencies installed!"
# Clean build artifacts
clean:
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@go clean
@echo "Cleaned!"
# Install globally
install: build-release
@echo "Installing $(BINARY_NAME)..."
@go install
@echo "Installed! Run '$(BINARY_NAME)' from anywhere"
# Create release builds for all platforms
release: clean
@echo "Creating release builds v$(VERSION)..."
@mkdir -p $(BUILD_DIR)
@GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 .
@GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 .
@GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 .
@GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 .
@GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=$(VERSION)" -trimpath -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe .
@cd $(BUILD_DIR) && sha256sum * > checksums.txt
@echo "Release builds created in $(BUILD_DIR)/"
# Tag and push a new release — triggers GitHub Actions to build + publish
# Usage: make tag VER=v2.1.0
tag:
@if [ -z "$(VER)" ]; then echo "Usage: make tag VER=v2.1.0"; exit 1; fi
git tag -a $(VER) -m "Release $(VER)"
git push origin $(VER)
@echo "✓ Tag $(VER) pushed — GitHub Actions will build and publish automatically."
# Build a local snapshot with goreleaser (no publish)
snapshot:
goreleaser release --snapshot --clean
# Security audit
audit:
@echo "Running security audit..."
@go list -json -m all | nancy sleuth
@echo "Security audit complete!"
# Benchmarks
bench:
@echo "Running benchmarks..."
@go test -bench=. -benchmem ./...
# Show help
help:
@echo "Excel TUI v$(VERSION) - Makefile Help"
@echo ""
@echo "Available targets:"
@echo " build - Build the application"
@echo " build-release - Build optimized release binary"
@echo " run - Build and run with sample data"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage report"
@echo " fmt - Format code"
@echo " lint - Lint code (requires golangci-lint)"
@echo " deps - Install dependencies"
@echo " clean - Remove build artifacts"
@echo " install - Install globally"
@echo " release - Create release builds for all platforms"
@echo " audit - Run security audit (requires nancy)"
@echo " bench - Run benchmarks"
@echo " help - Show this help"
@echo ""
@echo "Examples:"
@echo " make build"
@echo " make test"
@echo " make release"
# Default target
.DEFAULT_GOAL := help