- Makefile 新增 test-race / test-cover / guard 三个 target - guard 一次性跑所有可机械验证守卫(G1/G6/G11/G12 共 7 条 grep), 任一非零退出即失败;CI 友好,无需 jq/yq - README 补'测试与覆盖率'段落:列覆盖率现状、解释 pgxmock 选型、 解释 pgxPool 接口的存在;路线图把 v2.0 标记为完成 Production gate(合并 main 前必须全绿): ✅ go build ./... ✅ go vet ./... ✅ go test -race ./... ✅ indicator.go 12 函数平均 97.7%(≥90%) ✅ postgres 包 87.6%、mapper.go 100%(≥60%) ✅ make guard 全绿(G1/G6/G11/G12 7 条) ✅ go mod tidy 干净 ✅ entity.TechnicalStructure 字段签名未改 剩余收尾留给真实环境:手动 smoke(make docker-up + migrate-up + run + GET /v1/market/context?symbol=BTCUSDT)在生产部署前由 ops 跑一次。
54 lines
1.7 KiB
Makefile
54 lines
1.7 KiB
Makefile
DATABASE_URL ?= postgres://postgres:postgres@localhost:5432/hermes_market?sslmode=disable
|
||
|
||
.PHONY: run build test test-race test-cover lint tidy docker-up docker-down migrate-up migrate-down backfill guard
|
||
|
||
run:
|
||
go run ./cmd/app
|
||
|
||
build:
|
||
go build -o bin/app ./cmd/app
|
||
go build -o bin/backfill ./cmd/backfill
|
||
|
||
test:
|
||
go test ./...
|
||
|
||
test-race:
|
||
go test -race ./...
|
||
|
||
test-cover:
|
||
go test -race -coverprofile=coverage.out ./...
|
||
go tool cover -func=coverage.out | tail -1
|
||
|
||
lint:
|
||
golangci-lint run
|
||
|
||
tidy:
|
||
go mod tidy
|
||
|
||
# guard 跑全部可机械验证的守卫规则;任一非零退出即失败。
|
||
# 保留极简实现,不做花哨格式化——CI 友好。
|
||
guard:
|
||
@echo "G1 (no signing)..." && ! grep -rqi --include="*.go" "apikey\|x-mbx-apikey\|hmac\|secret_key\|api_secret" .
|
||
@echo "G6 (boundary)..." && ! grep -rq "repo/webapi/binance\|repo/persistent" internal/usecase internal/controller
|
||
@echo "G11 (ctrl derivs)..." && ! grep -rqn "FundingRepo\|OIRepo\|LSRepo\|TakerRepo" internal/controller
|
||
@echo "G12.1 (usecase float)..." && ! { grep -rn --include="*.go" "float64\|float32" internal/usecase | grep -v indicator | grep -q . ; }
|
||
@echo "G12.2 (indicator no repo)..." && ! grep -q "internal/repo" internal/usecase/indicator.go
|
||
@echo "G12.3 (indicator no DB)..." && ! grep -qE "binance|postgres|pgx" internal/usecase/indicator.go
|
||
@echo "G12.4 (entity no float)..." && ! grep -rqn --include="*.go" "float64\|float32" internal/entity
|
||
@echo "all guards green"
|
||
|
||
docker-up:
|
||
docker compose up -d
|
||
|
||
docker-down:
|
||
docker compose down
|
||
|
||
migrate-up:
|
||
migrate -path ./migrations -database "$(DATABASE_URL)" up
|
||
|
||
migrate-down:
|
||
migrate -path ./migrations -database "$(DATABASE_URL)" down 1
|
||
|
||
backfill:
|
||
go run ./cmd/backfill $(ARGS)
|