-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (37 loc) · 2 KB
/
Makefile
File metadata and controls
52 lines (37 loc) · 2 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
BINARY := logtap
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
.PHONY: all build build-forwarder test test-integration test-e2e bench lint fmt clean deps install coverage help
all: deps fmt lint test build ## Run deps, fmt, lint, test, and build
build: ## Build logtap binary
go build $(LDFLAGS) -o bin/$(BINARY) ./cmd/logtap
build-forwarder: ## Build logtap-forwarder binary (CGO_ENABLED=0)
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/logtap-forwarder ./cmd/logtap-forwarder
test: ## Run tests with race detection and coverage
go test -race -cover ./...
test-integration: ## Run integration tests (requires Kind cluster + KUBECONFIG)
LOGTAP_INTEGRATION=1 go test -race -v -timeout 10m ./internal/k8s/ -run TestIntegration
test-e2e: ## Run E2E tests (requires Kind cluster + loaded images)
LOGTAP_E2E=1 LOGTAP_FORWARDER_IMAGE=logtap-forwarder:e2e LOGTAP_RECEIVER_IMAGE=logtap-receiver:e2e \
go test -race -v -timeout 10m ./internal/k8s/ -run TestE2E
bench: ## Run benchmarks with memory stats
go test -bench=. -benchmem -run=^$$ ./internal/...
lint: ## Run golangci-lint
golangci-lint run ./...
fmt: ## Format code with gofmt and goimports
gofmt -w .
goimports -w .
deps: ## Download module dependencies
go mod download
install: build ## Build and install to GOPATH/bin
cp bin/$(BINARY) $(shell go env GOPATH)/bin/$(BINARY)
coverage: ## Generate HTML coverage report and open in browser
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
open coverage.html
clean: ## Remove build artifacts and coverage files
rm -rf bin/ coverage.out coverage.html
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'