Files
mce/Makefile

41 lines
1.1 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.

.PHONY: lint fmt check test
GOBIN := $(HOME)/go/bin
BIN_GOFUMPT := $(GOBIN)/gofumpt
BIN_GOIMPORTS := $(GOBIN)/goimports
BIN_LINT := $(GOBIN)/golangci-lint
# === 代码格式化 ===
fmt:
@echo "==> gofumpt..."
@$(BIN_GOFUMPT) -l -w internal/ cmd/
@echo "==> goimports..."
@$(BIN_GOIMPORTS) -w internal/ cmd/
# === 格式检查CI 用,只读不改) ===
fmt-check:
@echo "==> gofumpt check..."
@test -z "$$($(BIN_GOFUMPT) -l internal/ cmd/)" || (echo "gofumpt: 以下文件格式不正确:" && $(BIN_GOFUMPT) -l internal/ cmd/ && exit 1)
@echo "==> goimports check..."
@test -z "$$($(BIN_GOIMPORTS) -l internal/ cmd/)" || (echo "goimports: 以下文件 import 不规范:" && $(BIN_GOIMPORTS) -l internal/ cmd/ && exit 1)
# === 静态分析(报告模式,不阻断) ===
lint:
@echo "==> golangci-lint (report only)..."
@$(BIN_LINT) run ./... || true
# === 静态分析阻断模式CI 用) ===
lint-strict:
@echo "==> golangci-lint (strict)..."
@$(BIN_LINT) run ./...
# === 测试 ===
test:
@echo "==> go test..."
@go test -v -race ./...
# === CI 完整流程(报告模式) ===
ci:
@$(MAKE) fmt-check
@$(MAKE) lint