-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
203 lines (181 loc) · 5.24 KB
/
Makefile
File metadata and controls
203 lines (181 loc) · 5.24 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Chinese GraphRAG 測試自動化 Makefile
.PHONY: help install test test-unit test-integration test-chinese test-performance
.PHONY: quality-check security-scan coverage report clean setup-test-data
.PHONY: test-automation ci-local
# 預設目標
help:
@echo "Chinese GraphRAG 測試自動化命令"
@echo ""
@echo "安裝和設定:"
@echo " install 安裝專案依賴"
@echo " setup-test-data 初始化測試資料"
@echo ""
@echo "測試執行:"
@echo " test 執行所有測試"
@echo " test-unit 執行單元測試"
@echo " test-integration 執行整合測試"
@echo " test-chinese 執行中文功能測試"
@echo " test-performance 執行效能測試"
@echo ""
@echo "品質檢查:"
@echo " quality-check 執行程式碼品質檢查"
@echo " security-scan 執行安全性掃描"
@echo " coverage 生成覆蓋率報告"
@echo ""
@echo "報告和自動化:"
@echo " report 生成測試報告"
@echo " test-automation 執行完整測試自動化管道"
@echo " ci-local 本地模擬 CI 環境"
@echo ""
@echo "清理:"
@echo " clean 清理生成的檔案"
# 安裝依賴
install:
@echo "📦 安裝專案依賴..."
uv sync --dev
# 初始化測試資料
setup-test-data:
@echo "🚀 初始化測試資料..."
uv run python scripts/init_test_data.py --reset
# 執行所有測試
test:
@echo "🧪 執行所有測試..."
uv run pytest tests/ \
--cov=src/chinese_graphrag \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--junit-xml=pytest-all.xml \
--tb=short \
-v
# 執行單元測試
test-unit:
@echo "🧪 執行單元測試..."
uv run pytest tests/ \
--cov=src/chinese_graphrag \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--junit-xml=pytest-unit.xml \
-m "not integration and not slow" \
--tb=short \
-v
# 執行整合測試
test-integration:
@echo "🧪 執行整合測試..."
uv run pytest tests/integration/ \
--junit-xml=pytest-integration.xml \
-m "integration" \
--tb=short \
-v
# 執行中文功能測試
test-chinese:
@echo "🧪 執行中文功能測試..."
uv run pytest tests/ \
--junit-xml=pytest-chinese.xml \
-m "chinese" \
--tb=short \
-v
# 執行效能測試
test-performance:
@echo "⚡ 執行效能測試..."
uv run pytest tests/integration/test_performance.py \
--benchmark-json=benchmark.json \
--benchmark-only \
-v
# 程式碼品質檢查
quality-check:
@echo "🔍 執行程式碼品質檢查..."
@echo " 檢查程式碼格式 (Black)..."
uv run black --check --diff src/ tests/
@echo " 檢查導入排序 (isort)..."
uv run isort --check-only --diff src/ tests/
@echo " 檢查程式碼風格 (flake8)..."
uv run flake8 src/ tests/
@echo " 檢查型別註解 (mypy)..."
uv run mypy src/ || true
# 安全性掃描
security-scan:
@echo "🔒 執行安全性掃描..."
pip install bandit[toml]
bandit -r src/ -f json -o bandit-report.json || true
bandit -r src/ -f txt
# 生成覆蓋率報告
coverage: test-unit
@echo "📊 生成覆蓋率報告..."
@echo "HTML 報告已生成在 htmlcov/ 目錄"
@echo "XML 報告已生成: coverage.xml"
# 生成測試報告
report:
@echo "📊 生成測試報告..."
uv run python scripts/generate_test_report.py \
--output-dir test-reports \
--format html,json,summary \
--include-coverage \
--include-performance
# 執行完整測試自動化管道
test-automation:
@echo "🚀 執行完整測試自動化管道..."
uv run python scripts/run_test_automation.py \
--test-types unit integration chinese
# 本地模擬 CI 環境
ci-local: install setup-test-data quality-check test security-scan report
@echo "🎯 執行品質閘門檢查..."
uv run python scripts/quality_gate.py \
--test-results-dir . \
--coverage-file coverage.xml \
--benchmark-file benchmark.json \
--security-file bandit-report.json \
--config config/quality_gate.yaml
# 清理生成的檔案
clean:
@echo "🧹 清理生成的檔案..."
rm -rf htmlcov/
rm -rf test-reports/
rm -rf .coverage
rm -rf .pytest_cache/
rm -rf tests/__pycache__/
rm -rf src/**/__pycache__/
rm -f coverage.xml
rm -f pytest-*.xml
rm -f benchmark.json
rm -f bandit-report.json
rm -f quality-gate-results.json
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
# 格式化程式碼
format:
@echo "✨ 格式化程式碼..."
uv run black src/ tests/
uv run isort src/ tests/
# 快速測試(僅單元測試)
test-quick:
@echo "⚡ 執行快速測試..."
uv run pytest tests/ \
-m "not integration and not slow" \
--tb=short \
-x \
-q
# 監視模式測試
test-watch:
@echo "👀 監視模式測試..."
uv run pytest-watch tests/ \
-m "not integration and not slow" \
--tb=short
# 檢查依賴更新
check-deps:
@echo "🔍 檢查依賴更新..."
uv tree --outdated
# 更新依賴
update-deps:
@echo "📦 更新依賴..."
uv sync --upgrade
# 建立開發環境
dev-setup: install setup-test-data
@echo "🛠️ 開發環境設定完成!"
@echo ""
@echo "可用命令:"
@echo " make test-quick # 快速測試"
@echo " make test # 完整測試"
@echo " make quality-check # 品質檢查"
@echo " make format # 格式化程式碼"