-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
242 lines (196 loc) · 7.39 KB
/
Copy pathMakefile
File metadata and controls
242 lines (196 loc) · 7.39 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# =============================================================================
# Orc Makefile
# =============================================================================
#
# Quick Start (new users):
# curl -fsSL https://raw.githubusercontent.com/randalmurphal/orc/main/install.sh | sh
#
# Development:
# make setup # First-time setup (creates go.work for local deps)
# make build # Build binary locally
# make test # Run tests
# make dev-full # Start API + frontend dev servers
#
# Container Commands:
# make docker-build # Build all Docker images
# make docker-test # Run tests in container
# make docker-shell # Interactive shell in dev container
#
# =============================================================================
.PHONY: all setup build test lint doc-lint clean dev docker-build docker-test docker-shell proto help
# Configuration
BINARY := orc
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_DIR := bin
GO_FILES := $(shell find . -name '*.go' -not -path './vendor/*')
# Build flags
LDFLAGS := -ldflags="-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT)"
# Container runtime (supports docker, nerdctl, podman)
CONTAINER_RT ?= $(shell command -v nerdctl 2>/dev/null || command -v docker 2>/dev/null || echo "docker")
COMPOSE := $(CONTAINER_RT) compose
# Default target
all: build
# =============================================================================
# Setup
# =============================================================================
## setup: First-time project setup (for contributors with local deps)
setup:
@echo "==> Creating go.work for local development..."
@if [ ! -f go.work ]; then \
echo "go 1.24.0\n\nuse .\nuse ../llmkit\nuse ../flowgraph" > go.work; \
echo "Created go.work"; \
else \
echo "go.work already exists"; \
fi
@echo "==> Installing frontend dependencies..."
cd web && bun install
@echo "==> Setup complete!"
@echo ""
@echo "For development, run: make dev-full"
## deps: Download dependencies
deps:
go mod download
go mod tidy
## proto: Regenerate protobuf code (Go + TypeScript)
proto:
cd proto && buf generate
# =============================================================================
# Development (Native)
# =============================================================================
## build: Build the binary locally (with embedded frontend)
build: web-build embed-frontend
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) ./cmd/orc
## build-cli: Build CLI only (no frontend)
build-cli: $(BUILD_DIR)/$(BINARY)
$(BUILD_DIR)/$(BINARY): $(GO_FILES)
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 go build $(LDFLAGS) -o $@ ./cmd/orc
## embed-frontend: Copy frontend build to embed directory
embed-frontend:
@echo "==> Embedding frontend..."
@rm -rf internal/api/static
@cp -r web/build internal/api/static
@touch internal/api/static/.gitkeep
@echo " Frontend embedded to internal/api/static/"
## test: Run tests locally
test:
@mkdir -p internal/api/static
@test -f internal/api/static/.gitkeep || touch internal/api/static/.gitkeep
GOWORK=off go test -v -race -cover ./...
## test-short: Run tests without race detector (faster)
test-short:
@mkdir -p internal/api/static
@test -f internal/api/static/.gitkeep || touch internal/api/static/.gitkeep
GOWORK=off go test -v -cover ./...
## lint: Run linters locally
lint:
golangci-lint run ./...
## doc-lint: Check CLAUDE.md files against line thresholds
doc-lint:
@./scripts/doc-lint.sh
## vet: Run go vet
vet:
go vet ./...
## fmt: Format code
fmt:
go fmt ./...
goimports -w .
## clean: Remove build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -f coverage.out
## run: Build and run with arguments
run: build
./$(BUILD_DIR)/$(BINARY) $(ARGS)
## install: Install binary to GOPATH/bin
install:
go install $(LDFLAGS) ./cmd/orc
# =============================================================================
# Development (Container)
# =============================================================================
## docker-build: Build all Docker images
docker-build:
$(COMPOSE) build
## docker-shell: Interactive development shell
docker-shell:
$(COMPOSE) run --rm dev
## dev: Alias for docker-shell
dev: docker-shell
## docker-test: Run tests in container
docker-test:
$(COMPOSE) run --rm test
## docker-lint: Run linter in container
docker-lint:
$(COMPOSE) run --rm lint
## docker-clean: Remove containers and volumes
docker-clean:
$(COMPOSE) down -v --remove-orphans
$(CONTAINER_RT) image rm -f orc-dev orc-builder orc 2>/dev/null || true
# =============================================================================
# Release
# =============================================================================
## release-build: Build release binary in container
release-build:
@mkdir -p $(BUILD_DIR)
VERSION=$(VERSION) COMMIT=$(COMMIT) $(COMPOSE) run --rm build
## release-linux: Cross-compile for Linux
release-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY)-linux-amd64 ./cmd/orc
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY)-linux-arm64 ./cmd/orc
## release-darwin: Cross-compile for macOS
release-darwin:
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY)-darwin-amd64 ./cmd/orc
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY)-darwin-arm64 ./cmd/orc
# =============================================================================
# Frontend (React)
# =============================================================================
## web-install: Install frontend dependencies
web-install:
cd web && bun install
## web-dev: Start frontend dev server (proxies to :8080)
web-dev:
cd web && bun run dev
## web-build: Build frontend for production
web-build:
cd web && bun run build
## web-test: Run frontend tests (vitest unit tests)
web-test:
cd web && bun run test
## serve: Start API server (for frontend development)
serve: build
./$(BUILD_DIR)/$(BINARY) serve
## dev-full: Start both API server and frontend dev server
dev-full:
@echo "Starting API server on :8080 and frontend on :5173..."
@echo "API: http://localhost:8080"
@echo "UI: http://localhost:5173"
@$(MAKE) serve & cd web && bun run dev
# =============================================================================
# Coverage
# =============================================================================
## coverage: Generate test coverage report
coverage:
@mkdir -p internal/api/static
@test -f internal/api/static/.gitkeep || touch internal/api/static/.gitkeep
GOWORK=off go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## coverage-func: Show coverage by function
coverage-func:
@mkdir -p internal/api/static
@test -f internal/api/static/.gitkeep || touch internal/api/static/.gitkeep
GOWORK=off go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
# =============================================================================
# Help
# =============================================================================
## help: Show this help
help:
@echo "Orc - Claude Code Task Orchestrator"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'