-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (94 loc) · 3.1 KB
/
Copy pathMakefile
File metadata and controls
109 lines (94 loc) · 3.1 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
.PHONY: build run install clean test test-verbose test-coverage test-short test-integration test-smoke help tidy
# Build configuration
BINARY_NAME=homestead
BUILD_DIR=.
CMD_DIR=./cmd/homestead
COVERAGE_FILE=coverage.out
# Build the application
build:
@echo "🔨 Building $(BINARY_NAME)..."
go build -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR)
@echo "✅ Build complete: ./$(BINARY_NAME)"
# Run the application
run:
@echo "🚀 Running $(BINARY_NAME)..."
go run $(CMD_DIR)
# Install to $GOPATH/bin
install:
@echo "📦 Installing $(BINARY_NAME)..."
go install $(CMD_DIR)
@echo "✅ Installed to $(shell go env GOPATH)/bin/$(BINARY_NAME)"
# Clean build artifacts
clean:
@echo "🧹 Cleaning..."
rm -f $(BUILD_DIR)/$(BINARY_NAME)
rm -f $(COVERAGE_FILE)
go clean
@echo "✅ Clean complete"
# Run tests
test:
@echo "🧪 Running tests..."
go test ./...
# Run tests with verbose output
test-verbose:
@echo "🧪 Running tests (verbose)..."
go test -v ./...
# Run tests with coverage
test-coverage:
@echo "🧪 Running tests with coverage..."
go test -coverprofile=$(COVERAGE_FILE) ./...
go tool cover -func=$(COVERAGE_FILE)
@echo ""
@echo "📊 Coverage report saved to $(COVERAGE_FILE)"
@echo "🌐 To view HTML report, run: go tool cover -html=$(COVERAGE_FILE)"
# Run only short/unit tests (skip integration)
test-short:
@echo "🧪 Running short tests..."
go test -short ./...
# Run only integration tests
test-integration:
@echo "🧪 Running integration tests..."
go test -v -run Integration ./...
# Black-box smoke: build binary and run -version (skipped with -short)
test-smoke:
@echo "🧪 Running smoke tests..."
go test -v -count=1 -run TestSmoke_ .
# Run tests and open coverage in browser
test-coverage-html: test-coverage
@echo "🌐 Opening coverage report in browser..."
go tool cover -html=$(COVERAGE_FILE)
# Benchmark tests
benchmark:
@echo "⚡ Running benchmarks..."
go test -bench=. -benchmem ./...
# Download and tidy dependencies
tidy:
@echo "📚 Tidying dependencies..."
go mod tidy
go mod verify
@echo "✅ Dependencies updated"
# Show help
help:
@echo "Homestead - Makefile commands:"
@echo ""
@echo "Build & Run:"
@echo " make build - Build the binary"
@echo " make run - Run the application"
@echo " make install - Install to GOPATH/bin"
@echo " make clean - Remove build artifacts"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests"
@echo " make test-verbose - Run tests with verbose output"
@echo " make test-coverage - Run tests with coverage report"
@echo " make test-coverage-html - Run tests and open coverage in browser"
@echo " make test-short - Run only unit tests (skip integration and smoke)"
@echo " make test-integration - Run only integration tests"
@echo " make test-smoke - Build CLI and verify -version (E2E-style smoke)"
@echo " make benchmark - Run benchmark tests"
@echo ""
@echo "Dependencies:"
@echo " make tidy - Update and verify dependencies"
@echo ""
@echo "Help:"
@echo " make help - Show this help"