-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (48 loc) · 1.79 KB
/
Makefile
File metadata and controls
65 lines (48 loc) · 1.79 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
APP_NAME=Job-Queue
BIN_DIR=bin
MAIN_PATH=./cmd/server
# Build variables
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}"
.PHONY: help build run test clean tidy fmt lint docker-build docker-run
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## Build the application
@echo "Building $(APP_NAME)..."
@mkdir -p $(BIN_DIR)
go build $(LDFLAGS) -o $(BIN_DIR)/$(APP_NAME) $(MAIN_PATH)
run: ## Run the application
go run $(MAIN_PATH)
test: ## Run tests
go test -v ./...
test-coverage: ## Run tests with coverage
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
clean: ## Clean build artifacts
rm -rf $(BIN_DIR)
rm -f coverage.out coverage.html
tidy: ## Tidy Go modules
go mod tidy
go mod verify
fmt: ## Format Go code
go fmt ./...
lint: ## Lint Go code
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not found. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
install-tools: ## Install development tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/cosmtrek/air@latest
bazel-build: ## Build with Bazel
bazel build //...
bazel-test: ## Test with Bazel
bazel test //...
bazel-run: ## Run server with Bazel
bazel run //cmd/server:server
setup: tidy install-tools ## Setup development environment
@echo "Development environment setup complete!"