forked from tmc/langchaingo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (128 loc) · 4.78 KB
/
Makefile
File metadata and controls
154 lines (128 loc) · 4.78 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
# This file contains convenience targets for the project.
# It is not intended to be used as a build system.
# See the README for more information.
.PHONY: help
help:
@echo "Available targets:"
@echo ""
@echo "Testing:"
@echo " test - Run all tests with basic environment setup"
@echo " test-race - Run tests with race detection"
@echo " test-cover - Run tests with coverage reporting"
@echo " test-record - Run tests with re-recording of httprr files"
@echo ""
@echo "Code Quality:"
@echo " lint - Run linter with auto-installation if needed"
@echo " lint-fix - Run linter with automatic fixes"
@echo " lint-testing - Check test patterns and practices (httprr, etc.)"
@echo " lint-testing-fix - Check and attempt to fix test patterns"
@echo " lint-architecture - Check architectural rules and patterns"
@echo ""
@echo "Other:"
@echo " build-examples - Build all example projects to verify they compile"
@echo " docs - Generate documentation"
@echo " clean - Clean lint cache"
@echo " help - Show this help message"
@echo ""
@echo "Git Hooks:"
@echo " pre-push - Run lint and fast tests (suitable for git pre-push hook)"
@echo " install-git-hooks - Install git hooks (sets up pre-push hook)"
.PHONY: test
test:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test ./...
.PHONY: lint
lint: lint-deps
golangci-lint run --color=always ./...
.PHONY: lint-exp
lint-exp:
golangci-lint run --fix --config .golangci-exp.yaml ./...
.PHONY: lint-fix
lint-fix:
golangci-lint run --fix ./...
.PHONY: lint-all
lint-all:
golangci-lint run --color=always ./...
.PHONY: lint-deps
lint-deps:
@command -v golangci-lint >/dev/null 2>&1 || { \
echo >&2 "golangci-lint not found. Installing..."; \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6; \
command -v golangci-lint >/dev/null 2>&1 || { \
echo >&2 "Failed to detect golangci-lint after installation. Please check your Go installation and PATH."; \
exit 1; \
} \
}
@golangci-lint version | grep -q "version v2" || { echo "Error: golangci-lint v2.x.x required, found:" && golangci-lint version && exit 1; }
.PHONY: docs
docs:
@echo "Generating documentation..."
$(MAKE) -C docs build
.PHONY: test-race
test-race:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test -race ./...
.PHONY: test-cover
test-cover:
DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test -cover ./...
.PHONY: test-record
test-record:
@echo "Re-recording HTTP interactions for all packages using httprr..."
@echo "Note: Running with limited parallelism to avoid API rate limits"
PACKAGES=$$(go run ./internal/devtools/rrtool list-packages -format=paths) && \
echo "Recording HTTP interactions for packages:" && \
echo "$$PACKAGES" | tr ' ' '\n' | sed 's/^/ /' && \
echo "" && \
env DOCKER_HOST=$$(docker context inspect -f='{{.Endpoints.docker.Host}}' 2>/dev/null || echo "unix:///var/run/docker.sock") \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="/var/run/docker.sock" \
go test $$PACKAGES -httprecord=. -httprecord-delay=1s -p 2 -parallel=2 -timeout=300s
.PHONY: run-pkgsite
run-pkgsite:
go run golang.org/x/pkgsite/cmd/pkgsite@latest
.PHONY: clean
clean: clean-lint-cache
.PHONY: clean-lint-cache
clean-lint-cache:
golangci-lint cache clean
.PHONY: build-examples
build-examples:
for example in $(shell find ./examples -mindepth 1 -maxdepth 1 -type d); do \
(cd $$example; echo Build $$example; go mod tidy; go build -o /dev/null) || exit 1; done
.PHONY: add-go-work
add-go-work:
go work init .
go work use -r .
.PHONY: lint-devtools
lint-devtools:
go run ./internal/devtools/lint -v
.PHONY: lint-devtools-fix
lint-devtools-fix:
go run ./internal/devtools/lint -fix -v
.PHONY: lint-architecture
lint-architecture:
go run ./internal/devtools/lint -architecture -v
.PHONY: lint-prepush
lint-prepush:
go run ./internal/devtools/lint -prepush -v
.PHONY: lint-prepush-fix
lint-prepush-fix:
go run ./internal/devtools/lint -prepush -fix -v
.PHONY: lint-testing
lint-testing:
go run ./internal/devtools/lint -testing -v
.PHONY: lint-testing-fix
lint-testing-fix:
go run ./internal/devtools/lint -testing -fix -v
.PHONY: pre-push
pre-push:
@echo "Running pre-push checks..."
@$(MAKE) lint
@go test -short ./...
@echo "✅ Pre-push checks passed!"
.PHONY: install-git-hooks
install-git-hooks:
@./internal/devtools/git-hooks/install-git-hooks.sh