ci: 修正 Gitee Go 流水线格式

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