Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (82 loc) · 3.29 KB
/
Copy pathMakefile
File metadata and controls
101 lines (82 loc) · 3.29 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
# Lint, format, build and test every example. `make check` is what CI runs.
# Each per-language target needs only that language's toolchain.
PYTHON_DIRS := weather-server-python mcp-client-python
TS_DIRS := weather-server-typescript mcp-client-typescript tests/helpers
GO_DIRS := weather-server-go mcp-client-go
RUST_DIRS := weather-server-rust mcp-client-rust
RUBY_FILES := weather-server-ruby/weather.rb mcp-client-ruby/client.rb
.PHONY: help check lint fmt build test \
lint-python lint-typescript lint-go lint-rust lint-ruby \
fmt-python fmt-go fmt-rust \
build-typescript build-go build-rust
help:
@echo "make check lint, then build and run the smoke tests"
@echo "make lint check formatting and lint every example"
@echo "make fmt format Python, Go and Rust in place"
@echo "make build rebuild the TypeScript, Go and Rust examples"
@echo "make test rebuild, then run tests/smoke-test.sh"
@echo "Per language: lint-{python,typescript,go,rust,ruby},"
@echo " fmt-{python,go,rust}, build-{typescript,go,rust}"
# Lint first, then test, even under `make -j`: both install npm packages.
check: lint
$(MAKE) test
lint: lint-python lint-typescript lint-go lint-rust lint-ruby
fmt: fmt-python fmt-go fmt-rust
build: build-typescript build-go build-rust
# smoke-test.sh builds only what is missing, so rebuild first to avoid
# testing stale binaries.
test: build
./tests/smoke-test.sh
lint-python:
@set -e; for d in $(PYTHON_DIRS); do \
echo "== ruff $$d"; \
uv --directory $$d run --quiet ruff check .; \
uv --directory $$d run --quiet ruff format --check .; \
done
fmt-python:
@set -e; for d in $(PYTHON_DIRS); do \
uv --directory $$d run --quiet ruff check --fix .; \
uv --directory $$d run --quiet ruff format .; \
done
lint-typescript:
@set -e; for d in $(TS_DIRS); do \
echo "== tsc $$d"; \
[ -d $$d/node_modules ] || npm --prefix $$d ci --silent; \
(cd $$d && npx tsc --noEmit); \
done
build-typescript:
@set -e; for d in $(TS_DIRS); do \
[ -d $$d/node_modules ] || npm --prefix $$d ci --silent; \
npm --prefix $$d run --silent build; \
done
lint-go:
@set -e; for d in $(GO_DIRS); do \
echo "== gofmt, go vet $$d"; \
unformatted=$$(cd $$d && gofmt -l .); \
if [ -n "$$unformatted" ]; then echo "needs gofmt: $$unformatted"; exit 1; fi; \
(cd $$d && go vet ./...); \
done
fmt-go:
@set -e; for d in $(GO_DIRS); do (cd $$d && gofmt -w .); done
# The binary names are the ones smoke-test.sh runs. `go build -o` adds no
# `.exe` on Windows, so add it to replace the binary the smoke tests pick.
build-go:
cd weather-server-go && go build -o server$$(go env GOEXE) .
cd mcp-client-go && go build -o mcp-client-go$$(go env GOEXE) .
lint-rust:
@set -e; for d in $(RUST_DIRS); do \
echo "== rustfmt, clippy $$d"; \
(cd $$d && cargo fmt --check && cargo clippy --quiet --all-targets -- -D warnings); \
done
fmt-rust:
@set -e; for d in $(RUST_DIRS); do (cd $$d && cargo fmt); done
build-rust:
@set -e; for d in $(RUST_DIRS); do (cd $$d && cargo build --quiet --release); done
# `ruby -wc` exits 0 even when it prints warnings, so fail on the output.
lint-ruby:
@set -e; for f in $(RUBY_FILES); do \
echo "== ruby -wc $$f"; \
out=$$(ruby -wc $$f 2>&1) || { echo "$$out"; exit 1; }; \
echo "$$out"; \
if echo "$$out" | grep -q 'warning:'; then exit 1; fi; \
done