Merge pull request #88 from dofliu/claude/html-animation-frontend-ui #366
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
| # GitHub Actions CI (PR-4b) | |
| # | |
| # 每次 push / PR 自動跑 pytest, 失敗在 PR 頁面顯示紅叉。 | |
| # 矩陣: Python 3.10 / 3.12 × Ubuntu / Windows (專案實際環境是 Win, Linux 為了 | |
| # 排除作業系統相依問題 — 例如 path 用 / 還是 \ 寫死). | |
| # | |
| # 裝 pytest + 純函式測試需要的庫. 不裝 google-genai / f5-tts (重型 + 平台相依). | |
| # pymupdf (~10MB wheel) iter 132 起加進來 — iter 131 的 | |
| # tests/test_runner_ingest_dispatch.py 用 monkeypatch.setattr(core, "solve_pdf", | |
| # ...) 觸發 core/__init__.py lazy __getattr__ → import solve → solve 頂層 | |
| # import fitz, 沒裝就 ModuleNotFoundError. 之後加 integration test 走 TestClient | |
| # + 真 pipeline 時再考慮分 jobs 處理。 | |
| name: tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| pytest: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| python-version: ['3.10', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # iter 87: Ubuntu runner 預設沒中文 + Noto Sans CJK 字型, | |
| # iter 64 起 cover/outro/theme tests 會實際 render (Pillow 開字型), | |
| # 字型缺就 OSError. Windows runner 自帶 msjh.ttc 故不需要這步. | |
| # 加 fonts-noto-cjk + fonts-dejavu 兩套, 並 export 環境變數讓 | |
| # core/config.py 找到. fonts-noto-cjk 約 70MB 但裝 1 次 cache 之後 < 5s. | |
| - name: Install CJK fonts (Linux only) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y --no-install-recommends fonts-noto-cjk fonts-dejavu fonts-dejavu-extra | |
| # 列字型路徑給後續 step 用 | |
| fc-list | grep -i "noto sans cjk tc\|dejavu sans\b" | head -5 | |
| echo "CLAUDE_FONT_PATH=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc" >> $GITHUB_ENV | |
| echo "CLAUDE_FALLBACK_FONT_PATH=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" >> $GITHUB_ENV | |
| echo "CLAUDE_MONO_FONT_PATH=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" >> $GITHUB_ENV | |
| # 裝執行測試所需的依賴: pytest + 我們程式碼會 import 的核心 lib. | |
| # Pillow / fontTools 因 PR-5a (theme) 需要, 還算輕量。 | |
| # mutagen: pipeline.py 頂部 import, test_slide_renderer / test_visuals | |
| # 透過 import pipeline 會拉到, 純 Python ~600KB, 加進來避免 importorskip 蔓延。 | |
| # python-multipart: FastAPI Form/File 上傳, test_upload.py TestClient 用。 | |
| # qrcode: iter 67 outro QR codes 渲染需要. ~10KB pure Python, 輕量. | |
| # pymupdf (iter 132 加): ~10MB wheel, 都有 prebuilt (Linux/Win/Mac wheel | |
| # 都齊), 不卡 wheel build. iter 131 test_runner_ingest_dispatch.py 用 | |
| # monkeypatch.setattr(core, "solve_pdf", ...) 透過 core.__getattr__ lazy | |
| # import solve → solve 頂層 import fitz 踩到, 之後越來越多 test 會貼近 | |
| # production import path, 早晚要裝. | |
| # matplotlib (2026-06-04 加): LaTeX 公式渲染 core/formula_render.py 升為核心 | |
| # 依賴, test_formula_render.py 直接跑 (非 skip), prebuilt wheel 各平台齊。 | |
| # google-genai (2026-06-07 加): eduStudio 整合後 infocards 視覺生成 + 影片 | |
| # pipeline 都靠它, tests/test_infocards_*.py 的 gemini helper 測試直接 import | |
| # `from google.genai import types`(非 importorskip)→ 不裝會 ModuleNotFoundError。 | |
| # 純 Python wheel, 不卡 build。f5-tts 等重型平台相依仍不裝(相關 test 有 skipif)。 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install fastapi uvicorn pydantic python-multipart httpx beautifulsoup4 Pillow fonttools mutagen qrcode pymupdf matplotlib google-genai | |
| pip install -r requirements-dev.txt | |
| - name: Run pytest | |
| run: pytest -v | |
| # iter 64: frontend typecheck. tsc --noEmit 找型別漏洞, 不 build (build 太慢 | |
| # 且需要 lockfile 完整裝 — typecheck 只要 tsc + @types/*). | |
| # 注意: web/ 是 legacy 前端 (/ui · /studio, autosolvervideo-web, 已標 legacy 退場, | |
| # 見 U-3)。正式對外前端是 frontend/ (/app, edustudio-frontend), 由下方 | |
| # frontend-app-build job 把關。此 job 保留是因 /ui · /studio 仍在 server 提供 (帶退場 | |
| # banner), 退場前繼續守 legacy 型別不退步; 待 /studio 路由與 build 產物正式移除後可一併刪。 | |
| # 單一 job ubuntu × node 20, 不開 matrix (frontend 不需要跨 OS 驗證). | |
| frontend-typecheck: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: web | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install deps | |
| run: npm ci | |
| - name: Typecheck (tsc --noEmit) | |
| run: npx tsc --noEmit | |
| # T-2 (2026-06-10): 把關「唯一正式對外前端」frontend/ (/app, React 19 + Vite, U-6 已寫死 | |
| # base:'/app/')。先前 CI 只 typecheck legacy web/, 真正的 /app 前端從未進 CI —— | |
| # app.jsx 壞了不會被擋。frontend/edustudio 是純 JSX (無 tsconfig) → tsc --noEmit 不適用, | |
| # 有意義的護網是 `npm run build` (vite build): JSX 解析錯 / import 缺失 / 建置失敗都會紅。 | |
| # 產物輸出到 gitignore 的 web/eduapp, 不污染 repo。單一 job ubuntu × node 20。 | |
| frontend-app-build: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install deps | |
| run: npm ci | |
| - name: Build (/app, vite build, base=/app/) | |
| run: npm run build |