ci: 修正 Gitee Go 流水线格式
This commit is contained in:
1 parent
aae31a48bd
commit
36d1470b68
1 file changed
+85
-101
+85
-101
@@ -1,5 +1,4 @@
|
||||
# Gitee Go CI 流水线
|
||||
# 自动在 push/PR 到 master 时触发
|
||||
|
||||
triggers:
|
||||
push:
|
||||
@@ -17,117 +16,102 @@ stages:
|
||||
- structure
|
||||
|
||||
jobs:
|
||||
# ── 代码检查 ──
|
||||
py-compile:
|
||||
name: 语法检查
|
||||
stage: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: py_compile 语法检查
|
||||
run: |
|
||||
python -c "
|
||||
import py_compile, os, sys
|
||||
errors = 0
|
||||
for root, dirs, files in os.walk('.'):
|
||||
dirs[:] = [d for d in dirs if d not in {'.git', '__pycache__', 'node_modules', 'embedded_python'}]
|
||||
for f in files:
|
||||
if f.endswith('.py'):
|
||||
path = os.path.join(root, f)
|
||||
try:
|
||||
py_compile.compile(path, doraise=True)
|
||||
except py_compile.PyCompileError as e:
|
||||
print(f'ERROR: {e}')
|
||||
errors += 1
|
||||
if errors:
|
||||
print(f'\n{errors} 个文件有语法错误')
|
||||
sys.exit(1)
|
||||
print('所有文件语法正确')
|
||||
"
|
||||
image: python:3.12
|
||||
script:
|
||||
- python -c "
|
||||
import py_compile, os, sys;
|
||||
errors = 0;
|
||||
for root, dirs, files in os.walk('.'):
|
||||
dirs[:] = [d for d in dirs if d not in {'.git', '__pycache__', 'node_modules', 'embedded_python'}];
|
||||
for f in files:
|
||||
if f.endswith('.py'):
|
||||
path = os.path.join(root, f);
|
||||
try:
|
||||
py_compile.compile(path, doraise=True);
|
||||
except py_compile.PyCompileError as e:
|
||||
print(f'ERROR: {e}');
|
||||
errors += 1;
|
||||
if errors:
|
||||
print(f'{errors} 个文件有语法错误');
|
||||
sys.exit(1);
|
||||
print('所有文件语法正确')
|
||||
"
|
||||
|
||||
ruff-lint:
|
||||
name: Ruff lint
|
||||
stage: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: 安装 ruff
|
||||
run: pip install ruff
|
||||
- name: Ruff 检查
|
||||
run: ruff check . --select E,F,W --ignore E501,E402 --exclude .git,__pycache__,embedded_python
|
||||
image: python:3.12
|
||||
script:
|
||||
- pip install ruff -q
|
||||
- ruff check . --select E,F,W --ignore E501,E402 --exclude .git,__pycache__,embedded_python
|
||||
|
||||
# ── 插件测试 ──
|
||||
pytest:
|
||||
name: 插件测试 (Python ${{ matrix.python-version }})
|
||||
pytest-310:
|
||||
name: 插件测试 (Python 3.10)
|
||||
stage: test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11", "3.12"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: 安装依赖
|
||||
run: pip install pytest colorama
|
||||
- name: 运行测试
|
||||
run: pytest tests/ -v --tb=short
|
||||
image: python:3.10
|
||||
script:
|
||||
- pip install pytest colorama -q
|
||||
- pytest tests/ -v --tb=short
|
||||
|
||||
pytest-311:
|
||||
name: 插件测试 (Python 3.11)
|
||||
stage: test
|
||||
image: python:3.11
|
||||
script:
|
||||
- pip install pytest colorama -q
|
||||
- pytest tests/ -v --tb=short
|
||||
|
||||
pytest-312:
|
||||
name: 插件测试 (Python 3.12)
|
||||
stage: test
|
||||
image: python:3.12
|
||||
script:
|
||||
- pip install pytest colorama -q
|
||||
- pytest tests/ -v --tb=short
|
||||
|
||||
# ── 项目结构检查 ──
|
||||
structure:
|
||||
name: 项目结构检查
|
||||
stage: structure
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: 检查必要文件
|
||||
run: |
|
||||
echo "检查项目结构..."
|
||||
files=(
|
||||
"ai_cli.py"
|
||||
"launcher.py"
|
||||
"xcli_core/cli_core.py"
|
||||
"xcli_core/cli_base.py"
|
||||
"xcli_core/config.py"
|
||||
"xcli_core/constants.py"
|
||||
"ai_engines/ollama_engine.py"
|
||||
"ai_engines/openai_engine.py"
|
||||
"plugins/code_editor.py"
|
||||
"plugins/cmd_executor.py"
|
||||
"plugins/file_manager.py"
|
||||
"plugins/auto_engineer.py"
|
||||
)
|
||||
missing=0
|
||||
for f in "${files[@]}"; do
|
||||
if [ -f "$f" ]; then
|
||||
echo " ✓ $f"
|
||||
else
|
||||
echo " ✗ $f (缺失!)"
|
||||
missing=$((missing + 1))
|
||||
fi
|
||||
done
|
||||
if [ $missing -gt 0 ]; then
|
||||
echo "\n${missing} 个文件缺失"
|
||||
exit 1
|
||||
image: python:3.12
|
||||
script:
|
||||
- echo "检查项目结构..."
|
||||
- |
|
||||
files=(
|
||||
"ai_cli.py"
|
||||
"launcher.py"
|
||||
"xcli_core/cli_core.py"
|
||||
"xcli_core/cli_base.py"
|
||||
"xcli_core/config.py"
|
||||
"xcli_core/constants.py"
|
||||
"ai_engines/ollama_engine.py"
|
||||
"ai_engines/openai_engine.py"
|
||||
"plugins/code_editor.py"
|
||||
"plugins/cmd_executor.py"
|
||||
"plugins/file_manager.py"
|
||||
"plugins/auto_engineer.py"
|
||||
)
|
||||
missing=0
|
||||
for f in "${files[@]}"; do
|
||||
if [ -f "$f" ]; then
|
||||
echo " ✓ $f"
|
||||
else
|
||||
echo " ✗ $f (缺失!)"
|
||||
missing=$((missing + 1))
|
||||
fi
|
||||
echo "\n项目结构完整"
|
||||
|
||||
- name: 检查无重复引擎
|
||||
run: |
|
||||
engines=$(ls ai_engines/*_engine.py 2>/dev/null | wc -l)
|
||||
echo "AI 引擎数量: $engines"
|
||||
if [ "$engines" -gt 2 ]; then
|
||||
echo "警告: 引擎数量超过 2 个"
|
||||
exit 1
|
||||
fi
|
||||
echo "引擎数量正常"
|
||||
done
|
||||
if [ $missing -gt 0 ]; then
|
||||
echo "${missing} 个文件缺失"
|
||||
exit 1
|
||||
fi
|
||||
echo "项目结构完整"
|
||||
- |
|
||||
engines=$(ls ai_engines/*_engine.py 2>/dev/null | wc -l)
|
||||
echo "AI 引擎数量: $engines"
|
||||
if [ "$engines" -gt 2 ]; then
|
||||
echo "警告: 引擎数量超过 2 个"
|
||||
exit 1
|
||||
fi
|
||||
echo "引擎数量正常"
|
||||
Reference in new issue
Block a user