6ec7cd8146
合并 proto 契约 + buf 工具链任务到 main(已含 apierr + idgen + CONVENTIONS.md): - server/proto/pangolin/agent/v1/agent.proto: AgentService 6 个 RPC(Enroll/Register/ Heartbeat/Subscribe/Ack/ReportUsage)及全量消息类型,隐私红线注释保留 - server/buf.yaml: v2 格式,STANDARD lint + FILE breaking 规则 - server/buf.gen.yaml: remote protoc-gen-go v1.36.4 + protoc-gen-go-grpc v1.5.1 插件 - server/internal/pb/: 生成的 agent.pb.go + agent_grpc.pb.go 提交入库 - server/Makefile: 新增 proto / proto-lint / proto-breaking 目标 - server/tools.go: 新增 buf v1.70.0、protoc-gen-go、protoc-gen-go-grpc 工具依赖 - server/go.mod / go.sum: 合并 buf 工具链依赖;github.com/google/uuid 保留为 direct 依赖(idgen 直接 import);go 版本升至 1.25.10 冲突解决:两侧均修改 go.mod,以 proto 分支(超集)为基础,将 google/uuid 移至 直接依赖 require 块,保留 apierr/idgen 的已有文件不变。 go build ./... ✓ | go test ./internal/apierr/... ./internal/idgen/... ✓ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
2.9 KiB
Makefile
52 lines
2.9 KiB
Makefile
.PHONY: build test test-unit test-integration vet lint generate migrate-up migrate-down build-codegen deps proto proto-lint proto-breaking
|
||
|
||
# ── deps ───────────────────────────────────────────────────────────────────────
|
||
deps:
|
||
go mod tidy
|
||
go mod download
|
||
|
||
# ── build ──────────────────────────────────────────────────────────────────────
|
||
build:
|
||
go build ./...
|
||
|
||
build-codegen: ## 激活码批次生成 CLI
|
||
go build -o bin/codegen ./cmd/codegen
|
||
|
||
# ── test ───────────────────────────────────────────────────────────────────────
|
||
test:
|
||
go test ./...
|
||
|
||
test-unit: ## 单测(不依赖外部服务)
|
||
go test -count=1 -race ./internal/codes/... -run 'Test[^I][^n][^t]'
|
||
|
||
test-integration: ## 集成测试(需本机 docker,testcontainers)
|
||
go test -count=1 ./internal/codes/... -run TestInt
|
||
|
||
# ── vet / lint ─────────────────────────────────────────────────────────────────
|
||
vet:
|
||
go vet ./...
|
||
lint:
|
||
golangci-lint run ./...
|
||
|
||
# ── generate ───────────────────────────────────────────────────────────────────
|
||
generate:
|
||
@echo "generate: not yet configured (see task 1d)"
|
||
|
||
# ── proto ──────────────────────────────────────────────────────────────────────
|
||
proto: ## 从 proto/ 生成 internal/pb/ 代码(buf generate)
|
||
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 generate
|
||
|
||
proto-lint: ## 检查 proto 语法与命名规范(buf lint)
|
||
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 lint
|
||
|
||
proto-breaking: ## 与 main 分支对比检测 breaking change(buf breaking)
|
||
## 注:proto 首次合入 main 前,main 无 .proto 文件,此命令预期报"had no .proto files";
|
||
## proto 合入 main 后,后续所有变更须通过此检查,无报错视为通过。
|
||
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 breaking --against '../.git#branch=main,subdir=server'
|
||
|
||
# ── migrate ────────────────────────────────────────────────────────────────────
|
||
migrate-up:
|
||
@echo "migrate-up: see cmd/migrate"
|
||
migrate-down:
|
||
@echo "migrate-down: see cmd/migrate"
|