Files
cfdaily 163e778096
CI / lint (push) Failing after -3m47s
CI / test (push) Has been skipped
CI / lint (pull_request) Failing after -3m57s
CI / test (pull_request) Has been skipped
CI / notify-on-failure (push) Successful in -4m3s
CI / notify-on-failure (pull_request) Successful in -4m3s
fix: 司马懿 Review M1-M3 修复
M1: runs-on ubuntu-latest → macos-arm64(匹配 act-runner label)
M2: flake8 → ruff(对齐设计文档 §8.4)
M3: ci.yml 排除 main 改为注释说明(main 由 deploy.yml 负责)
S1: deploy.yml 加 coverage report step
S3: pip install -r requirements.txt → -e .[dev]
S4: ci.yml 非 PR 事件 CI 失败改创建 Issue
2026-06-06 17:23:29 +08:00

107 lines
3.3 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# E2E 测试 — moziplus v2.0
#
# 触发条件:
# - workflow_dispatch(手动触发)
#
# 注意:E2E 在 CI 隔离环境中运行(独立 venv + 临时 SQLite + 临时端口 8084),
# 不污染生产环境。
# Agent spawn 走生产 openclaw(全局单例,无法隔离),
# 测试 case 用 UUID 前缀标识。
#
# Gitea v1.23.4 限制注意:
# - 不支持 workflow_run 触发器(无法直接 needs 另一个 workflow 的 job
# - 此 workflow 需手动触发或在 deploy.yml 中以 needs 方式调用
# - 实际使用时可能需要合并到 deploy.yml 作为同一个 workflow 的 job
# - 或依赖 daemon Webhook 监听 deploy 完成事件后通过 API 触发
name: E2E Tests
on:
workflow_dispatch:
# 手动触发,可选参数
inputs:
test_filter:
description: 'Test filter (e.g. tests/e2e/test_api.py)'
required: false
default: 'tests/e2e/'
jobs:
e2e:
runs-on: macos-arm64
steps:
- uses: actions/checkout@v4
- name: Setup isolated environment
run: |
# 创建独立 venv
python3 -m venv /tmp/e2e-venv
/tmp/e2e-venv/bin/pip install --quiet -e ".[dev]"
# 创建临时数据目录
mkdir -p /tmp/e2e-test-projects
mkdir -p /tmp/e2e-test-data
echo "Isolated environment ready:"
echo " venv: /tmp/e2e-venv"
echo " projects dir: /tmp/e2e-test-projects"
echo " data dir: /tmp/e2e-test-data"
echo " port: 8084 (avoid conflict with production 8083)"
- name: Start test service
env:
SANGUO_PROJECTS_DIR: /tmp/e2e-test-projects
BLACKBOARD_ROOT: /tmp/e2e-test-data
PORT: "8084"
run: |
# 启动 FastAPI 服务在临时端口
/tmp/e2e-venv/bin/python -m uvicorn src.main:app --host 0.0.0.0 --port 8084 &
SERVER_PID=$!
# 等待服务就绪(最多 30 秒)
for i in $(seq 1 30); do
if curl -sf http://localhost:8084/api/health > /dev/null 2>&1; then
echo "Test service ready (PID: $SERVER_PID)"
break
fi
if [ $i -eq 30 ]; then
echo "ERROR: Test service failed to start within 30 seconds"
kill $SERVER_PID 2>/dev/null
exit 1
fi
sleep 1
done
echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
- name: Run E2E tests
env:
SANGUO_PROJECTS_DIR: /tmp/e2e-test-projects
BLACKBOARD_ROOT: /tmp/e2e-test-data
RUN_INTEGRATION: "1"
BASE_URL: "http://localhost:8084"
run: |
TEST_PATH="${{ gitea.event.inputs.test_filter }}"
if [ -z "$TEST_PATH" ]; then
TEST_PATH="tests/e2e/"
fi
/tmp/e2e-venv/bin/pytest "$TEST_PATH" -x -q \
--tb=short \
-p no:randomly
- name: Stop test service
if: always()
run: |
if [ -n "$SERVER_PID" ]; then
kill $SERVER_PID 2>/dev/null || true
echo "Test service stopped."
fi
- name: Cleanup
if: always()
run: |
rm -rf /tmp/e2e-venv
rm -rf /tmp/e2e-test-projects
rm -rf /tmp/e2e-test-data
echo "Isolated environment cleaned up."