Skip to content

Commit 7115161

Browse files
author
shijiashuai
committed
ci: 修复 CI 目录检查和翻译校验脚本
- quality-check.yml: 将不存在的 examples/templates 目录替换为实际存在的 scripts 目录 - validate_translations.py: 修正文件匹配模式为 .cursorrules,移除未使用的 yaml 导入,增加中文内容检测
1 parent 57298ed commit 7115161

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

.github/workflows/quality-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: 检查目录结构
4242
run: |
4343
echo "验证项目目录结构..."
44-
required_dirs=("rules" "docs" "examples" "templates")
44+
required_dirs=("rules" "docs" "scripts")
4545
for dir in "${required_dirs[@]}"; do
4646
if [ ! -d "$dir" ]; then
4747
echo "错误: 缺少必需目录 $dir"

scripts/validate_translations.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
import glob
2-
import yaml
3-
from pathlib import Path
2+
import os
3+
44

55
def check_translation_consistency():
6+
"""检查 rules/ 目录下所有 .cursorrules 文件的基本完整性。"""
67
errors = 0
7-
for file in glob.glob("rules/**/*.mdc", recursive=True):
8+
files_checked = 0
9+
for file in glob.glob("rules/**/.cursorrules", recursive=True):
10+
files_checked += 1
11+
file_size = os.path.getsize(file)
12+
if file_size == 0:
13+
print(f"❌ {file} 文件为空")
14+
errors += 1
15+
continue
816
with open(file, encoding='utf-8') as f:
917
content = f.read()
10-
if "---" not in content:
11-
print(f"❌ {file} 缺少元数据头部")
12-
errors += 1
13-
elif "description:" not in content:
14-
print(f"⚠️ {file} 缺少description描述")
15-
return errors
18+
# 检查是否包含中文内容(表明已翻译)
19+
has_chinese = any('\u4e00' <= ch <= '\u9fff' for ch in content)
20+
if not has_chinese:
21+
print(f"⚠️ {file} 可能未翻译(未检测到中文内容)")
22+
return errors, files_checked
23+
1624

1725
if __name__ == "__main__":
1826
print("开始翻译校验...")
19-
error_count = check_translation_consistency()
20-
print(f"校验完成,发现 {error_count} 处问题")
27+
error_count, total = check_translation_consistency()
28+
print(f"校验完成:共检查 {total} 个文件,发现 {error_count} 处问题")

0 commit comments

Comments
 (0)