forked from AlexsJones/sympozium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (123 loc) · 5.29 KB
/
Makefile
File metadata and controls
174 lines (123 loc) · 5.29 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
# Sympozium Makefile
# Kubernetes-native agent orchestration platform
# Image registry — matches ghcr.io/<owner>/<repo>/<image>
REGISTRY ?= ghcr.io/alexsjones/sympozium
TAG ?= latest
# Tool versions
CONTROLLER_GEN_VERSION ?= v0.17.2
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GOVET = $(GOCMD) vet
GOMOD = $(GOCMD) mod
# Local tool binaries
LOCALBIN ?= $(shell pwd)/bin
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
# Binary output directory
BIN_DIR = bin
# All binaries
BINARIES = controller apiserver ipc-bridge webhook agent-runner sympozium
# All channel binaries
CHANNELS = telegram whatsapp discord slack
# All images
IMAGES = controller apiserver ipc-bridge webhook agent-runner \
channel-telegram channel-whatsapp channel-discord channel-slack \
skill-k8s-ops
.PHONY: all build test clean generate manifests docker-build docker-push install help
all: build
##@ General
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
build: $(addprefix build-,$(BINARIES)) $(addprefix build-channel-,$(CHANNELS)) ## Build all binaries
build-%: ## Build a specific binary (e.g., make build-controller)
$(GOBUILD) -o $(BIN_DIR)/$* ./cmd/$*/
build-channel-%: ## Build a specific channel binary
$(GOBUILD) -o $(BIN_DIR)/channel-$* ./channels/$*/
test: ## Run tests
$(GOTEST) -race -coverprofile=coverage.out ./...
test-short: ## Run short tests
$(GOTEST) -short ./...
test-integration: ## Run integration tests (requires Kind cluster + API keys)
./test/integration/test-write-file.sh
./test/integration/test-anthropic-write-file.sh
./test/integration/test-k8s-ops-nodes.sh
./test/integration/test-telegram-channel.sh
./test/integration/test-slack-channel.sh
vet: ## Run go vet
$(GOVET) ./...
lint: ## Run golangci-lint
golangci-lint run ./...
fmt: ## Run gofmt
gofmt -s -w .
tidy: ## Run go mod tidy
$(GOMOD) tidy
##@ Code Generation
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Install controller-gen locally
$(CONTROLLER_GEN):
@mkdir -p $(LOCALBIN)
GOBIN=$(LOCALBIN) $(GOCMD) install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
generate: controller-gen ## Generate code (deepcopy, CRD manifests)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
$(CONTROLLER_GEN) rbac:roleName=sympozium-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@$(MAKE) helm-sync
manifests: controller-gen ## Generate CRD manifests
$(CONTROLLER_GEN) crd paths="./api/..." output:crd:artifacts:config=config/crd/bases
@$(MAKE) helm-sync
##@ Docker
docker-build: $(addprefix docker-build-,$(IMAGES)) ## Build all Docker images
docker-build-%: ## Build a specific Docker image
docker build --build-arg IMAGE_TAG=$(TAG) -t $(REGISTRY)/$*:$(TAG) -f images/$*/Dockerfile .
docker-push: $(addprefix docker-push-,$(IMAGES)) ## Push all Docker images
docker-push-%: ## Push a specific Docker image
docker push $(REGISTRY)/$*:$(TAG)
KIND_CLUSTER ?= kind
kind-load: $(addprefix kind-load-,$(IMAGES)) ## Load all Docker images into Kind
kind-load-%: ## Load a specific image into Kind (e.g., make kind-load-controller)
kind load docker-image $(REGISTRY)/$*:$(TAG) --name $(KIND_CLUSTER)
kind-reload: docker-build kind-load ## Build all images and load into Kind
kubectl rollout restart deployment sympozium-controller-manager -n sympozium-system
set-images: ## Stamp REGISTRY/TAG into K8s manifests
cd config/manager && kustomize edit set image \
controller=$(REGISTRY)/controller:$(TAG) \
apiserver=$(REGISTRY)/apiserver:$(TAG)
cd config/webhook && kustomize edit set image \
webhook=$(REGISTRY)/webhook:$(TAG)
@echo "Images set to $(REGISTRY)/*:$(TAG)"
##@ Deployment
install: manifests ## Install CRDs, skills, personas, and policies into the K8s cluster
kubectl apply -f config/crd/bases/
kubectl create namespace sympozium-system --dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f config/skills/
kubectl apply -f config/personas/
kubectl apply -f config/policies/
uninstall: ## Uninstall CRDs from the K8s cluster
kubectl delete -f config/crd/bases/
deploy: manifests ## Deploy controller to the K8s cluster
kubectl apply -k config/
undeploy: ## Undeploy controller from the K8s cluster
kubectl delete -k config/
deploy-samples: ## Deploy sample CRs
kubectl apply -f config/samples/
##@ Database
db-migrate: ## Run database migrations
@echo "Running migrations against $${DATABASE_URL}"
psql "$${DATABASE_URL}" -f migrations/001_initial.sql
##@ Helm
helm-sync: ## Sync CRDs and appVersion into the Helm chart
@echo "Syncing CRDs to charts/sympozium/crds/..."
@mkdir -p charts/sympozium/crds
cp config/crd/bases/*.yaml charts/sympozium/crds/
@echo "Done."
helm-sync-check: ## Check that Helm chart CRDs are in sync (CI use)
@diff -qr config/crd/bases/ charts/sympozium/crds/ > /dev/null 2>&1 \
|| (echo "ERROR: Helm chart CRDs are out of sync. Run 'make helm-sync'" && exit 1)
@echo "Helm chart CRDs are in sync."
helm-lint: ## Lint the Helm chart
helm lint charts/sympozium/
##@ Clean
clean: ## Remove build artifacts
rm -rf $(BIN_DIR)
rm -f coverage.out