-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (100 loc) · 3.94 KB
/
Makefile
File metadata and controls
133 lines (100 loc) · 3.94 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
milvus-url = milvus-standalone.orb.local:19530
# ================================
# Build
# ================================
# Recursively find all Go files in cmd and its subfolders
GO_FILES := $(shell find cmd -name '*.go')
# Extract unique directory names from GO_FILES
CMD_DIRS := $(sort $(dir $(GO_FILES)))
# Add these variables at the top of the Makefile
GOBUILD=go build -v
GOBUILD_FLAGS=-ldflags="-s -w" -buildmode=pie
# Build all executables in the cmd folder and its subfolders
build:
@for dir in $(CMD_DIRS); do \
app_name=$$(echo $$dir | sed 's|cmd/||g' | sed 's|/$$||' | tr '/' '_'); \
echo "Building $$app_name..."; \
$(GOBUILD) $(GOBUILD_FLAGS) -o bin/$$app_name ./$$dir; \
done
# ================================
# Examples
# ================================
# Recursively find all Go files in the examples folder
EXAMPLE_GO_FILES := $(shell find examples -name '*.go')
# Extract unique directory names from EXAMPLE_GO_FILES
EXAMPLE_DIRS := $(patsubst examples/%,%,$(patsubst %/,%,$(sort $(dir $(EXAMPLE_GO_FILES)))))
# Generate run targets for each executable in the examples folder
define generate_example_target
example_$(subst /,_,$(1)):
@echo "Building and running example $(1)..."
@go build -o bin/$(subst /,_,$(1)) ./examples/$(1)
@./bin/$(subst /,_,$(1))
endef
# Create targets for each directory in EXAMPLE_DIRS
$(foreach dir,$(EXAMPLE_DIRS),$(eval $(call generate_example_target,$(dir))))
# Debug target to list all available example targets
list-examples:
@echo "Available example targets:"
@for dir in $(EXAMPLE_DIRS); do \
echo " make example_$${dir//\//_}"; \
done
.PHONY: list-examples $(foreach dir,$(EXAMPLE_DIRS),example_$(subst /,_,$(dir)))
test:
go test ./internal/... -v
test-integration:
go test ./test/integration/... -v
.PHONY: test test-integration
# Clean up build artifacts
clean:
rm -f bin/*
swag-files := ./cmd/server,./internal/app/controllers,./internal/pkg/agents/worker,./internal/pkg/ws
# Build Swagger documentation
swagger:
@echo "Current directory: $$(pwd)"
@echo "Generating Swagger documentation..."
@which swag > /dev/null || (echo "swag not found. Installing..." && go install github.com/swaggo/swag/cmd/swag@latest)
@echo "Running swag init..."
@swag fmt -g main.go -d $(swag-files)
@swag init -g main.go -d $(swag-files) -o api/swagger
.PHONY: build clean swagger $(addprefix run-,$(EXECUTABLES))
generate-db-models:
@echo "Generating database models..."
@sqlc generate -f database/sqlc.yml
generate-mocks:
@find internal/pkg -name "type.go" -type f | while read -r file; do \
dest_file=$$(echo "$$file" | sed 's|internal/pkg/|test/_mocks/|' | sed 's|/type.go|/mock_type.go|'); \
dest_dir=$$(dirname "$$dest_file"); \
mkdir -p "$$dest_dir"; \
echo "Generating mock for $$file -> $$dest_file"; \
mockgen -source "$$file" -destination "$$dest_file"; \
done
# Run migrations up
migrate-up: build
./bin/migrate -up -dump
# Run migrations down
migrate-down: build
./bin/migrate -down -dump
run-server:
$(GOBUILD) $(GOBUILD_FLAGS) -o bin/server cmd/server/main.go
@make swagger
./bin/server
run-server-without-control-plane:
$(GOBUILD) $(GOBUILD_FLAGS) -o bin/server cmd/server/main.go
@make swagger
./bin/server --with-control-plane=false
start-milvus:
cd milvus && ./standalone_embed.sh start
stop-milvus:
cd milvus && ./standalone_embed.sh stop
run-milvus-gui:
docker run --rm -p 8000:3000 -e MILVUS_URL=${milvus-url} zilliz/attu:v2.4
start-kafka:
cd kafka-stack-docker-compose && docker compose -f zk-single-kafka-single.yml up -d
stop-kafka:
cd kafka-stack-docker-compose && docker compose -f zk-single-kafka-single.yml down
list-agent-states:
psql -d lucid -c "select id, agent_id, role, status, awakened_at, asleep_at from agent_states order by created_at desc;"
list-agent-profiles:
psql -d lucid -c "select id, agent_id, profile, created_at from agent_profiles order by created_at desc;"
list-posts:
psql -d lucid -c "select id, content, created_at from posts order by created_at desc;"