Files
patbond-ai/.gitea/workflows/ci.yml
T
lixi 6990709124
CI / ai-gates (push) Successful in 47s
chore: 建仓门禁四件套——CI、防泄漏脚本与钩子、gitignore、职责边界 README
patbond-ai 纳入发布语义(ADR-023 §12)。本仓是四仓中唯一直接持有 AI
服务商凭证的仓库,因此不得成为唯一没有防泄漏门禁的仓库——建仓即配齐,
不等代码落地。

- .gitea/workflows/ci.yml:ai-gates 作业,push(dev) + pull_request 双触发,
  与另三仓同构。Secret scan 为第一个 step 且先于任何依赖安装。
  pip 走腾讯云镜像(与 patbond-doc 装 mkdocs 同一策略)。
  门禁命令 ruff format --check / ruff check / pytest,对应 flutter 仓的
  dart format + analyze + test 三步。requirements*.txt 落地前只装工具本身,
  使 CI 自建仓第一天即为绿;pytest 无测试时退出码 5 视为通过。
- scripts/check-secrets.sh:四仓同构副本,md5 640994c12bfa78b4512e872d709ed685。
  已覆盖 AI 服务商密钥形态(sk-ant- / sk- / sk-proj- / sk-svcacct-)与
  api_key/auth_token 实值赋值——本仓正是这些规则的主要适用对象。
- scripts/hooks/pre-commit:与另三仓同构。四仓 core.hooksPath 均已启用,
  ADR-023 §12 登记的「防泄漏第一层从未生效」至此闭环。
  实测验证:含 5 种真实凭证形态的 .env 夹具被钩子拦下,提交未产生。
- .gitignore:Python 产物与工具缓存;凭证载体(.env / credentials* / *.pem
  / *.key)一律排除,占位样例走 .env.sample(对应脚本的 DENY_NAME_OK)。
- README.md:职责边界(不访问数据库、不持有对象存储凭证、对上游同步异步
  一律对外呈现为异步)、与 Java 侧的接口约定(REST 非 gRPC、独立
  openapi-internal.yaml、服务身份 JWT 独立密钥对、请求体不含 userId)、
  本地门禁命令与凭证纪律。细节以 ADR-023 为准。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 16:42:34 +08:00

62 lines
2.5 KiB
YAML
Raw 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.
# 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 ]