|
1 | 1 | #!/bin/bash |
2 | 2 | # ============================================================================= |
3 | | -# CI 本地模拟脚本 |
4 | | -# 用途: 在提交 PR 前模拟 CI 的所有检查步骤 |
| 3 | +# CI local simulation script |
| 4 | +# Purpose: Run all CI checks locally before creating a PR |
5 | 5 | # ============================================================================= |
6 | 6 |
|
7 | | -set -e # 遇到错误立即退出 |
| 7 | +set -e # Exit on error |
8 | 8 |
|
9 | | -# 颜色定义 |
| 9 | +# Color definitions |
10 | 10 | RED='\033[0;31m' |
11 | 11 | GREEN='\033[0;32m' |
12 | 12 | YELLOW='\033[1;33m' |
@@ -38,25 +38,25 @@ print_warning() { |
38 | 38 | # ============================================================================= |
39 | 39 | print_header "Step 1/4: Lint & Format Check" |
40 | 40 |
|
41 | | -echo "检查代码格式..." |
| 41 | +echo "Checking code format..." |
42 | 42 | if ruff format --check src/ tests/; then |
43 | | - print_success "代码格式检查通过" |
| 43 | + print_success "Code format check passed" |
44 | 44 | else |
45 | | - print_error "代码格式检查失败" |
| 45 | + print_error "Code format check failed" |
46 | 46 | echo "" |
47 | | - echo "运行以下命令修复:" |
| 47 | + echo "Run the following to fix formatting:" |
48 | 48 | echo " ruff format src/ tests/" |
49 | 49 | exit 1 |
50 | 50 | fi |
51 | 51 |
|
52 | 52 | echo "" |
53 | | -echo "运行 Linter..." |
| 53 | +echo "Running linter..." |
54 | 54 | if ruff check src/ tests/; then |
55 | | - print_success "Lint 检查通过" |
| 55 | + print_success "Lint check passed" |
56 | 56 | else |
57 | | - print_error "Lint 检查失败" |
| 57 | + print_error "Lint check failed" |
58 | 58 | echo "" |
59 | | - echo "尝试自动修复:" |
| 59 | + echo "Try auto-fixing with:" |
60 | 60 | echo " ruff check --fix src/ tests/" |
61 | 61 | exit 1 |
62 | 62 | fi |
|
66 | 66 | # ============================================================================= |
67 | 67 | print_header "Step 2/4: Type Check" |
68 | 68 |
|
69 | | -echo "运行 MyPy 类型检查..." |
| 69 | +echo "Running MyPy type checks..." |
70 | 70 | if mypy src/; then |
71 | | - print_success "类型检查通过" |
| 71 | + print_success "Type check passed" |
72 | 72 | else |
73 | | - print_error "类型检查失败" |
| 73 | + print_error "Type check failed" |
74 | 74 | exit 1 |
75 | 75 | fi |
76 | 76 |
|
|
79 | 79 | # ============================================================================= |
80 | 80 | print_header "Step 3/4: Run Tests" |
81 | 81 |
|
82 | | -echo "运行测试并生成报告..." |
| 82 | +echo "Running tests and generating reports..." |
83 | 83 | if pytest --junitxml=pytest-report.xml --cov=deep_solutions --cov-report=xml --cov-report=term-missing; then |
84 | | - print_success "所有测试通过" |
| 84 | + print_success "All tests passed" |
85 | 85 | else |
86 | | - print_error "测试失败" |
| 86 | + print_error "Tests failed" |
87 | 87 | exit 1 |
88 | 88 | fi |
89 | 89 |
|
|
92 | 92 | # ============================================================================= |
93 | 93 | print_header "Step 4/4: Build Check" |
94 | 94 |
|
95 | | -echo "清理旧的构建产物..." |
| 95 | +echo "Cleaning previous build artifacts..." |
96 | 96 | rm -rf dist/ build/ *.egg-info |
97 | 97 |
|
98 | | -echo "构建包..." |
| 98 | +echo "Building package..." |
99 | 99 | if python -m build; then |
100 | | - print_success "包构建成功" |
| 100 | + print_success "Package build succeeded" |
101 | 101 | else |
102 | | - print_error "包构建失败" |
| 102 | + print_error "Package build failed" |
103 | 103 | exit 1 |
104 | 104 | fi |
105 | 105 |
|
106 | 106 | echo "" |
107 | | -echo "检查包..." |
| 107 | +echo "Checking distribution files..." |
108 | 108 | if twine check dist/*; then |
109 | | - print_success "包检查通过" |
| 109 | + print_success "Distribution check passed" |
110 | 110 | else |
111 | | - print_error "包检查失败" |
| 111 | + print_error "Distribution check failed" |
112 | 112 | exit 1 |
113 | 113 | fi |
114 | 114 |
|
115 | 115 | # ============================================================================= |
116 | 116 | # Summary |
117 | 117 | # ============================================================================= |
118 | | -print_header "总结" |
| 118 | +print_header "Summary" |
119 | 119 |
|
120 | | -echo -e "${GREEN}✓ 所有 CI 检查通过!${NC}" |
| 120 | +echo -e "${GREEN}✓ All CI checks passed!${NC}" |
121 | 121 | echo "" |
122 | | -echo "生成的文件:" |
123 | | -echo " - pytest-report.xml (测试报告)" |
124 | | -echo " - coverage.xml (覆盖率报告)" |
125 | | -echo " - dist/ (构建产物)" |
| 122 | +echo "Generated files:" |
| 123 | +echo " - pytest-report.xml (test report)" |
| 124 | +echo " - coverage.xml (coverage report)" |
| 125 | +echo " - dist/ (build artifacts)" |
126 | 126 | echo "" |
127 | | -print_success "代码已准备好创建 Pull Request" |
| 127 | +print_success "Code is ready to create a Pull Request" |
0 commit comments