Files
Yaojia Wang a02c6b6e4f test: 接入覆盖率工具并在 CI 强制 ≥80% 门禁
后端: 加 pytest-cov + [tool.coverage] 配置, pytest --cov-fail-under=80 (基线~88%)。
前端: 加 @vitest/coverage-v8, vitest.config.ts 设 80% 阈值, 新增 test:coverage 脚本 (基线~93%)。
前端覆盖范围限定 lib/** 纯逻辑层; hooks(use*.ts)待 jsdom 测试栈接入后纳入。
CI backend/frontend job 改跑覆盖率门禁命令。CLAUDE.md 同步 DoD 与 Toolchain。
2026-06-26 21:11:57 +02:00

91 lines
3.1 KiB
YAML
Raw Permalink 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.

name: CI
on:
push:
branches: [main]
pull_request:
jobs:
backend:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: writer
POSTGRES_PASSWORD: writer
POSTGRES_DB: writer
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U writer"
--health-interval 5s --health-timeout 3s --health-retries 10
env:
DATABASE_URL: postgresql+asyncpg://writer:writer@localhost:5432/writer
DATABASE_URL_SYNC: postgresql+psycopg://writer:writer@localhost:5432/writer
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv sync
- name: ruff
run: uv run ruff check .
- name: mypy
run: uv run mypy packages apps
- name: alembic upgrade + drift check
run: |
uv run alembic upgrade head
uv run alembic check
- name: pytest + coverage gate (>=80%)
run: uv run pytest -q --cov --cov-report=term-missing --cov-fail-under=80
# 打包冒烟:构建 ww-agents wheel → 装进裸 venv → import ww_agents 并断言 SPECS。
# 证明 prompts/*.md 随 wheel 分发(源码树 pytest 测不出此漏带——见
# docs/design/prompt-management.md §4/§6#16。load_prompt 在 import 期读盘,
# 若 .md 漏带则抛 PromptNotFoundError本步即红。
agents-wheel-smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: build ww-agents wheel
run: uv build --wheel packages/agents --out-dir dist
- name: install into bare venv + import SPECS
run: |
uv venv .smoke-venv
# 工作区兄弟包按路径装解析其第三方依赖structlog 是 ww-llm-gateway
# import 期用到但未显式声明的传递依赖,显式补上以保证裸装可 import。
uv pip install --python .smoke-venv \
"ww-shared @ ./packages/shared" \
"ww-config @ ./packages/config" \
"ww-db @ ./packages/db" \
"ww-llm-gateway @ ./packages/llm_gateway" \
structlog
# 被测产物:装 wheel 本身,--no-deps 确保 import 的是它而非源码树。
uv pip install --python .smoke-venv --no-deps dist/ww_agents-*.whl
.smoke-venv/bin/python -c "import ww_agents; assert ww_agents.SPECS"
frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv sync
- uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack enable
- name: install
working-directory: apps/web
run: pnpm install --frozen-lockfile
- name: gen api types
working-directory: apps/web
run: pnpm gen:api
- name: lint
working-directory: apps/web
run: pnpm lint
- name: typecheck
working-directory: apps/web
run: pnpm typecheck
- name: test + coverage gate (>=80%)
working-directory: apps/web
run: pnpm test:coverage