-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (87 loc) · 4.05 KB
/
Makefile
File metadata and controls
111 lines (87 loc) · 4.05 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
.PHONY: all build cli build-products build-all test clean run dev check lint
VERSION ?= dev
all: build
# Build the unified binary
build:
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard ./cmd/stockyard
@echo "Built dist/stockyard ($(VERSION))"
# Build the open-source proxy
proxy:
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard-proxy ./cmd/stockyard-proxy
@echo "Built dist/stockyard-proxy ($(VERSION))"
# Build the CLI tool
cli:
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/sy ./cmd/sy
@echo "Built dist/sy ($(VERSION))"
# Sub-products
PRODUCTS = bid doubt echo fault fossil grain hollow iron morph prism replay seance spine stampede tide trailhead verdikt relic breed fossilrec phantom feral tidepool crucible cortex mycelium spore molt
# Build all binaries (unified + proxy + tools + CLI + products)
build-all: build proxy cli build-products
CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/sy-api ./cmd/sy-api
CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/sy-keygen ./cmd/sy-keygen
@echo "Built all binaries in dist/"
# Build all sub-product binaries
build-products:
@for p in $(PRODUCTS); do \
CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/$$p ./cmd/$$p && echo " $$p: ok" || echo " $$p: FAILED"; \
done
@echo "Built $(words $(PRODUCTS)) product binaries"
test:
go test ./... -count=1 -race -timeout 120s
test-v:
go test ./... -count=1 -v -timeout 120s
cover:
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
lint:
go vet ./...
@echo "No issues"
clean:
rm -rf dist/ coverage.out
# Run locally
run:
go run ./cmd/stockyard
dev:
STOCKYARD_ADMIN_KEY=dev go run ./cmd/stockyard
# Verify it compiles
check:
CGO_ENABLED=0 go build -o /dev/null ./cmd/stockyard && echo "stockyard: ok"
CGO_ENABLED=0 go build -o /dev/null ./cmd/stockyard-proxy && echo "stockyard-proxy: ok"
CGO_ENABLED=0 go build -o /dev/null ./cmd/sy-api && echo "sy-api: ok"
# Cross-compile for releases
release-build:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard_linux_amd64 ./cmd/stockyard
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard_linux_arm64 ./cmd/stockyard
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard_darwin_amd64 ./cmd/stockyard
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard_darwin_arm64 ./cmd/stockyard
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard-proxy_linux_amd64 ./cmd/stockyard-proxy
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard-proxy_linux_arm64 ./cmd/stockyard-proxy
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard-proxy_darwin_amd64 ./cmd/stockyard-proxy
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION)" -o dist/stockyard-proxy_darwin_arm64 ./cmd/stockyard-proxy
@echo "Built 8 release binaries in dist/"
# Docker
docker:
docker build -t stockyard:$(VERSION) .
docker tag stockyard:$(VERSION) stockyard:latest
# Benchmarks
bench:
go test ./internal/proxy/ -bench=. -benchmem -count=3 -timeout 120s
bench-short:
go test ./internal/proxy/ -bench=. -benchmem -count=1 -timeout 60s
# Doctor (run health check)
doctor: build
./dist/stockyard doctor
# Sync site/ to internal/site/static/
site-sync:
@find site -name "*.html" -o -name "*.xml" -o -name "*.sh" -o -name "*.txt" -o -name "*.json" -o -name "*.sig" | while read f; do \
dest="internal/site/static/$${f#site/}"; \
mkdir -p "$$(dirname "$$dest")"; \
cp "$$f" "$$dest"; \
done
@echo "Synced site/ → internal/site/static/"
# Full check before pushing
pre-push: lint test bench-short
@echo "All checks passed"
# Integration smoke test (builds binary, boots server, hits all endpoints)
smoke:
bash test/smoke_test.sh