-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (99 loc) · 4.51 KB
/
Copy pathMakefile
File metadata and controls
136 lines (99 loc) · 4.51 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
.PHONY: build build-server build-panda build-proxy install install-server install-panda install-proxy test lint clean docker docker-push docker-sandbox test-sandbox run studio help setup-hooks govulncheck generate
# Build variables
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS := -s -w \
-X github.com/ethpandaops/panda/internal/version.Version=$(VERSION) \
-X github.com/ethpandaops/panda/internal/version.GitCommit=$(GIT_COMMIT) \
-X github.com/ethpandaops/panda/internal/version.BuildTime=$(BUILD_TIME)
# Docker variables
DOCKER_IMAGE ?= ethpandaops/panda
DOCKER_TAG ?= $(VERSION)
# Go variables
GOBIN ?= $(shell go env GOPATH)/bin
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: build-server build-panda ## Build primary binaries (panda-server + panda)
build-server: ## Build the server binary
go build -ldflags "$(LDFLAGS)" -o panda-server ./cmd/server
build-panda: ## Build the CLI binary
go build -ldflags "$(LDFLAGS)" -o panda ./cmd/panda
build-proxy: ## Build the standalone proxy binary
go build -ldflags "$(LDFLAGS)" -o panda-proxy ./cmd/proxy
build-linux: ## Build for Linux (amd64)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o panda-server-linux-amd64 ./cmd/server
test: ## Run tests
go test -race -v ./...
test-coverage: ## Run tests with coverage
go test -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -html=coverage.out -o coverage.html
lint: ## Run linters
@which golangci-lint > /dev/null || (echo "Installing golangci-lint v2..." && go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest)
golangci-lint run ./...
./scripts/lint-structure.sh
lint-fix: ## Run linters and fix issues
golangci-lint run --fix ./...
fmt: ## Format code
go fmt ./...
gofmt -s -w .
vet: ## Run go vet
go vet ./...
govulncheck: ## Scan for reachable vulnerabilities (allowlist in scripts/govulncheck.sh)
./scripts/govulncheck.sh
tidy: ## Run go mod tidy
go mod tidy
generate: ## Run code generation (oapi-codegen for the compute API client)
go generate ./pkg/compute/...
clean: ## Clean build artifacts
rm -f panda-server .panda-server-bin panda panda-proxy panda-server-linux-amd64
rm -f coverage.out coverage.html
docker: ## Build Docker image
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_TIME=$(BUILD_TIME) \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) \
-t $(DOCKER_IMAGE):latest \
.
docker-push: docker ## Push Docker image
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
docker-sandbox: ## Build sandbox Docker image
docker build -t ethpandaops-panda-sandbox:latest -f sandbox/Dockerfile .
sandbox-hash: ## Print the content hash of the sandbox image build inputs
@./scripts/sandbox-hash.sh
docker-sandbox-tagged: ## Build sandbox image tagged with its content hash (+ latest)
docker build \
-t ethpandaops-panda-sandbox:$(shell ./scripts/sandbox-hash.sh) \
-t ethpandaops-panda-sandbox:latest \
-f sandbox/Dockerfile .
test-sandbox: ## Run sandbox package tests
go test -race -v ./pkg/sandbox/...
run: build-server ## Run the server
./panda-server serve
studio: ## Run panda case studio (eval-case minting + codex fix dispatch UI)
cd tests/eval && uv sync --group studio -q && uv run --group studio python -m studio
run-docker: docker ## Run with docker compose
docker compose up -d
stop-docker: ## Stop docker compose services
docker compose down
logs: ## View docker compose logs
docker compose logs -f panda-server
install: install-server install-panda ## Install primary binaries to GOBIN
install-server: ## Install the server binary to GOBIN
@mkdir -p $(GOBIN)
go build -ldflags "$(LDFLAGS)" -o $(GOBIN)/panda-server ./cmd/server
install-panda: ## Install the CLI binary to GOBIN
@mkdir -p $(GOBIN)
go build -ldflags "$(LDFLAGS)" -o $(GOBIN)/panda ./cmd/panda
install-proxy: ## Install the standalone proxy binary to GOBIN
@mkdir -p $(GOBIN)
go build -ldflags "$(LDFLAGS)" -o $(GOBIN)/panda-proxy ./cmd/proxy
setup-hooks: ## Install git pre-commit hooks
git config core.hooksPath .githooks
@echo "Git hooks configured to use .githooks/"
version: ## Show version info
@echo "Version: $(VERSION)"
@echo "Git Commit: $(GIT_COMMIT)"
@echo "Build Time: $(BUILD_TIME)"