-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (137 loc) · 5.05 KB
/
Makefile
File metadata and controls
167 lines (137 loc) · 5.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
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
.PHONY: all gen build test test-ui test-ui-headed coverage lint vet tidy \
serve-docs serve-tour mcp-tour inspect-tour inspect-tour-sse verify a11y \
work-on-lifecycle work-on-loam work-on-procio work-on-introspection \
work-off-lifecycle work-off-loam work-off-procio work-off-introspection work-off-all
# Go parameters
GOCMD=go
GOMOD=$(GOCMD) mod
GORUN=$(GOCMD) run
GOWORK=$(GOCMD) work
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool
GOINSTALL=$(GOCMD) install
BINARY_NAME=trellis
# --- OS Detection & Command Abstraction ---
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY_NAME).exe
RM := del /F /Q
CURL := curl.exe
# Windows needs backslashes for 'go work edit -dropuse' to match go.work content
DROP_WORK = if exist go.work ( $(GOWORK) edit -dropuse $(subst /,\,$(1)) )
INIT_WORK = if not exist go.work ( echo "Initializing go.work..." & $(GOWORK) init . )
else
BINARY := $(BINARY_NAME)
RM := rm -f
CURL := curl
# Linux/macOS uses forward slashes
DROP_WORK = [ -f go.work ] && $(GOWORK) edit -dropuse $(1)
INIT_WORK = [ -f go.work ] || ( echo "Initializing go.work..." && $(GOWORK) init . )
endif
# Default target
all: gen build
# Generate Go code from OpenAPI spec using oapi-codegen
gen:
go generate ./pkg/adapters/http
# Build the binary for the current platform
build:
@echo "Building for $(GOOS)/$(GOARCH)..."
$(GOBUILD) -v -o $(BINARY_NAME) ./cmd/trellis
# Run all tests
# Note: -race is mandatory for verifying behavioral logic and concurrency safety.
test:
@echo "Running tests..."
$(GOTEST) -race -timeout 90s ./...
# Run UI E2E tests in headless mode (default)
test-ui:
$(GOTEST) -v -timeout 30s ./tests/ui/...
# Run UI E2E tests with a visible browser window (for debugging)
test-ui-headed:
TRELLIS_TEST_HEADLESS=false $(GOTEST) -v -timeout 60s ./tests/ui/...
# Run coverage tests
coverage:
$(GOTEST) -race -timeout 90s -coverprofile="coverage.out" ./...
$(GOTOOL) cover -func="coverage.out"
# Run ineffassign to detect ineffectual assignments
lint:
$(GORUN) github.com/gordonklaus/ineffassign@latest ./...
# Run vet tool in all files
vet:
go vet ./...
# Ensure dependencies are clean
tidy:
$(GOMOD) tidy
# Run local Go documentation server (pkgsite)
serve-docs:
$(GOTOOL) godoc -http=:6060
# Run the Stateless Server in dev mode (requires `tour` example)
serve-tour: gen
$(GORUN) ./cmd/trellis serve --dir ./examples/tour --port 8080
# Run the MCP Server in SSE mode (requires `tour` example)
mcp-tour:
$(GORUN) ./cmd/trellis mcp --dir ./examples/tour --transport sse --port 8080
# Run the MCP Inspector against the Tour example (using Stdio)
inspect-tour:
npx @modelcontextprotocol/inspector $(GORUN) ./cmd/trellis mcp --dir ./examples/tour
# Run the MCP Inspector against a running SSE server (requires 'make mcp-tour' in another terminal)
inspect-tour-sse:
npx @modelcontextprotocol/inspector --server-url http://localhost:8080/sse
# Verify server endpoints (requires server running in another terminal)
verify:
$(CURL) -X POST http://localhost:8080/render -H "Content-Type: application/json" -d "{\"current_node_id\": \"start\"}"
# Run Accessibility Audit (requires pa11y and lighthouse)
a11y:
@chmod +x ./scripts/a11y-audit.sh
./scripts/a11y-audit.sh
# --- Dependency Management (Dev vs Prod) ---
# Helper to get the correct path (uses WORK_PATH if provided, else default)
GET_PATH = $(if $(WORK_PATH),$(WORK_PATH),$(1))
# Enable local development mode for lifecycle
# Usage: make work-on-lifecycle [WORK_PATH=../lifecycle]
work-on-lifecycle:
@echo "Enabling local lifecycle..."
@$(INIT_WORK)
@$(GOWORK) use $(call GET_PATH,../lifecycle)
# Enable local development mode for loam
# Usage: make work-on-loam [WORK_PATH=../loam]
work-on-loam:
@echo "Enabling local loam..."
@$(INIT_WORK)
@$(GOWORK) use $(call GET_PATH,../loam)
# Enable local development mode for procio
# Usage: make work-on-procio [WORK_PATH=../procio]
work-on-procio:
@echo "Enabling local procio..."
@$(INIT_WORK)
@$(GOWORK) use $(call GET_PATH,../procio)
# Enable local development mode for introspection
# Usage: make work-on-introspection [WORK_PATH=../introspection]
work-on-introspection:
@echo "Enabling local introspection..."
@$(INIT_WORK)
@$(GOWORK) use $(call GET_PATH,../introspection)
# Disable local lifecycle
# Usage: make work-off-lifecycle [WORK_PATH=../lifecycle]
work-off-lifecycle:
@echo "Disabling local lifecycle..."
@$(call DROP_WORK,$(call GET_PATH,../lifecycle))
# Disable local loam
# Usage: make work-off-loam [WORK_PATH=../loam]
work-off-loam:
@echo "Disabling local loam..."
@$(call DROP_WORK,$(call GET_PATH,../loam))
# Disable local procio
# Usage: make work-off-procio [WORK_PATH=../procio]
work-off-procio:
@echo "Disabling local procio..."
@$(call DROP_WORK,$(call GET_PATH,../procio))
# Disable local introspection
# Usage: make work-off-introspection [WORK_PATH=../introspection]
work-off-introspection:
@echo "Disabling local introspection..."
@$(call DROP_WORK,$(call GET_PATH,../introspection))
# Disable local development mode by removing go.work (nuclear option)
work-off-all:
@echo "Disabling local workspace mode..."
@$(RM) go.work