diff --git a/.gitea/workflows/code-review.yml b/.gitea/workflows/code-review.yml new file mode 100644 index 000000000..d1b969449 --- /dev/null +++ b/.gitea/workflows/code-review.yml @@ -0,0 +1,58 @@ +name: AI Code Review + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +# 同一个 PR 只跑一个 review,新的取消旧的 +concurrency: + group: code-review-${{ gitea.repository }}-${{ gitea.event.pull_request.number }} + cancel-in-progress: true + +jobs: + code-review: + name: AI Code Review + runs-on: ubuntu-latest + # 跳过草稿 PR + if: ${{ !gitea.event.pull_request.draft }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + + - name: Run AI Code Review + env: + # Gitea 配置(自动从运行环境获取) + GITEA_API_URL: ${{ gitea.server_url }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + REPO_NAME: ${{ gitea.repository }} + PR_NUMBER: ${{ gitea.event.pull_request.number }} + # LLM 提供商: coze (扣子原生Bot) / openai (OpenAI兼容) + LLM_PROVIDER: "coze" + # 扣子模式配置(默认国内站 api.coze.cn) + LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + COZE_BOT_ID: ${{ secrets.COZE_BOT_ID }} + LLM_MODEL: ${{ secrets.LLM_MODEL }} + # 可选参数 + MAX_DIFF_CHARS: "30000" + LLM_TIMEOUT: "120" + run: | + python scripts/ci_code_review.py + # 审查脚本异常不影响 CI 通过 + continue-on-error: true