# CI 门禁(Gitea Actions,语法与 GitHub Actions 兼容) # # 三个 job: # 1. backend-tests —— pytest 全量(sqlite+aiosqlite,无外部服务依赖; # OCC 契约测试在无 pythonocc 的 pip 环境自动 skip) # 2. frontend-build —— npm ci + npm run build(含 vue-tsc -b 类型检查,D15 已修复) # 3. openapi-drift —— 用 OCC 环境重导出 openapi.json 与仓库版本比对, # 防止接口变更三件套(AGENTS §2)被遗漏导致前后端漂移 # # 运行前提:Gitea 实例启用 Actions 且注册了 runner; # `ubuntu-latest` label 需映射到带 node/git 的镜像(gitea runner 默认映射满足)。 # 已验证事实:pytest 与 openapi 导出均不依赖 .env(settings 惰性校验)。 name: CI on: push: branches: [main] pull_request: jobs: backend-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install dependencies # requirements.txt 自带阿里云 pip 镜像配置 run: pip install -r requirements.txt - name: Run tests run: python -m pytest tests/ -q frontend-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies working-directory: frontend run: npm ci - name: Type check and build working-directory: frontend run: npm run build openapi-drift: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Miniforge and pythonocc # pythonocc-core 仅经 conda-forge 提供(与 deploy/Dockerfile.moldinsight 同版本约束) # 默认走 TUNA 镜像(Gitea 服务器多为国内网络);海外环境可换回官方源 run: | wget -q https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh -O miniforge.sh bash miniforge.sh -b -p "$HOME/miniforge" "$HOME/miniforge/bin/conda" create -n ci -c https://mirrors.tuna.tsinghua.edu.cn/conda-forge -y python=3.12 pythonocc-core=7.9.0 - name: Install python dependencies run: "$HOME/miniforge/envs/ci/bin/pip" install -r requirements.txt - name: Export openapi.json and compare with committed version run: | "$HOME/miniforge/envs/ci/bin/python" -c "import sys; sys.path.insert(0, 'src'); from entrypoints.unified import app; import json; print(json.dumps(app.openapi(), ensure_ascii=False, indent=2))" > /tmp/openapi.json git diff --exit-code --no-index /tmp/openapi.json openapi.json || { echo "::error::openapi.json 与代码不一致——请按 docs/API_CONTRACT.md §4 重导出并执行 npm run gen:api" exit 1 }