# Gitea Actions 门禁:与本地门禁同一套命令(规范见 patbond-doc # docs/development/git-workflow.md)。零外部 action / 零 GitHub 依赖, # 原因见 patbond-api 的 ci.yml 头注释。 # pip 与 PyPI 走腾讯云镜像,与 patbond-doc 的 mkdocs 安装同一策略。 # # 本仓是唯一存放 AI 服务商凭证的仓库,因此 Secret scan 是第一个 step, # 且先于任何依赖安装执行(ADR-021、ADR-023 §12)。 name: CI on: push: branches: [dev] pull_request: concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: ai-gates: runs-on: ubuntu-latest steps: - name: Checkout (manual) run: | git init -q . AUTH_URL=$(echo "${{ github.server_url }}" | sed "s#https://#https://oauth2:${{ github.token }}@#") git remote add origin "$AUTH_URL/${{ github.repository }}.git" git fetch -q --depth 1 origin "+${{ github.ref }}:refs/ci-head" git checkout -q refs/ci-head # 凭证防泄漏兜底(ADR-021):与本地 pre-commit 同一脚本、同一规则表, # 四仓副本内容同构,扫全部已跟踪文件(本次 push 变更的超集)。 - name: Secret scan run: sh scripts/check-secrets.sh --all - name: Set up Python run: | apt-get update -qq apt-get install -y -qq --no-install-recommends python3 python3-venv python3-pip python3 -m venv .venv echo "$PWD/.venv/bin" >> "$GITHUB_PATH" echo "PIP_INDEX_URL=https://mirrors.cloud.tencent.com/pypi/simple" >> "$GITHUB_ENV" - name: Install dependencies run: | python -m pip install -q --upgrade pip # requirements-dev.txt 落地前,门禁只装 lint/test 工具本身, # 使 CI 从建仓第一天就是绿的而非「等代码来了再配」。 if [ -f requirements-dev.txt ]; then pip install -q -r requirements-dev.txt else pip install -q ruff pytest fi if [ -f requirements.txt ]; then pip install -q -r requirements.txt; fi # 与本地门禁同一套命令。ruff 兼任 format 检查与 lint, # 对应 patbond-flutter 的 dart format + flutter analyze 两步。 - name: Gates run: | python --version ruff format --check . ruff check . # 尚无测试文件时 pytest 退出码为 5(no tests collected), # 该情形视为通过;真实失败仍会以非 0/5 退出。 pytest -q || [ $? -eq 5 ]