# forge-toolkit — сборка, тесты, линт. GO ?= go GOLANGCI_LINT ?= golangci-lint .PHONY: test test-fast lint fmt tidy toolkit-deps ci # Тесты с race-детектором (основной гейт). test: $(GO) test -race ./... -count=1 # Быстрая итерация без race. test-fast: $(GO) build ./... && $(GO) vet ./... && $(GO) test ./... -count=1 # Статический анализ + форматирование. lint: @command -v $(GOLANGCI_LINT) >/dev/null 2>&1 || { \ echo "golangci-lint не найден: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2"; \ exit 1; } $(GOLANGCI_LINT) run ./... @unformatted=$$(gofmt -l .); \ if [ -n "$$unformatted" ]; then echo "gofmt: нужно форматирование: $$unformatted"; exit 1; fi fmt: gofmt -w . tidy: $(GO) mod tidy # Карантин зависимостей: тулкит обязан оставаться stdlib + go-sdk # (+ yaml/toml в validate). Любая другая ПРЯМАЯ зависимость — ошибка. toolkit-deps: @direct=$$($(GO) list -m -f '{{if not .Main}}{{if not .Indirect}}{{.Path}}{{end}}{{end}}' all); \ allowed='^(github.com/modelcontextprotocol/go-sdk|gopkg.in/yaml.v3|github.com/BurntSushi/toml)$$'; \ bad=$$(echo "$$direct" | grep -vE "$$allowed" | grep -v '^$$'); \ if [ -n "$$bad" ]; then \ echo "недопустимые прямые зависимости (разрешены только go-sdk/yaml/toml):"; \ echo "$$bad"; exit 1; \ fi; \ echo "toolkit-deps: ok" ci: test lint toolkit-deps