-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (82 loc) · 3.67 KB
/
Makefile
File metadata and controls
111 lines (82 loc) · 3.67 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
BINARY := distill
GO := go
GOFLAGS :=
LDFLAGS := -s -w
BUILD_DIR := .
.DEFAULT_GOAL := build
# ── Build ─────────────────────────────────────────────────────────────────────
.PHONY: build
build: ## Build the distill binary
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) .
.PHONY: install
install: ## Install distill to $GOPATH/bin
$(GO) install $(GOFLAGS) -ldflags "$(LDFLAGS)" .
.PHONY: clean
clean: ## Remove build artifacts
rm -f $(BUILD_DIR)/$(BINARY)
# ── Test ──────────────────────────────────────────────────────────────────────
.PHONY: test
test: ## Run all tests
$(GO) test ./...
.PHONY: test-verbose
test-verbose: ## Run all tests with verbose output
$(GO) test -v ./...
.PHONY: test-race
test-race: ## Run tests with race detector
$(GO) test -race ./...
.PHONY: test-cover
test-cover: ## Run tests and show coverage
$(GO) test -coverprofile=coverage.out ./...
$(GO) tool cover -func=coverage.out
rm -f coverage.out
.PHONY: bench
bench: ## Run benchmarks
$(GO) test -bench=. -benchmem ./...
# ── Code quality ──────────────────────────────────────────────────────────────
.PHONY: fmt
fmt: ## Format all Go source files
$(GO) fmt ./...
.PHONY: vet
vet: ## Run go vet
$(GO) vet ./...
.PHONY: lint
lint: ## Run golangci-lint (requires golangci-lint in PATH)
golangci-lint run ./...
.PHONY: check
check: fmt vet test ## Run fmt, vet, and test
# ── Docker ────────────────────────────────────────────────────────────────────
.PHONY: docker-build
docker-build: ## Build the Docker image
docker build -t $(BINARY):latest .
.PHONY: docker-run
docker-run: ## Run the Docker container (API mode, port 8080)
docker run --rm -p 8080:8080 \
-e OPENAI_API_KEY="$$OPENAI_API_KEY" \
$(BINARY):latest api
# ── Release ───────────────────────────────────────────────────────────────────
.PHONY: release-dry
release-dry: ## Dry-run goreleaser (snapshot, no publish)
goreleaser release --snapshot --clean
.PHONY: release
release: ## Run goreleaser (requires GITHUB_TOKEN)
goreleaser release --clean
# ── Dev helpers ───────────────────────────────────────────────────────────────
.PHONY: config-init
config-init: build ## Generate a default distill.yaml
./$(BINARY) config init
.PHONY: run-api
run-api: build ## Start the API server on :8080
./$(BINARY) api
.PHONY: run-serve
run-serve: build ## Start the serve command
./$(BINARY) serve
.PHONY: deps
deps: ## Download and tidy Go modules
$(GO) mod download
$(GO) mod tidy
# ── Help ──────────────────────────────────────────────────────────────────────
.PHONY: help
help: ## List all available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' \
| sort