-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (115 loc) · 5.23 KB
/
Makefile
File metadata and controls
151 lines (115 loc) · 5.23 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
.PHONY: build clean lint test test-all build-test-runner docker-build docker-build-simple-email docker-build-send-email-link docker-push docker-push-simple-email docker-push-send-email-link
REGISTRY := ghcr.io/constructive-io/constructive-functions
# Detect kind binary (search PATH, fallback to Homebrew)
KIND_BIN := $(shell which kind)
ifeq ($(KIND_BIN),)
KIND_BIN := /opt/homebrew/bin/kind
endif
KIND_CLUSTER_NAME ?= interweb-local
SUBDIRS := functions/hello-world functions/simple-email functions/send-email-link functions/runtime-script
build:
pnpm -r build
clean:
pnpm -r clean
lint:
pnpm -r lint
test:
pnpm -r test
# Docker Build & Push (Restored)
docker-build-runtime:
@echo "Building Shared Node Runtime..."
docker build -t constructive/node-runtime:latest functions/_runtimes/node -f functions/_runtimes/node/Dockerfile.runtime
docker-build: docker-build-runtime
@echo "Building Docker images for functions..."
@for fn in functions/*; do \
if [ -f "$$fn/Dockerfile" ]; then \
echo "Building $$fn..."; \
docker build -t "$(REGISTRY)/$$(basename $$fn):latest" -f "$$fn/Dockerfile" .; \
fi \
done
docker-build-simple-email:
docker build -t $(REGISTRY)/simple-email:latest -f functions/simple-email/Dockerfile .
docker-build-send-email-link:
docker build -t $(REGISTRY)/send-email-link:latest -f functions/send-email-link/Dockerfile .
docker-push:
@echo "Pushing Docker images to $(REGISTRY)..."
@for fn in functions/*; do \
if [ -f "$$fn/Dockerfile" ]; then \
echo "Pushing $$fn..."; \
docker push "$(REGISTRY)/$$(basename $$fn):latest"; \
fi \
done
docker-push-simple-email:
docker push $(REGISTRY)/simple-email:latest
docker-push-send-email-link:
docker push $(REGISTRY)/send-email-link:latest
# Bulk Kind Load
kind-load-all:
@echo "Loading all function images into Kind..."
@for fn in functions/*; do \
if [ -f "$$fn/Dockerfile" ]; then \
echo "Loading $$fn..."; \
$(KIND_BIN) load docker-image "$(REGISTRY)/$$(basename $$fn):latest" --name $(KIND_CLUSTER_NAME); \
fi \
done
# Kubernetes Test Runner
# Run All Tests inside K8s (Centralized Runner)
# Depends on building and loading ALL images to ensure environment is complete.
test-k8s-all: docker-build kind-load-all
@echo "Running all K8s tests via centralized KubernetesJS runner..."
pnpm exec ts-node scripts/test-runner.ts
# Generic target to run specific function test (e.g., make test-k8s-hello-world)
test-k8s-%:
@echo "Running K8s test for function: $*"
pnpm exec ts-node scripts/test-runner.ts --function $*
build-test-runner:
@echo "Building Shared Test Runner Image..."
docker build -f functions/_runtimes/node/Dockerfile.test -t constructive/function-test-runner:v9 .
$(KIND_BIN) load docker-image constructive/function-test-runner:v9 --name $(KIND_CLUSTER_NAME)
rebuild-all-runners: build-test-runner
@echo "All runners rebuilt and loaded into Kind."
# Individual Test Shortcuts
test-k8s-create-db:
pnpm exec ts-node scripts/test-runner.ts --function create-db
test-k8s-crypto-login:
pnpm exec ts-node scripts/test-runner.ts --function crypto-login
test-k8s-github-repo-creator:
pnpm exec ts-node scripts/test-runner.ts --function github-repo-creator
test-k8s-hello-world:
pnpm exec ts-node scripts/test-runner.ts --function hello-world
test-k8s-llm-external:
pnpm exec ts-node scripts/test-runner.ts --function llm-external
test-k8s-llm-internal-calvin:
pnpm exec ts-node scripts/test-runner.ts --function llm-internal-calvin
test-k8s-opencode-headless:
pnpm exec ts-node scripts/test-runner.ts --function opencode-headless
test-k8s-pgpm-dump:
pnpm exec ts-node scripts/test-runner.ts --function pgpm-dump
test-k8s-runtime-script:
pnpm exec ts-node scripts/test-runner.ts --function runtime-script
test-k8s-send-email-link:
pnpm exec ts-node scripts/test-runner.ts --function send-email-link
test-k8s-simple-bash:
pnpm exec ts-node scripts/test-runner.ts --function simple-bash
test-k8s-simple-email:
pnpm exec ts-node scripts/test-runner.ts --function simple-email
test-k8s-stripe-function:
pnpm exec ts-node scripts/test-runner.ts --function stripe-function
test-k8s-twilio-sms:
pnpm exec ts-node scripts/test-runner.ts --function twilio-sms
test-k8s-pytorch-gpu:
docker build -t constructive/pytorch-gpu:latest functions/pytorch-gpu
$(KIND_BIN) load docker-image constructive/pytorch-gpu:latest --name $(KIND_CLUSTER_NAME)
pnpm exec ts-node scripts/test-runner.ts --function pytorch-gpu
test-k8s-rust-hello-world:
docker build -t constructive/rust-hello-world:latest functions/rust-hello-world
$(KIND_BIN) load docker-image constructive/rust-hello-world:latest --name $(KIND_CLUSTER_NAME)
pnpm exec ts-node scripts/test-runner.ts --function rust-hello-world
# Cleanup K8s Resources
k8s-clean:
@echo "Cleaning up K8s jobs for constructive-functions..."
# Delete all jobs matching test-* or *-exec-* pattern (batch delete)
@kubectl get jobs -n default --no-headers -o custom-columns=":metadata.name" | grep -E "^test-|-exec-" | xargs kubectl delete job -n default --ignore-not-found || true
# Delete all pods matching test-* or *-exec-* pattern (orphaned pods) (batch delete)
@kubectl get pods -n default --no-headers -o custom-columns=":metadata.name" | grep -E "^test-|-exec-" | xargs kubectl delete pod -n default --ignore-not-found || true
@echo "Done."