-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (143 loc) · 6.04 KB
/
Makefile
File metadata and controls
176 lines (143 loc) · 6.04 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
# Makefile for flow
BINARY_NAME=flow
BIN_DIR=bin
VERSION_PKG=github.com/grovetools/core/version
# --- Versioning ---
# For dev builds, we construct a version string from git info.
# For release builds, VERSION is passed in by the CI/CD pipeline (e.g., VERSION=v1.2.3)
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
GIT_DIRTY ?= $(shell test -n "`git status --porcelain`" && echo "-dirty")
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# If VERSION is not set, default to a dev version string
VERSION ?= $(GIT_BRANCH)-$(GIT_COMMIT)$(GIT_DIRTY)
# Build tags: fts5 enables SQLite FTS5 in mattn/go-sqlite3 (required by memory package)
GO_TAGS = -tags "fts5"
# Go LDFLAGS to inject version info at compile time
LDFLAGS = -ldflags="\
-X '$(VERSION_PKG).Version=$(VERSION)' \
-X '$(VERSION_PKG).Commit=$(GIT_COMMIT)' \
-X '$(VERSION_PKG).Branch=$(GIT_BRANCH)' \
-X '$(VERSION_PKG).BuildDate=$(BUILD_DATE)'"
.PHONY: all build test clean fmt fmt-check vet lint run check generate-docs dev build-all schema help
all: build
schema:
@echo "Generating JSON schema..."
@go generate ./cmd
@echo "Regenerating docs JSON..."
# @docgen regen-json
build: schema
@mkdir -p $(BIN_DIR)
@echo "Building $(BINARY_NAME) version $(VERSION)..."
@go build $(GO_TAGS) $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) .
test:
@echo "Running tests..."
@go test $(GO_TAGS) -v ./...
# --- Grove-tend E2E Testing ---
# Mocks are built automatically by tend from tests/e2e/tend/mocks/src/
test-e2e: build
@echo "Running grove-tend E2E tests..."
@tend run -p $(ARGS)
clean:
@echo "Cleaning..."
@go clean
@rm -rf $(BIN_DIR)
@rm -f $(BINARY_NAME)
@rm -f coverage.out
fmt:
@echo "Formatting code..."
@gofumpt -w .
fmt-check:
@unformatted="$$(gofumpt -l . 2>/dev/null)"; \
if [ -n "$$unformatted" ]; then \
echo "Unformatted files (run 'make fmt'):"; \
echo "$$unformatted" | sed 's/^/ /'; \
exit 1; \
fi
vet:
@echo "Running go vet..."
@go vet ./...
lint:
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
# Run the CLI
run: build
@$(BIN_DIR)/$(BINARY_NAME) $(ARGS)
# Run all checks
check: schema fmt-check vet lint test
# Development build with race detector
dev:
@mkdir -p $(BIN_DIR)
@echo "Building $(BINARY_NAME) version $(VERSION) with race detector..."
@go build -race $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) .
# Cross-compilation targets
PLATFORMS ?= darwin/amd64 darwin/arm64 linux/amd64 linux/arm64
DIST_DIR ?= dist
build-all:
@echo "Building for multiple platforms into $(DIST_DIR)..."
@mkdir -p $(DIST_DIR)
@for platform in $(PLATFORMS); do \
os=$$(echo $$platform | cut -d'/' -f1); \
arch=$$(echo $$platform | cut -d'/' -f2); \
output_name="$(BINARY_NAME)-$${os}-$${arch}"; \
echo " -> Building $${output_name} version $(VERSION)"; \
GOOS=$$os GOARCH=$$arch go build $(LDFLAGS) -o $(DIST_DIR)/$${output_name} .; \
done
# Interactive e2e tests
test-orchestration-interactive: build
@echo "Running orchestration tests in interactive mode..."
@cd tests/e2e/orchestration-tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd ../../.. && pwd)/bin/flow ./test-orchestration-e2e.sh
test-reference-prompts-interactive: build
@echo "Running reference prompts tests in interactive mode..."
@cd tests/e2e/orchestration-tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd ../../.. && pwd)/bin/flow ./test-reference-prompts-e2e.sh
test-chat-interactive: build
@echo "Running chat functionality tests in interactive mode..."
@cd tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-chat-functionality.sh
# Test individual e2e test files
test-chat-run: build
@echo "Running chat run command tests..."
@cd tests && FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-chat-run.sh
test-chat-run-interactive: build
@echo "Running chat run command tests in interactive mode..."
@cd tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-chat-run.sh
test-chat-title-filtering: build
@echo "Running chat title filtering tests..."
@cd tests && FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-chat-title-filtering.sh
test-chat-title-filtering-interactive: build
@echo "Running chat title filtering tests in interactive mode..."
@cd tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-chat-title-filtering.sh
test-launch: build
@echo "Running launch feature tests..."
@cd tests && FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-launch.sh
test-launch-interactive: build
@echo "Running launch feature tests in interactive mode..."
@cd tests && GROVE_TEST_STEP_THROUGH=true FLOW_CMD=$$(cd .. && pwd)/bin/flow ./e2e/test-launch-feature.sh
# Show available targets
help:
@echo "Available targets:"
@echo " make build - Build the binary"
@echo " make test - Run tests"
@echo " make test-e2e - Run end-to-end tests"
@echo " make clean - Clean build artifacts"
@echo " make fmt - Format code"
@echo " make vet - Run go vet"
@echo " make lint - Run linter"
@echo " make run ARGS=.. - Run the CLI with arguments"
@echo " make check - Run all checks"
@echo " make dev - Build with race detector"
@echo " make help - Show this help"
@echo ""
@echo "Interactive test targets:"
@echo " make test-orchestration-interactive - Run orchestration tests interactively"
@echo " make test-reference-prompts-interactive - Run reference prompts tests interactively"
@echo " make test-chat-interactive - Run chat tests interactively"
@echo ""
@echo "Individual test targets:"
@echo " make test-chat-run - Run chat run command tests only"
@echo " make test-chat-run-interactive - Run chat run tests in interactive mode"
@echo " make test-launch - Run launch feature tests only"
@echo " make test-launch-interactive - Run launch tests in interactive mode"