Makefile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .PHONY: wire build build-embed test-unit test-integration test-e2e test-cover-integration
  2. VERSION ?= $(shell ./scripts/resolve-version.sh)
  3. LDFLAGS ?= -s -w -X main.Version=$(VERSION)
  4. wire:
  5. @echo "生成 Wire 代码..."
  6. @cd cmd/server && go generate
  7. @echo "Wire 代码生成完成"
  8. build:
  9. @echo "构建后端(不嵌入前端)..."
  10. @go build -ldflags="$(LDFLAGS)" -o bin/server ./cmd/server
  11. @echo "构建完成: bin/server"
  12. build-embed:
  13. @echo "构建后端(嵌入前端)..."
  14. @go build -tags embed -ldflags="$(LDFLAGS)" -o bin/server ./cmd/server
  15. @echo "构建完成: bin/server (with embedded frontend)"
  16. test-unit:
  17. @go test -tags unit ./... -count=1
  18. test-integration:
  19. @go test -tags integration ./... -count=1 -race -parallel=8
  20. test-e2e:
  21. @echo "运行 E2E 测试(需要本地服务器运行)..."
  22. @go test -tags e2e ./internal/integration/... -count=1 -v
  23. test-cover-integration:
  24. @echo "运行集成测试并生成覆盖率报告..."
  25. @go test -tags=integration -cover -coverprofile=coverage.out -count=1 -race -parallel=8 ./...
  26. @go tool cover -func=coverage.out | tail -1
  27. @go tool cover -html=coverage.out -o coverage.html
  28. @echo "覆盖率报告已生成: coverage.html"
  29. clean-coverage:
  30. @rm -f coverage.out coverage.html
  31. @echo "覆盖率文件已清理"
  32. clean: clean-coverage
  33. @rm -rf bin/
  34. @echo "构建产物已清理"