加入 type-sync-check.yaml: - 觸發: apps/api/src/models/** 變更時 - 行為: 重新生成 TypeScript,檢查是否有差異 - 失敗: 提示開發者執行 pnpm generate 設計決策: - 採用「驗證模式」而非「自動生成模式」 - 避免 CI 提交造成的循環觸發 - 符合 GitOps 原則 (所有變更來自開發者) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
76 lines
2.0 KiB
YAML
76 lines
2.0 KiB
YAML
# =============================================================================
|
|
# AWOOOI Type Sync Check (Phase 14.3 #99)
|
|
# =============================================================================
|
|
# 驗證 Pydantic 模型與 TypeScript 型別是否同步
|
|
#
|
|
# 觸發條件: apps/api/src/models/** 變更
|
|
# 失敗時: 開發者需執行 `pnpm --filter @awoooi/shared-types generate`
|
|
#
|
|
# 2026-03-31 Claude Code (Phase 14.3)
|
|
|
|
name: Type Sync Check
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'apps/api/src/models/**'
|
|
- 'packages/shared-types/**'
|
|
- 'scripts/generate-schemas.py'
|
|
pull_request:
|
|
paths:
|
|
- 'apps/api/src/models/**'
|
|
- 'packages/shared-types/**'
|
|
- 'scripts/generate-schemas.py'
|
|
|
|
jobs:
|
|
check-type-sync:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v3
|
|
with:
|
|
version: 9
|
|
|
|
- name: Install Python Dependencies
|
|
run: |
|
|
cd apps/api
|
|
pip install -q uv
|
|
uv pip install --system pydantic structlog -q
|
|
|
|
- name: Install Node Dependencies
|
|
run: pnpm install --filter @awoooi/shared-types
|
|
|
|
- name: Generate Types (Temp)
|
|
run: |
|
|
cd apps/api
|
|
python ../../scripts/generate-schemas.py
|
|
cd ../../packages/shared-types
|
|
pnpm generate:types
|
|
|
|
- name: Check for Differences
|
|
run: |
|
|
if git diff --exit-code packages/shared-types/; then
|
|
echo "✅ TypeScript 型別與 Pydantic 模型同步"
|
|
else
|
|
echo "❌ TypeScript 型別需要更新!"
|
|
echo ""
|
|
echo "請在本地執行:"
|
|
echo " pnpm --filter @awoooi/shared-types generate"
|
|
echo ""
|
|
echo "然後提交更新的型別檔案。"
|
|
exit 1
|
|
fi
|