-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (57 loc) · 1.98 KB
/
Makefile
File metadata and controls
70 lines (57 loc) · 1.98 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
.PHONY: build test clean install lint run help
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
VERSION_NUM := $(shell echo "$(VERSION)" | sed 's/^v//')
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
LDFLAGS := -ldflags "-X main.version=$(VERSION_NUM) -X main.commit=$(COMMIT)"
BINARY := bin/clickspectre
help: ## Show this help message
@echo "ClickSpectre Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building ClickSpectre..."
@go build $(LDFLAGS) -o $(BINARY) ./cmd/clickspectre
@echo "Binary built: $(BINARY)"
test: ## Run tests with race detector
@echo "Running tests..."
@go test -v -race ./...
clean: ## Remove binaries and reports
@echo "Cleaning..."
@rm -rf bin/
@rm -rf report-*/
@echo "Clean complete"
install: ## Install binary to $GOPATH/bin
@echo "Installing ClickSpectre..."
@go install $(LDFLAGS) ./cmd/clickspectre
@echo "Installed to $(shell go env GOPATH)/bin/clickspectre"
lint: ## Run golangci-lint
@echo "Running linters..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Install from: https://golangci-lint.run/usage/install/"; \
fi
run: build ## Build and run with example flags
@echo "Running ClickSpectre (dry-run mode)..."
@$(BINARY) analyze \
--clickhouse-dsn "clickhouse://localhost:9000/default" \
--output ./report \
--lookback 7d \
--dry-run \
--verbose
dev: ## Run without building (for development)
@go run ./cmd/clickspectre $(ARGS)
deps: ## Download dependencies
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
fmt: ## Format code
@echo "Formatting code..."
@go fmt ./...
@go mod tidy
vet: ## Run go vet
@echo "Running go vet..."
@go vet ./...
all: clean deps fmt vet test build ## Run all checks and build