-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (62 loc) · 2.01 KB
/
Makefile
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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GORUN=$(GOCMD) run
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
BINARY_NAME=blastra
MAIN_PATH=./main.go
# Build flags
LDFLAGS=-ldflags "-s -w"
.PHONY: all build clean test coverage run deps lint help
all: clean build test ## Build and run tests
build: ## Build the binary
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_PATH)
clean: ## Remove build artifacts
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f coverage.out
test: ## Run tests
$(GOTEST) -v ./...
coverage: ## Run tests with coverage
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
coverage-func: ## Show test coverage by function
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -func=coverage.out
run: ## Run the application
$(GORUN) $(MAIN_PATH)
deps: ## Download dependencies
$(GOMOD) download
$(GOMOD) tidy
lint: ## Run linters
@if command -v golangci-lint >/dev/null; then \
golangci-lint run ./...; \
else \
echo "golangci-lint is not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
exit 1; \
fi
watch: ## Run the application with hot reload (requires air)
@if command -v air >/dev/null; then \
air; \
else \
echo "air is not installed. Run: go install github.com/air-verse/air@latest"; \
exit 1; \
fi
bench: ## Run benchmarks
$(GOTEST) -bench=. -benchmem ./...
docker-build: ## Build docker image
docker build -t $(BINARY_NAME) .
docker-run: ## Run docker container
docker run -p 8080:8080 $(BINARY_NAME)
# Development tools installation
tools: ## Install development tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/cosmtrek/air@latest
# Help target
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# Default target
.DEFAULT_GOAL := help