-
Notifications
You must be signed in to change notification settings - Fork 6
192 lines (152 loc) · 5.94 KB
/
ci-basic.yml
File metadata and controls
192 lines (152 loc) · 5.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: CI - Basic Checks
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
jobs:
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync
- name: Check code formatting
run: |
uv run ruff format --check . || echo "⚠️ Code formatting issues found (not blocking CI)"
- name: Lint with ruff
run: |
echo "📊 Running ruff lint check..."
uv run ruff check . --statistics || echo "⚠️ Linting issues found (not blocking CI)"
echo "✅ Lint check completed (informational only)"
validate-config:
name: Validate Configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check environment example completeness
run: |
echo "🔍 Validating env.example..."
# 必须存在的配置项
required_vars=(
"LLM_API_KEY"
"LLM_BASE_URL"
"LLM_MODEL"
"EMBEDDING_API_KEY"
"EMBEDDING_BASE_URL"
"EMBEDDING_MODEL"
"EMBEDDING_DIM"
"MINERU_MODE"
"MINERU_API_TOKEN"
"TASK_STORE_STORAGE"
"TENANT_CONFIG_STORAGE"
)
missing_vars=()
for var in "${required_vars[@]}"; do
if ! grep -q "^$var=" env.example; then
missing_vars+=("$var")
fi
done
if [ ${#missing_vars[@]} -gt 0 ]; then
echo "❌ Missing required variables in env.example:"
printf '%s\n' "${missing_vars[@]}"
exit 1
fi
echo "✅ env.example contains all required variables"
- name: Validate TASK_STORE_STORAGE documentation
run: |
echo "🔍 Checking TASK_STORE_STORAGE documentation..."
# 验证 env.example 中变量定义之前是否有正确的注释说明
# 使用 -B 7 查找变量定义之前的 7 行(覆盖所有文档注释)
# 检查文档中是否包含 memory 和 redis 两种存储方式的说明
doc_content=$(grep -B 7 "^TASK_STORE_STORAGE=" env.example)
if ! echo "$doc_content" | grep -q "memory"; then
echo "❌ TASK_STORE_STORAGE documentation missing 'memory' option"
exit 1
fi
if ! echo "$doc_content" | grep -q "redis"; then
echo "❌ TASK_STORE_STORAGE documentation missing 'redis' option"
exit 1
fi
echo "✅ TASK_STORE_STORAGE documented correctly (both memory and redis options)"
- name: Check Docker Compose syntax
run: |
echo "🔍 Validating Docker Compose files..."
# 创建临时 .env 文件(Docker Compose 会尝试加载它)
cp env.example .env
# 验证开发环境配置
docker compose -f docker-compose.dev.yml config > /dev/null
echo "✅ docker-compose.dev.yml is valid"
# 验证生产环境配置
docker compose -f docker-compose.yml config > /dev/null
echo "✅ docker-compose.yml is valid"
- name: Check TASK_STORE_STORAGE in docker-compose
run: |
echo "🔍 Checking TASK_STORE_STORAGE in Docker Compose..."
# 验证开发环境包含 TASK_STORE_STORAGE
if ! grep -q "TASK_STORE_STORAGE" docker-compose.dev.yml; then
echo "❌ TASK_STORE_STORAGE missing in docker-compose.dev.yml"
exit 1
fi
# 验证生产环境包含 TASK_STORE_STORAGE
if ! grep -q "TASK_STORE_STORAGE" docker-compose.yml; then
echo "❌ TASK_STORE_STORAGE missing in docker-compose.yml"
exit 1
fi
echo "✅ TASK_STORE_STORAGE configured in both docker-compose files"
- name: Deployment pre-check simulation
run: |
echo "🔍 Simulating deployment pre-check..."
# 创建模拟 .env 文件
cp env.example .env
# 填充必要的测试值
sed -i 's/your_mineru_api_token_here/test_token_12345/g' .env
sed -i 's/your_llm_api_key_here/test_key_12345/g' .env
sed -i 's/your_embedding_api_key_here/test_key_12345/g' .env
sed -i 's/your_rerank_api_key_here/test_key_12345/g' .env
sed -i 's/your_deepseek_ocr_api_key_here/test_key_12345/g' .env
# 确保 MINERU_MODE 为 remote
sed -i 's/^MINERU_MODE=.*/MINERU_MODE=remote/' .env
echo "✅ Environment simulation created"
# 运行部署检查脚本(跳过网络连通性测试)
echo "📋 Would run: bash scripts/check-deployment.sh"
echo "⚠️ Skipping network connectivity test in CI"
validate-scripts:
name: Validate Shell Scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Check shell scripts
run: |
echo "🔍 Running shellcheck on all .sh files..."
# 查找所有 .sh 文件
shfiles=$(find . -name "*.sh" -not -path "./.git/*" -not -path "./.venv/*")
if [ -z "$shfiles" ]; then
echo "⚠️ No shell scripts found"
exit 0
fi
failed=0
for file in $shfiles; do
echo "Checking $file..."
# 排除 SC1091 (source .env 文件不存在的警告)
if ! shellcheck -x -e SC1091 "$file"; then
failed=1
fi
done
if [ $failed -eq 1 ]; then
echo "❌ Some shell scripts have issues"
exit 1
fi
echo "✅ All shell scripts passed shellcheck"