-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (153 loc) · 7.97 KB
/
Makefile
File metadata and controls
190 lines (153 loc) · 7.97 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# ──────────────────────────────────────────────────────────────
# Chronos — Makefile
# ──────────────────────────────────────────────────────────────
# Project metadata
MODULE := github.com/spawn08/chronos
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GO := go
GOFLAGS ?=
CGO_ENABLED ?= 1
# Build flags
LDFLAGS := -s -w \
-X $(MODULE)/cli/cmd.Version=$(VERSION) \
-X $(MODULE)/cli/cmd.Commit=$(COMMIT) \
-X $(MODULE)/cli/cmd.BuildDate=$(BUILD_DATE)
# Output
BIN_DIR := bin
CLI_BIN := $(BIN_DIR)/chronos
# Docker
DOCKER_IMAGE := chronos
DOCKER_TAG ?= $(VERSION)
# ──────────────────────────────────────────────────────────────
# Development
# ──────────────────────────────────────────────────────────────
.PHONY: all
all: fmt vet lint build ## Run fmt, vet, lint, and build
.PHONY: build
build: ## Compile all packages and build the CLI binary
@mkdir -p $(BIN_DIR)
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(CLI_BIN) ./cli/main.go
@echo "Built $(CLI_BIN) ($(VERSION))"
.PHONY: build-all
build-all: ## Compile every package (including examples)
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) ./...
.PHONY: install
install: ## Install the chronos binary to $GOPATH/bin
CGO_ENABLED=$(CGO_ENABLED) $(GO) install $(GOFLAGS) -ldflags '$(LDFLAGS)' ./cli/main.go
.PHONY: run
run: build ## Build and run the CLI
./$(CLI_BIN) $(ARGS)
# ──────────────────────────────────────────────────────────────
# Quality
# ──────────────────────────────────────────────────────────────
.PHONY: fmt
fmt: ## Format all Go source files
$(GO) fmt ./...
.PHONY: vet
vet: ## Run go vet on all packages
$(GO) vet ./...
.PHONY: lint
lint: ## Run golangci-lint (install: https://golangci-lint.run/usage/install/)
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found — skipping (install: https://golangci-lint.run/usage/install/)"; \
fi
.PHONY: test
test: ## Run all tests with race detector
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -race -count=1 -timeout 120s ./...
.PHONY: test-verbose
test-verbose: ## Run all tests with verbose output
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -race -count=1 -timeout 120s -v ./...
.PHONY: test-cover
test-cover: ## Run tests and generate coverage report
@mkdir -p $(BIN_DIR)
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -race -count=1 -timeout 120s -coverprofile=$(BIN_DIR)/coverage.out ./...
$(GO) tool cover -html=$(BIN_DIR)/coverage.out -o $(BIN_DIR)/coverage.html
@echo "Coverage report: $(BIN_DIR)/coverage.html"
.PHONY: bench
bench: ## Run benchmarks
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -bench=. -benchmem -run=^$$ ./...
# ──────────────────────────────────────────────────────────────
# Dependencies
# ──────────────────────────────────────────────────────────────
.PHONY: tidy
tidy: ## Tidy and verify module dependencies
$(GO) mod tidy
$(GO) mod verify
.PHONY: deps
deps: ## Download module dependencies
$(GO) mod download
# ──────────────────────────────────────────────────────────────
# Docker
# ──────────────────────────────────────────────────────────────
.PHONY: docker-build
docker-build: ## Build the Docker image
docker build -f deploy/docker/Dockerfile \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) \
-t $(DOCKER_IMAGE):latest .
.PHONY: docker-push
docker-push: ## Push the Docker image to registry
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
.PHONY: docker-run
docker-run: ## Run the Docker container locally
docker run --rm -p 8420:8420 $(DOCKER_IMAGE):$(DOCKER_TAG)
# ──────────────────────────────────────────────────────────────
# Release
# ──────────────────────────────────────────────────────────────
.PHONY: release-snapshot
release-snapshot: ## Build a release snapshot (requires goreleaser)
@if command -v goreleaser >/dev/null 2>&1; then \
goreleaser release --snapshot --clean; \
else \
echo "goreleaser not found — building manually"; \
$(MAKE) build-cross; \
fi
.PHONY: build-cross
build-cross: ## Cross-compile for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64
@mkdir -p $(BIN_DIR)
@for pair in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do \
os=$${pair%%/*}; arch=$${pair##*/}; \
echo "Building $$os/$$arch..."; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \
$(GO) build -ldflags '$(LDFLAGS)' \
-o $(BIN_DIR)/chronos-$$os-$$arch ./cli/main.go; \
done
@echo "Cross-compilation complete"
# ──────────────────────────────────────────────────────────────
# Examples
# ──────────────────────────────────────────────────────────────
.PHONY: example-quickstart
example-quickstart: ## Run the quickstart example
$(GO) run ./examples/quickstart/main.go
.PHONY: example-multi-agent
example-multi-agent: ## Run the multi-agent example
$(GO) run ./examples/multi_agent/main.go
.PHONY: example-multi-provider
example-multi-provider: ## Run the multi-provider example
$(GO) run ./examples/multi_provider/main.go
# ──────────────────────────────────────────────────────────────
# Clean
# ──────────────────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove build artifacts
rm -rf $(BIN_DIR)
rm -f *.db
$(GO) clean -cache -testcache
# ──────────────────────────────────────────────────────────────
# Help
# ──────────────────────────────────────────────────────────────
.PHONY: help
help: ## Show this help message
@echo "Chronos — AI Agent Framework"
@echo ""
@echo "Usage: make [target]"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help