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
+45 -61
+45 -61
View File
@@ -1,5 +1,4 @@
# Gitee Go CI 流水线 # Gitee Go CI 流水线
# 自动在 push/PR 到 master 时触发
triggers: triggers:
push: push:
@@ -17,82 +16,69 @@ 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"
- name: py_compile 语法检查
run: |
python -c "
import py_compile, os, sys
errors = 0
for root, dirs, files in os.walk('.'): for root, dirs, files in os.walk('.'):
dirs[:] = [d for d in dirs if d not in {'.git', '__pycache__', 'node_modules', 'embedded_python'}] dirs[:] = [d for d in dirs if d not in {'.git', '__pycache__', 'node_modules', 'embedded_python'}];
for f in files: for f in files:
if f.endswith('.py'): if f.endswith('.py'):
path = os.path.join(root, f) path = os.path.join(root, f);
try: try:
py_compile.compile(path, doraise=True) py_compile.compile(path, doraise=True);
except py_compile.PyCompileError as e: except py_compile.PyCompileError as e:
print(f'ERROR: {e}') print(f'ERROR: {e}');
errors += 1 errors += 1;
if errors: if errors:
print(f'\n{errors} 个文件有语法错误') print(f'{errors} 个文件有语法错误');
sys.exit(1) sys.exit(1);
print('所有文件语法正确') 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:
python-version: "3.12"
- name: 检查必要文件
run: |
echo "检查项目结构..."
files=( files=(
"ai_cli.py" "ai_cli.py"
"launcher.py" "launcher.py"
@@ -117,13 +103,11 @@ jobs:
fi fi
done done
if [ $missing -gt 0 ]; then if [ $missing -gt 0 ]; then
echo "\n${missing} 个文件缺失" echo "${missing} 个文件缺失"
exit 1 exit 1
fi fi
echo "\n项目结构完整" echo "项目结构完整"
- |
- name: 检查无重复引擎
run: |
engines=$(ls ai_engines/*_engine.py 2>/dev/null | wc -l) engines=$(ls ai_engines/*_engine.py 2>/dev/null | wc -l)
echo "AI 引擎数量: $engines" echo "AI 引擎数量: $engines"
if [ "$engines" -gt 2 ]; then if [ "$engines" -gt 2 ]; then