docs: require frontend codegen alongside the OpenAPI export in the gates
The local gate list only covered `scripts/export_openapi.py` + a clean
`openapi/` diff, but `frontend/src/api/schema.d.ts` is generated from that JSON
and CI re-runs `npm run codegen` with `git diff --exit-code`. d07a083 changed a
route docstring, refreshed openapi.json, and skipped codegen — local green,
remote red on a one-line comment diff. Spell out both steps and note that route
docstrings feed the OpenAPI description too.
Also add AGENTS.md as a symlink to CLAUDE.md so other agent tooling picks up
the same contract.
This commit is contained in:
@@ -79,6 +79,23 @@ python scripts/export_openapi.py && git diff --exit-code openapi/ # 改了路
|
|||||||
前端任务(M2)在 `frontend/` 下另跑 `npm run lint && npm run typecheck && npm run test && npm run build`(详见 m2 文档 §8)。
|
前端任务(M2)在 `frontend/` 下另跑 `npm run lint && npm run typecheck && npm run test && npm run build`(详见 m2 文档 §8)。
|
||||||
**不过闸门就不算完成**,不得跳过、不得留红给下一轮。
|
**不过闸门就不算完成**,不得跳过、不得留红给下一轮。
|
||||||
|
|
||||||
|
#### API 契约同步:`openapi/` 与 `schema.d.ts` 是**两步**(v1.4.0 后教训)
|
||||||
|
|
||||||
|
**只跑 `export_openapi.py` 不够。** 前端的 `frontend/src/api/schema.d.ts` 是由 `openapi/openapi.json` 二次生成的,CI(`.github/workflows/frontend.yml` 的 *Check codegen is in sync*)会重跑 codegen 并 `git diff --exit-code src/api/schema.d.ts`。漏了第二步 → 本地闸门全绿、远端 CI 红。真出过:`d07a083` 改了 `/api/energy/prices` 的 docstring 并同步了 `openapi.json`,但没重跑 codegen,只差一行注释就把 CI 挂了。
|
||||||
|
|
||||||
|
所以**只要动了路由 / Pydantic schema / 路由 docstring**(docstring 也会进 OpenAPI description!),两步都要跑,两个产物都要入库:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1) 后端契约
|
||||||
|
python scripts/export_openapi.py && git diff --exit-code openapi/
|
||||||
|
# 2) 前端类型(在 frontend/ 下)
|
||||||
|
npm run codegen && git diff --exit-code src/api/schema.d.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
- 判据:`git diff --exit-code openapi/` 有输出 → **必然**还要跑一次 `npm run codegen`。
|
||||||
|
- 反过来也成立:`schema.d.ts` 不要手改,它是生成物。
|
||||||
|
- Reviewer 审"动了路由 / schema / 路由 docstring"类任务时,把**这两个产物是否都已重新生成并入库**当作 acceptance 的一部分。
|
||||||
|
|
||||||
### 构建上下文完整性(M1 Dockerfile 教训)
|
### 构建上下文完整性(M1 Dockerfile 教训)
|
||||||
|
|
||||||
`docker build` **不在 pytest/ruff 闸门里**——M1 删了 `alembic_location/poo` 后忘了同步 `Dockerfile` 的 `COPY`,单元闸门全绿却把坏掉的镜像构建一路漏到 release tag。所以:
|
`docker build` **不在 pytest/ruff 闸门里**——M1 删了 `alembic_location/poo` 后忘了同步 `Dockerfile` 的 `COPY`,单元闸门全绿却把坏掉的镜像构建一路漏到 release tag。所以:
|
||||||
|
|||||||
Reference in New Issue
Block a user