-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (75 loc) · 2.24 KB
/
Makefile
File metadata and controls
89 lines (75 loc) · 2.24 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
.PHONY: build clean test run lint lint-golangci format help
# Binary name
BINARY_NAME=don
# Build directory
BUILD_DIR=build
# Go related variables
GOBASE=$(shell pwd)
GOBIN=$(GOBASE)/$(BUILD_DIR)
# Default target
all: build
# Build the application
build:
@echo ">>> Building $(BINARY_NAME)..."
@mkdir -p $(GOBIN)
@go build -o $(GOBIN)/$(BINARY_NAME) .
@echo ">>> ... $(BINARY_NAME) built successfully"
# Clean build artifacts
clean:
@echo ">>> Cleaning..."
@rm -rf $(BUILD_DIR)
# Run tests
test:
@echo ">>> Running tests..."
@go test -v ./...
@echo ">>> ... tests completed successfully"
# Run the exe command tests
test-e2e:
@echo ">>> Running end-to-end tests..."
@if [ ! -x "$(GOBIN)/$(BINARY_NAME)" ]; then \
echo ">>> $(GOBIN)/$(BINARY_NAME) not found. Building..."; \
$(MAKE) build; \
fi
@chmod +x tests/*.sh 2>/dev/null || true
@tests/run_tests.sh
@echo ">>> ... end-to-end tests completed"
# Run the application
run:
@go run main.go
# Install the application
install:
@echo ">>> Installing $(BINARY_NAME)..."
@go install .
@echo ">>> ... $(BINARY_NAME) installed successfully"
# Run linting (golangci-lint)
lint: lint-golangci
# Run golangci-lint (comprehensive linting)
lint-golangci:
@echo ">>> Running golangci-lint..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not found. Installing..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
golangci-lint run; \
fi
@echo ">>> ... golangci-lint completed successfully"
# Format code
format:
@echo ">>> Formatting Go code..."
@go fmt ./...
@go mod tidy
@echo ">>> ... code formatted successfully"
# Show help
help:
@echo "Available targets:"
@echo " build - Build the application"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " test-e2e - Run end-to-end tests"
@echo " run - Run the application"
@echo " install - Install the application"
@echo " lint - Run linting (alias for lint-golangci)"
@echo " lint-golangci - Run golangci-lint (installs if not present)"
@echo " format - Format Go code"
@echo " help - Show this help"