fix: 司马懿 Review M1-M3 修复
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

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
This commit is contained in:
cfdaily
2026-06-06 17:23:29 +08:00
parent db184c32b5
commit 163e778096
3 changed files with 143 additions and 17 deletions
+20 -10
View File
@@ -1,8 +1,10 @@
# CI 管道 — moziplus v2.0
#
# 触发条件:
# - push(非 main 分支)
# - pull_requestopened, synchronize
# - push(非 main 分支)→ 快速门控(lint + unit test
# - pull_requestopened, synchronize→ 同上
#
# 注意:main 分支的 CI 由 deploy.yml 负责(完整 CI + 部署)
#
# Gitea v1.23.4 限制注意:
# - 不支持 failure() 表达式,用 always() + shell 条件判断替代
@@ -23,22 +25,22 @@ on:
jobs:
# ── Job 1: Lint ──────────────────────────────────────
lint:
runs-on: ubuntu-latest
runs-on: macos-arm64
steps:
- uses: actions/checkout@v4
- name: Setup Python
run: |
python3 -m venv .venv
.venv/bin/pip install --quiet flake8
.venv/bin/pip install --quiet ruff
- name: Lint with flake8
- name: Lint with ruff
run: |
.venv/bin/flake8 src/ --max-line-length=120 --extend-ignore=E501
.venv/bin/ruff check src/
# ── Job 2: Test ──────────────────────────────────────
test:
runs-on: ubuntu-latest
runs-on: macos-arm64
needs: lint
steps:
- uses: actions/checkout@v4
@@ -46,7 +48,7 @@ jobs:
- name: Setup Python
run: |
python3 -m venv .venv
.venv/bin/pip install --quiet -r requirements.txt
.venv/bin/pip install --quiet -e ".[dev]"
- name: Run tests (exclude E2E)
run: |
@@ -55,7 +57,7 @@ jobs:
# ── Job 3: CI 失败通知 ───────────────────────────────
# v1.23 不支持 failure(),用 always() + shell 检查 commit status 替代
notify-on-failure:
runs-on: ubuntu-latest
runs-on: macos-arm64
needs: [lint, test]
if: always()
steps:
@@ -85,7 +87,15 @@ jobs:
|| echo "Failed to post PR comment"
echo "PR comment posted."
else
echo "Not a PR event, skipping PR comment."
# 非 PR 事件(push 分支),创建 Issue 通知
BRANCH="${{ gitea.ref_name }}"
curl -sf -X POST \
-H "Authorization: token $CI_TOKEN" \
-H "Content-Type: application/json" \
"${{ gitea.api_url }}/repos/${{ gitea.repository }}/issues" \
-d "{\"title\": \"🔴 CI 失败: branch $BRANCH\", \"body\": \"非 main 分支 push CI 失败。\\n\\n触发 commit: \`${{ gitea.sha }}\`\\n分支: $BRANCH\\n\\n请检查 CI 日志并修复。\", \"labels\": [\"bug\"]}" \
|| echo "Failed to create issue"
echo "Issue created for branch push CI failure."
fi
else
echo "CI passed, no notification needed."