-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (51 loc) · 1.73 KB
/
Makefile
File metadata and controls
65 lines (51 loc) · 1.73 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
.PHONY: all fmt lint test bench cover build examples docs clean help
# Variables
BINARY_NAME=drav
GO=go
GOFLAGS=-v
LDFLAGS=-ldflags "-s -w"
COVERAGE_FILE=coverage.out
COVERAGE_HTML=coverage.html
all: fmt lint test build ## Run all checks and build
fmt: ## Format code
@echo "==> Formatting code..."
@gofmt -s -w .
@$(GO) mod tidy
lint: ## Run linters
@echo "==> Running linters..."
@golangci-lint run ./...
test: ## Run tests
@echo "==> Running tests..."
@$(GO) test $(GOFLAGS) -race -timeout=5m ./...
bench: ## Run benchmarks
@echo "==> Running benchmarks..."
@$(GO) test -bench=. -benchmem -run=^$$ ./...
cover: ## Generate coverage report
@echo "==> Generating coverage report..."
@$(GO) test -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
@$(GO) tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
@echo "Coverage report: $(COVERAGE_HTML)"
build: ## Build CLI binary
@echo "==> Building $(BINARY_NAME)..."
@$(GO) build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/drav
examples: ## Build all examples
@echo "==> Building examples..."
@for dir in examples/*/; do \
echo "Building $$dir..."; \
(cd "$$dir" && $(GO) build -o ../../bin/$$(basename $$dir) .); \
done
docs: ## Build documentation
@echo "==> Building docs..."
@cd docs && mkdocs build
clean: ## Clean build artifacts
@echo "==> Cleaning..."
@rm -rf bin/ dist/ build/
@rm -f $(COVERAGE_FILE) $(COVERAGE_HTML)
@rm -f *.prof *.pprof
@find . -name "*.test" -delete
install: ## Install CLI binary
@echo "==> Installing $(BINARY_NAME)..."
@$(GO) install $(LDFLAGS) ./cmd/drav
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help