-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
195 lines (167 loc) · 8.79 KB
/
Makefile
File metadata and controls
195 lines (167 loc) · 8.79 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
.PHONY: build build-host test test-all clean run-example test-agent help release-build validate-schema test-contract build-agent-bundle build-skills-package validate-skills-package test-run-safety
# Project variables
BINARY_NAME=holon
BIN_DIR=bin
GO_FILES=$(shell find . -type f -name '*.go')
AGENT_DIR=agents/claude
# Version variables (injected via ldflags)
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" 2>/dev/null || echo "unknown")
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.Commit=$(COMMIT) -X main.BuildDate=$(BUILD_DATE)"
# Default target
all: build
## build: Build the holon runner CLI
build: build-host
## build-host: Build runner CLI for current OS/Arch with version info
build-host:
@echo "Building runner CLI (Version: $(VERSION), Commit: $(COMMIT))..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@mkdir -p $(BIN_DIR)
go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) ./cmd/holon
## release-build: Build binaries for multiple platforms
release-build:
@echo "Building release binaries..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@mkdir -p $(BIN_DIR)
@echo "Building for linux/amd64..."
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/holon
@echo "Building for darwin/amd64..."
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/holon
@echo "Building for darwin/arm64..."
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/holon
@echo "Release binaries built successfully"
## test: Run all project tests with structured output
test: test-go
## test-go: Run Go tests with structured output
test-go:
@echo "Running Go tests..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@echo "Checking embedded skills drift..."
@diff -qr --exclude=".git-commit" skills pkg/builtin/skills > /dev/null 2>&1 || (echo "ERROR: Embedded skills (pkg/builtin/skills) differ from source (skills/)"; echo "This means pkg/builtin/skills is not up to date."; echo "Please run 'go generate ./pkg/builtin' to regenerate."; exit 1)
@if command -v gotestfmt > /dev/null 2>&1; then \
go test ./... -json -v 2>&1 | gotestfmt; \
else \
echo "gotestfmt not found, using plain output (install: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest)"; \
go test ./... -v; \
fi
## test-raw: Run Go tests without gotestfmt (plain output)
test-raw:
@echo "Running Go tests with plain output..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@echo "Checking embedded skills drift..."
@diff -qr --exclude=".git-commit" skills pkg/builtin/skills > /dev/null 2>&1 || (echo "ERROR: Embedded skills (pkg/builtin/skills) differ from source (skills/)"; echo "This means pkg/builtin/skills is not up to date."; echo "Please run 'go generate ./pkg/builtin' to regenerate."; exit 1)
go test ./... -v
## test-unit: Run unit tests (non-integration) with structured output
test-unit:
@echo "Running unit tests..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@echo "Checking embedded skills drift..."
@diff -qr --exclude=".git-commit" skills pkg/builtin/skills > /dev/null 2>&1 || (echo "ERROR: Embedded skills (pkg/builtin/skills) differ from source (skills/)"; echo "This means pkg/builtin/skills is not up to date."; echo "Please run 'go generate ./pkg/builtin' to regenerate."; exit 1)
@if command -v gotestfmt > /dev/null 2>&1; then \
go test $$(go list ./... | grep -v '^github.com/holon-run/holon/tests/') -short -json -v 2>&1 | gotestfmt; \
else \
echo "gotestfmt not found, using plain output (install: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest)"; \
go test $$(go list ./... | grep -v '^github.com/holon-run/holon/tests/') -short -v; \
fi
## test-unit-raw: Run unit tests (non-integration) without gotestfmt
test-unit-raw:
@echo "Running unit tests with plain output..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@echo "Checking embedded skills drift..."
@diff -qr --exclude=".git-commit" skills pkg/builtin/skills > /dev/null 2>&1 || (echo "ERROR: Embedded skills (pkg/builtin/skills) differ from source (skills/)"; echo "This means pkg/builtin/skills is not up to date."; echo "Please run 'go generate ./pkg/builtin' to regenerate."; exit 1)
go test $$(go list ./... | grep -v '^github.com/holon-run/holon/tests/') -short -v
## test-agent: Run agent TypeScript tests
test-agent:
@echo "Running TypeScript agent tests..."
cd $(AGENT_DIR) && npm install && npm run build && npm test
## build-agent-bundle: Build agent bundle from repo sources
build-agent-bundle:
@echo "Building agent bundle from repo sources..."
@cd $(AGENT_DIR) && npm ci && npm run bundle
## test-all: Run all project tests (Go + agent)
test-all: test-agent test-go
## validate-schema: Validate JSON schema syntax
validate-schema:
@echo "Validating run manifest JSON schema..."
@which ajv > /dev/null 2>&1 || (echo "ajv not found. Install with: npm install -g ajv-cli" && exit 1)
@ajv compile -s schemas/run.manifest.schema.json
@echo "Schema validation passed"
## test-contract: Run manifest contract tests (backward compatibility)
test-contract:
@echo "Running manifest contract tests..."
@go test ./pkg/api/v1/... -v -run TestHolonManifest
## test-run-safety: Run runtime sandbox safety regression tests
test-run-safety:
@echo "Running runtime sandbox safety tests..."
@echo "Generating builtin skills..."
@go generate ./pkg/builtin
@echo "Checking embedded skills drift..."
@diff -qr --exclude=".git-commit" skills pkg/builtin/skills > /dev/null 2>&1 || (echo "ERROR: Embedded skills (pkg/builtin/skills) differ from source (skills/)"; echo "This means pkg/builtin/skills is not up to date."; echo "Please run 'go generate ./pkg/builtin' to regenerate."; exit 1)
@go test ./pkg/runtime/docker -v -run 'Test(BuildContainerHostConfig|InputMountReadOnly|WorkspaceAndOutputMountsReadWrite|ValidateMountTargets|ValidateRequiredArtifacts|RedactLogs_)'
## install-gotestfmt: Install gotestfmt tool for structured test output
install-gotestfmt:
@echo "Installing gotestfmt..."
@go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
@echo "gotestfmt installed successfully"
## clean: Remove build artifacts
clean:
@echo "Cleaning up..."
rm -rf $(BIN_DIR)
rm -rf holon-output*
rm -rf _testwork
rm -rf $(AGENT_DIR)/dist
## test-integration: Run integration tests with structured output (requires Docker)
test-integration: build build-agent-bundle
@echo "Running integration tests..."
@if command -v gotestfmt > /dev/null 2>&1; then \
go test ./tests/integration/... -json -v 2>&1 | gotestfmt; \
else \
echo "gotestfmt not found, using plain output (install: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest)"; \
go test ./tests/integration/... -v; \
fi
## test-integration-raw: Run integration tests without gotestfmt (plain output)
test-integration-raw: build build-agent-bundle
@echo "Running integration tests with plain output..."
go test ./tests/integration/... -v
## test-integration-artifacts: Run integration tests and capture artifacts on failure
test-integration-artifacts: build build-agent-bundle
@echo "Running integration tests with artifact capture..."
@mkdir -p _testwork
@go test ./tests/integration/... -v -work
## test-serve-tui-smoke: Run serve TUI/RPC smoke tests
test-serve-tui-smoke:
@echo "Running serve TUI/RPC smoke tests..."
go test ./pkg/tui -run '^TestTUISmoke_' -v
## run-example: Run the fix-bug example (requires ANTHROPIC_API_KEY)
run-example: build
@echo "Running fix-bug example..."
cd agents/claude && npm install && npm run build
./$(BIN_DIR)/$(BINARY_NAME) run --spec examples/fix-bug.yaml --image golang:1.22 --workspace . --output ./holon-output-fix --runtime-mode dev --runtime-dev-agent-source ./agents/claude
## help: Display help information
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^##' Makefile | sed -e 's/## //'
## build-skills-package: Build skill package for distribution
build-skills-package:
@echo "Building skill package..."
@./scripts/build-skills-package.sh
## build-skills-package-release: Build skill package for release (uses git tag)
build-skills-package-release:
@echo "Building skill package for release..."
@VERSION=$$(git describe --tags --exact-match 2>/dev/null || echo "v0.0.0-dev") \
./scripts/build-skills-package.sh
## validate-skills-package: Validate skill package format
validate-skills-package:
@echo "Validating skill package schema..."
@which ajv > /dev/null 2>&1 || (echo "ajv not found. Install with: npm install -g ajv-cli" && exit 1)
@ajv compile -s schemas/skill-package.schema.json
@echo "Skill package schema validation passed"