同步新增接口的 OpenAPI 契约基线 #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| # 项目要求提交按切片依次推送。保留每个提交的完整检查结果,避免后一 | |
| # 次推送把前一轮标成 cancelled,导致提交列表出现并非测试失败的红叉。 | |
| cancel-in-progress: false | |
| jobs: | |
| web: | |
| name: Web typecheck / lint / build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| # 按 ADR-0002:统一在仓库根安装。apps/web 的 tsconfig extends | |
| # @openmathmodel/config(workspace 包),子目录单独安装解析不到它。 | |
| - run: npm ci | |
| - run: npm run check --workspace @openmathmodel/web | |
| - run: npm run build --workspace @openmathmodel/web | |
| python: | |
| name: Python syntax + contracts gate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Compile shipped Python sources | |
| run: | | |
| python -m compileall -q \ | |
| datasets/recipes \ | |
| packages/contracts \ | |
| agents/core/src \ | |
| agents/evals/src \ | |
| agents/harness/src \ | |
| agents/skills/src \ | |
| agents/tools/src \ | |
| backend/api/omm_api \ | |
| backend/worker/src | |
| - name: Contracts gate (self-check + compatibility + generated models, activates once contracts land) | |
| run: | | |
| if [ -f packages/contracts/validate.py ]; then | |
| pip install -r packages/contracts/requirements-dev.txt | |
| python packages/contracts/validate.py | |
| python packages/contracts/check_compat.py | |
| python packages/contracts/scripts/generate_python.py --check | |
| python packages/contracts/scripts/generate_python.py --verify | |
| else | |
| echo "contracts not present on this ref; skipped" | |
| fi | |
| - name: API package + OpenAPI gate (activates once backend/api lands) | |
| run: | | |
| if [ -f backend/api/pyproject.toml ]; then | |
| # backend/api 依赖 omm-agent-skills / omm-agent-tools(真实技能节点与 | |
| # 实验沙箱),skills 又依赖 omm-agent-harness(Loop 引擎),它们只存在 | |
| # 于本仓库,必须与 contracts/core 一样以可编辑方式一并安装,否则 pip | |
| # 会去 PyPI 找。 | |
| pip install -e packages/contracts -e agents/core -e agents/harness -e agents/skills -e agents/tools -e "backend/api[dev]" | |
| python -c "import omm_api; from omm_api.main import create_app; assert callable(create_app)" | |
| python packages/contracts/scripts/export_openapi.py --check | |
| else | |
| echo "backend/api not present on this ref; skipped" | |
| fi | |
| - name: Agent package import gate (activates once agents/core lands) | |
| run: | | |
| if [ -f agents/core/pyproject.toml ]; then | |
| pip install -e agents/core -e agents/harness -e agents/tools -e agents/skills -e backend/worker -e agents/evals | |
| python -c "import omm_agent_core, omm_agent_harness, omm_agent_tools, omm_agent_skills, omm_worker, omm_agent_evals" | |
| else | |
| echo "agent runtime not present on this ref; skipped" | |
| fi | |
| api-postgres: | |
| name: API tests on PostgreSQL | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| # 与 infra/docker/compose.dev.yaml 同镜像同版本:CI 验证的就是部署要用的底座 | |
| image: pgvector/pgvector:pg16 | |
| env: | |
| POSTGRES_USER: openmathmodel | |
| POSTGRES_PASSWORD: openmathmodel-dev | |
| POSTGRES_DB: openmathmodel | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U openmathmodel -d openmathmodel" | |
| --health-interval 5s | |
| --health-timeout 3s | |
| --health-retries 20 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| # 与 python job 相同的可编辑安装(backend/api 依赖本仓库的 contracts/core/harness/skills/tools) | |
| - name: Install backend/api with workspace deps | |
| run: pip install -e packages/contracts -e agents/core -e agents/harness -e agents/skills -e agents/tools -e "backend/api[dev]" | |
| # 迁移验证用独立数据库:alembic_version 等痕迹不进测试库,两条验证互不干扰 | |
| - name: Alembic upgrade head on real PostgreSQL | |
| working-directory: backend/api | |
| env: | |
| OMM_DATABASE_URL: postgresql+psycopg://openmathmodel:openmathmodel-dev@127.0.0.1:5432/omm_migrations | |
| run: | | |
| python -c "import psycopg; psycopg.connect('postgresql://openmathmodel:openmathmodel-dev@127.0.0.1:5432/postgres', autocommit=True).execute('CREATE DATABASE omm_migrations')" | |
| python -m alembic upgrade head | |
| - name: PostgreSQL connectivity smoke | |
| run: >- | |
| python -c "import psycopg; | |
| conn=psycopg.connect('postgresql://openmathmodel:openmathmodel-dev@127.0.0.1:5432/openmathmodel'); | |
| assert conn.execute('SELECT 1').fetchone() == (1,); | |
| conn.close()" | |
| contracts-ts: | |
| name: Contracts generated TS types | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - name: Generated types up to date (activates once workspaces land) | |
| run: | | |
| if [ -f package-lock.json ] && [ -f packages/contracts/package.json ]; then | |
| npm ci | |
| npm run check --workspace @openmathmodel/contracts | |
| else | |
| echo "contracts workspace not present on this ref; skipped" | |
| fi |