## 主要改进 ### 架构重构 - 将单体 provider.go 拆分为多个专门的模块文件 - 实现了清晰的职责分离和模块化设计 - 遵循 SOLID 原则,提高代码可维护性 ### 新增功能 - **验证规则系统**: 实现了完整的 provider 验证框架 - **报告生成器**: 支持多种格式的验证报告 (JSON/HTML/Markdown/Text) - **解析器优化**: 重新设计了解析流程,提高性能和可扩展性 - **错误处理**: 增强了错误处理和诊断能力 ### 修复关键 Bug - 修复 @provider(job) 注解缺失 __job 注入参数的问题 - 统一了 job 和 cronjob 模式的处理逻辑 - 确保了 provider 生成的正确性和一致性 ### 代码质量提升 - 添加了完整的测试套件 - 引入了 golangci-lint 代码质量检查 - 优化了代码格式和结构 - 增加了详细的文档和规范 ### 文件结构优化 ``` pkg/ast/provider/ ├── types.go # 类型定义 ├── parser.go # 解析器实现 ├── validator.go # 验证规则 ├── report_generator.go # 报告生成 ├── renderer.go # 渲染器 ├── comment_parser.go # 注解解析 ├── modes.go # 模式定义 ├── errors.go # 错误处理 └── validator_test.go # 测试文件 ``` ### 兼容性 - 保持向后兼容性 - 支持现有的所有 provider 模式 - 优化了 API 设计和用户体验 This completes the implementation of T025-T029 tasks following TDD principles, including validation rules implementation and critical bug fixes.
70 lines
2.4 KiB
Makefile
70 lines
2.4 KiB
Makefile
# Makefile for pkg/ast/provider development
|
|
|
|
.PHONY: help test benchmark lint clean setup install-tools
|
|
|
|
# Default target
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " setup - Install required tools"
|
|
@echo " test - Run all tests"
|
|
@echo " test-coverage - Run tests with coverage"
|
|
@echo " benchmark - Run benchmark tests"
|
|
@echo " lint - Run linter"
|
|
@echo " clean - Clean build artifacts"
|
|
@echo " install-tools - Install development tools"
|
|
|
|
# Install required tools
|
|
install-tools:
|
|
@echo "Installing development tools..."
|
|
go install github.com/golang/mock/mockgen@latest
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
go install github.com/axw/gocov/gocov@latest
|
|
go install github.com/AlekSi/gocov-xml@latest
|
|
|
|
# Setup development environment
|
|
setup: install-tools
|
|
@echo "Setting up development environment..."
|
|
go mod download
|
|
go mod tidy
|
|
|
|
# Run all tests
|
|
test:
|
|
@echo "Running tests..."
|
|
go test -v -race -parallel=4 ./tests/... ./pkg/ast/provider/...
|
|
|
|
# Run tests with coverage
|
|
test-coverage:
|
|
@echo "Running tests with coverage..."
|
|
go test -v -coverprofile=coverage.out -covermode=atomic ./tests/... ./pkg/ast/provider/...
|
|
go tool cover -html=coverage.out -o coverage.html
|
|
@echo "Coverage report generated: coverage.html"
|
|
|
|
# Run benchmark tests
|
|
benchmark:
|
|
@echo "Running benchmark tests..."
|
|
go test -bench=. -benchmem -count=3 ./pkg/ast/provider/...
|
|
|
|
# Run linter
|
|
lint:
|
|
@echo "Running linter..."
|
|
golangci-lint run ./pkg/ast/provider/... ./tests/...
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
rm -f coverage.out coverage.html
|
|
rm -rf vendor/
|
|
go clean -cache -testcache
|
|
|
|
# Run performance validation
|
|
validate-performance:
|
|
@echo "Validating performance requirements..."
|
|
@echo "Running single file parsing benchmark..."
|
|
@go test -bench=ParseFile -benchtime=100ms -count=5 ./pkg/ast/provider/... | grep -E "(ParseFile|MB/s|allocs/op)"
|
|
@echo "Running project parsing benchmark..."
|
|
@go test -bench=ParseProject -benchtime=1s -count=3 ./pkg/ast/provider/... | grep -E "(ParseProject|MB/s|allocs/op)"
|
|
|
|
# Check test coverage meets requirements
|
|
check-coverage: test-coverage
|
|
@echo "Checking coverage meets 90% requirement..."
|
|
@go tool cover -func=coverage.out | grep total | awk '{if ($$3 < 90.0) {print "Coverage " $$3 " is below 90% requirement"; exit 1} else {print "Coverage " $$3 " meets requirement"}}'
|