-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (95 loc) · 4.72 KB
/
Copy pathMakefile
File metadata and controls
118 lines (95 loc) · 4.72 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
.PHONY: help build test clean run lint coverage bench bench-ci openapi openapi-check fmt vet deps update-deps install dev
BINARY_NAME=modbridge
VERSION?=$(shell cat version.txt 2>/dev/null || echo "1.0.17")
LDFLAGS=-ldflags "-s -w -X main.Version=$(VERSION)"
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: build-frontend ## Build the application
@echo "Building $(BINARY_NAME)..."
go build $(LDFLAGS) -o $(BINARY_NAME) .
build-frontend: ## Build the frontend
@echo "Building frontend..."
cd frontend && npm install
cd frontend && npm run build
rm -rf pkg/web/dist
cp -r frontend/dist pkg/web/dist
@echo "Frontend built and copied to pkg/web/dist"
build-all: ## Build for all platforms
@echo "Building for all platforms..."
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./main.go
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-arm64 ./main.go
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-windows-amd64.exe ./main.go
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-amd64 ./main.go
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-arm64 ./main.go
test: ## Run tests
@echo "Running tests..."
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}{{.ImportPath}}{{end}}' ./... | xargs go test -v -race -coverprofile=coverage.txt -covermode=atomic
bench: ## Run performance benchmarks
@echo "Running benchmarks..."
go test -run '^$$' -bench 'BenchmarkProxy(Connection|Request|Concurrent)$$' -benchmem ./pkg/testing/performance
bench-ci: ## Run benchmark regression guardrails for CI
@echo "Running benchmark guardrails..."
./scripts/ci/check_bench.sh
openapi: ## Generate OpenAPI spec file
@echo "Generating docs/openapi.json..."
go run ./cmd/openapi > docs/openapi.json
openapi-check: ## Verify generated OpenAPI spec matches committed file
@echo "Checking OpenAPI spec consistency..."
go run ./cmd/openapi > docs/openapi.generated.json
python -m json.tool docs/openapi.generated.json > /dev/null
diff -u docs/openapi.json docs/openapi.generated.json
rm -f docs/openapi.generated.json
coverage: test ## Generate coverage report
@echo "Generating coverage report..."
go tool cover -html=coverage.txt -o coverage.html
@echo "Coverage report generated: coverage.html"
lint: ## Run linter
@echo "Running linter..."
@which golangci-lint > /dev/null || (echo "golangci-lint not installed. Install from https://golangci-lint.run/usage/install/" && exit 1)
golangci-lint run --timeout=5m
fmt: ## Format code
@echo "Formatting code..."
go fmt ./...
gofmt -s -w .
vet: ## Run go vet
@echo "Running go vet..."
go vet ./...
clean: ## Clean build artifacts
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f coverage.txt coverage.html
rm -rf bin/
rm -rf frontend/dist
rm -rf pkg/web/dist
rm -f *.log
run: build ## Build and run the application
@echo "Running $(BINARY_NAME)..."
./$(BINARY_NAME)
deps: ## Download dependencies
@echo "Downloading dependencies..."
go mod download
go mod tidy
update-deps: ## Update dependencies
@echo "Updating dependencies..."
go get -u ./...
go mod tidy
install: build ## Install the binary
@echo "Installing $(BINARY_NAME)..."
go install $(LDFLAGS) ./main.go
dev: ## Run in development mode with live reload (requires air)
@which air > /dev/null || (echo "air not installed. Install with: go install github.com/cosmtrek/air@latest" && exit 1)
air
build-headless: ## Build headless variant (no web UI, no auth, config-file only)
@echo "Building headless variant..."
go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o modbridge-headless ./cmd/modbridge-headless/
build-headless-all: ## Build headless for all platforms
@echo "Building headless for all platforms..."
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o bin/modbridge-headless-linux-amd64 ./cmd/modbridge-headless/
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o bin/modbridge-headless-linux-arm64 ./cmd/modbridge-headless/
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o bin/modbridge-headless-windows-amd64.exe ./cmd/modbridge-headless/
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o bin/modbridge-headless-darwin-amd64 ./cmd/modbridge-headless/
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.Version=$(VERSION)-headless" -trimpath -o bin/modbridge-headless-darwin-arm64 ./cmd/modbridge-headless/
.DEFAULT_GOAL := help