Files
cryptoHermes/Makefile
dela 12420c5db7 chore(milestone6): Makefile guard/test-cover/test-race + README 测试章节
- 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 跑一次。
2026-05-24 20:51:20 +08:00

54 lines
1.7 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)