-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (135 loc) · 3.94 KB
/
Makefile
File metadata and controls
174 lines (135 loc) · 3.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# shnote Makefile
# 常用开发命令
.PHONY: all build build-release check test test-verbose lint fmt clean install uninstall cov cov-html cov-open doc doc-open help
.PHONY: release-patch release-minor release-major release-dry
# 默认目标
all: check test
# ============ 构建 ============
# Debug 构建
build:
cargo build
# Release 构建
build-release:
cargo build --release
# 检查编译(不生成二进制)
check:
cargo check
# ============ 测试 ============
# 运行所有测试
test:
cargo test
# 详细输出测试
test-verbose:
cargo test -- --nocapture
# 运行特定测试(用法:make test-one TEST=test_name)
test-one:
cargo test $(TEST) -- --nocapture
# 串行运行测试(调试并发问题时使用)
test-serial:
cargo test -- --test-threads=1
# ============ 代码质量 ============
# Clippy 检查(警告视为错误)
lint:
cargo clippy -- -D warnings
# 格式化代码
fmt:
cargo fmt
# 检查格式(不修改)
fmt-check:
cargo fmt -- --check
# 完整检查(lint + fmt + test)
ci: fmt-check lint test
# ============ 覆盖率 ============
# 安装覆盖率工具(首次使用前运行)
cov-install:
cargo install cargo-llvm-cov
# 生成覆盖率报告(终端输出)
cov:
cargo llvm-cov --all-features
# 生成 HTML 覆盖率报告
cov-html:
cargo llvm-cov --all-features --html
# 生成并打开 HTML 覆盖率报告
cov-open:
cargo llvm-cov --all-features --open
# 生成 LCOV 格式报告(用于 CI)
cov-lcov:
cargo llvm-cov --all-features --lcov --output-path lcov.info
# ============ 文档 ============
# 生成文档
doc:
cargo doc --no-deps
# 生成并打开文档
doc-open:
cargo doc --no-deps --open
# ============ 安装/卸载 ============
# 安装到系统
install:
cargo install --path .
# 从系统卸载
uninstall:
cargo uninstall shnote
# ============ 清理 ============
# 清理构建产物
clean:
cargo clean
# 清理覆盖率数据
clean-cov:
cargo llvm-cov clean --workspace
# ============ 发布 ============
# 预览发布(dry-run)
release-dry:
cargo release patch --no-verify
# 发布 patch 版本 (0.1.5 → 0.1.6)
release-patch: ci
cargo release patch --execute --no-verify --no-confirm
# 发布 minor 版本 (0.1.5 → 0.2.0)
release-minor: ci
cargo release minor --execute --no-verify --no-confirm
# 发布 major 版本 (0.1.5 → 1.0.0)
release-major: ci
cargo release major --execute --no-verify --no-confirm
# 检查发布准备情况
publish-check:
cargo publish --dry-run
# ============ 帮助 ============
help:
@echo "shnote 开发命令"
@echo ""
@echo "构建:"
@echo " make build - Debug 构建"
@echo " make build-release - Release 构建"
@echo " make check - 检查编译"
@echo ""
@echo "测试:"
@echo " make test - 运行所有测试"
@echo " make test-verbose - 详细输出测试"
@echo " make test-one TEST=name - 运行特定测试"
@echo " make test-serial - 串行运行测试"
@echo ""
@echo "代码质量:"
@echo " make lint - Clippy 检查"
@echo " make fmt - 格式化代码"
@echo " make fmt-check - 检查格式"
@echo " make ci - 完整 CI 检查"
@echo ""
@echo "覆盖率:"
@echo " make cov-install - 安装覆盖率工具"
@echo " make cov - 终端覆盖率报告"
@echo " make cov-html - HTML 覆盖率报告"
@echo " make cov-open - 生成并打开 HTML 报告"
@echo ""
@echo "文档:"
@echo " make doc - 生成文档"
@echo " make doc-open - 生成并打开文档"
@echo ""
@echo "发布:"
@echo " make release-dry - 预览发布(dry-run)"
@echo " make release-patch - 发布 patch 版本"
@echo " make release-minor - 发布 minor 版本"
@echo " make release-major - 发布 major 版本"
@echo ""
@echo "其他:"
@echo " make install - 安装到系统"
@echo " make uninstall - 从系统卸载"
@echo " make clean - 清理构建产物"