-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (77 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
95 lines (77 loc) · 2.46 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
# Name of the binary
BINARY := vectorsync
.PHONY: help all build run dev test format lint fix clean docker-build docker-up docker-down proto migrate-up install-tools
# Show this help message
help:
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
# Run all checks and build
all: format lint test build
# Build the binary
build:
@echo "Building Vectorsync for production..."
@go build -o bin/vectorsync ./cmd/vector-sync/main.go
# Run the server in production
run: build
@./bin/vectorsync
# Run the server in development mode with air
dev:
@air
# Run tests
test:
go test -v ./...
# Format code with goimports (excluding generated files)
format:
@echo "Formatting code..."
@find . -name '*.go' -not -path './api/proto/v1/generated/*' -not -path './vendor/*' | xargs goimports -w
@echo "Done!"
# Run golangci-lint
lint:
@echo "Running linters..."
golangci-lint run
@echo "Done!"
# Auto-fix linting issues
fix:
golangci-lint run --fix
# Clean build artifacts
clean:
rm -rf bin/
go clean
# Build Docker image
docker-build:
docker compose build
# Start Docker container
docker-up:
docker compose up
# Stop Docker container
docker-down:
docker compose down
# Generate protobuf code along with grpc gateway
proto:
@mkdir -p api/proto/v1/generated
@protoc -I api/proto/v1 \
-I api/proto/third_party \
--go_out=api/proto/v1/generated \
--go_opt=paths=source_relative \
--go-grpc_out=api/proto/v1/generated \
--go-grpc_opt=paths=source_relative \
--grpc-gateway_out=api/proto/v1/generated \
--grpc-gateway_opt=paths=source_relative \
api/proto/v1/*.proto
# Run database migrations
migrate-up:
psql $$DB_URL -f migrations/001_enable_pgvector.up.sql
psql $$DB_URL -f migrations/002_create_collections.up.sql
psql $$DB_URL -f migrations/003_create_documents.up.sql
psql $$DB_URL -f migrations/004_add_distance_metric.up.sql
psql $$DB_URL -f migrations/005_fix_fts_index_size.up.sql
psql $$DB_URL -f migrations/006_add_collection_embedding_config.up.sql
# Install development tools
install-tools:
@echo "Installing goimports..."
go install golang.org/x/tools/cmd/goimports@latest
@echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
@echo "Installing air for hot reload..."
go install github.com/air-verse/air@latest
@echo "Done! Tools installed."