-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (105 loc) · 4.94 KB
/
Makefile
File metadata and controls
139 lines (105 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# AgentHub — CI / Pre-push Test Suite
# Usage: make test (unit tests, no external deps)
# make test-all (all tests including integration)
# make lint (golangci-lint)
# make coverage (HTML coverage report)
# make fe-lint (frontend eslint + stylelint)
# make fe-build (build all frontend packages)
# make release VER=v0.1.1 (build + upload release binaries)
# make help (show this help)
.PHONY: test test-all test-edge test-hub lint coverage sec release clean fmt \
fe-install fe-dev fe-build fe-test fe-lint fe-typecheck help
# ── Help ───────────────────────────────────────────
help:
@echo "AgentHub Makefile targets:"
@echo ""
@echo " Backend:"
@echo " test 单元测试 (edge + hub, -short)"
@echo " test-all 完整测试 (需 Redis + PG)"
@echo " test-edge Edge Server 单元测试"
@echo " test-hub Hub Server 单元测试"
@echo " lint golangci-lint (edge + hub)"
@echo " coverage 覆盖率报告 (HTML + func)"
@echo " sec gosec + govulncheck"
@echo " bench Benchmark (events + service)"
@echo " ci 全量 CI: test + lint + sec"
@echo " clean 清理测试缓存和覆盖率文件"
@echo ""
@echo " Frontend:"
@echo " fe-install pnpm install"
@echo " fe-dev pnpm dev (desktop :5173)"
@echo " fe-build pnpm -r build (全部包)"
@echo " fe-test pnpm -r test"
@echo " fe-lint eslint + stylelint"
@echo " fe-typecheck tsc --noEmit (desktop + web)"
@echo ""
@echo " Release:"
@echo " release VER=v0.1.1 一键构建 + 上传"
@echo ""
# ── Unit tests (no external deps) ────────────────────
test: test-edge test-hub
test-edge:
cd edge-server && go test ./... -short -count=1 -timeout 60s
test-hub:
cd hub-server && go test ./... -short -count=1 -timeout 60s
# ── Full tests (requires Redis + PG) ─────────────────
test-all: test-edge-full test-hub-full
test-edge-full:
cd edge-server && go test ./... -count=1 -timeout 120s -race
test-hub-full:
cd hub-server && go test ./... -count=1 -timeout 120s
# ── Benchmarks ───────────────────────────────────
bench:
cd edge-server && go test -bench=. -benchmem ./internal/events/
cd hub-server && go test -bench=. -benchmem ./internal/service/
# ── Lint ─────────────────────────────────────────
lint:
cd edge-server && golangci-lint run ./...
cd hub-server && golangci-lint run ./...
# ── Format ───────────────────────────────────────
fmt:
cd edge-server && gofmt -w .
cd hub-server && gofmt -w .
# ── Coverage ─────────────────────────────────────
coverage:
cd edge-server && go test ./... -short -coverprofile=coverage.out && go tool cover -html=coverage.out -o coverage.html
cd hub-server && go test ./... -short -coverprofile=coverage.out && go tool cover -func=coverage.out
# ── Security ─────────────────────────────────────
sec:
cd edge-server && gosec ./...
cd hub-server && gosec ./...
cd edge-server && govulncheck ./...
cd hub-server && govulncheck ./...
# ── All checks (CI pipeline) ─────────────────────
ci: test lint sec
# ── Release ─────────────────────────────────────
release:
@if [ -z "$(VER)" ]; then echo "Usage: make release VER=v0.1.1"; exit 1; fi
@if command -v pwsh >/dev/null 2>&1; then \
pwsh -File scripts/release.ps1 $(VER); \
elif command -v powershell >/dev/null 2>&1; then \
powershell -File scripts/release.ps1 $(VER); \
else \
echo "Error: PowerShell (pwsh or powershell) is required for release"; exit 1; \
fi
# ── Clean ────────────────────────────────────────
clean:
cd edge-server && go clean -testcache
cd hub-server && go clean -testcache
rm -f edge-server/coverage.out edge-server/coverage.html
rm -f hub-server/coverage.out hub-server/coverage.html
# ── Frontend ─────────────────────────────────────
fe-install:
cd app && pnpm install
fe-dev:
cd app && pnpm dev
fe-build:
cd app && pnpm -r build
fe-test:
cd app && pnpm -r test
fe-lint:
cd app && pnpm -r lint
cd app && pnpm lint:css
fe-typecheck:
cd app/desktop && npx tsc --noEmit
cd app/web && npx tsc --noEmit