Skip to content

Commit 209d254

Browse files
committed
Add CI quality checks
- add GitHub Actions jobs for frontend and backend verification - configure Ruff formatting and pytest coverage baseline - document local development check commands
1 parent f4ce079 commit 209d254

32 files changed

Lines changed: 805 additions & 567 deletions

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
frontend:
19+
name: Frontend
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: npm
31+
cache-dependency-path: web/package-lock.json
32+
33+
- name: Install frontend dependencies
34+
working-directory: web
35+
run: npm ci
36+
37+
- name: Lint frontend
38+
working-directory: web
39+
run: npm run lint
40+
41+
- name: Test frontend
42+
working-directory: web
43+
run: npm run test
44+
45+
- name: Build frontend
46+
working-directory: web
47+
run: npm run build
48+
49+
backend:
50+
name: Backend Python ${{ matrix.python-version }}
51+
runs-on: ubuntu-latest
52+
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
python-version:
57+
- "3.11"
58+
- "3.12"
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
cache: pip
69+
cache-dependency-path: |
70+
requirements.txt
71+
requirements-dev.txt
72+
73+
- name: Install backend dependencies
74+
run: python -m pip install -r requirements-dev.txt
75+
76+
- name: Ruff lint
77+
run: ruff check api src tests main.py
78+
79+
- name: Ruff format check
80+
run: ruff format --check api src tests main.py
81+
82+
- name: Test backend with coverage
83+
run: python -m pytest --cov=api --cov=src --cov-report=term-missing

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ENV/
1111
*.egg-info/
1212
.installed.cfg
1313
*.egg
14+
.coverage*
15+
htmlcov/
1416

1517
# Node.js (前端依赖由 web/.gitignore 管理,这里作为备份)
1618
node_modules/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,33 @@ output/ppt_20241201_123456/
161161
└── images/ # Slide images
162162
```
163163

164+
## 🧪 Development Checks
165+
166+
Recommended local runtime:
167+
- Python 3.11 or 3.12
168+
- Node.js 20
169+
170+
Backend checks:
171+
172+
```bash
173+
python -m pip install -r requirements-dev.txt
174+
ruff check api src tests main.py
175+
ruff format --check api src tests main.py
176+
python -m pytest --cov=api --cov=src --cov-report=term-missing
177+
```
178+
179+
Frontend checks:
180+
181+
```bash
182+
cd web
183+
npm ci
184+
npm run lint
185+
npm run test
186+
npm run build
187+
```
188+
189+
GitHub Actions runs the same default checks on `main` and `dev` pull requests and pushes. Real model API calls are intentionally not part of the default CI because they require private keys and can be flaky.
190+
164191
## 📋 TODO
165192

166193
- [ ] Upgrade generated PPT images into structured, editable PPT content

README_zh.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,33 @@ output/ppt_20241201_123456/
161161
└── images/ # 幻灯片图片
162162
```
163163

164+
## 🧪 开发检查
165+
166+
推荐本地运行环境:
167+
- Python 3.11 或 3.12
168+
- Node.js 20
169+
170+
后端检查:
171+
172+
```bash
173+
python -m pip install -r requirements-dev.txt
174+
ruff check api src tests main.py
175+
ruff format --check api src tests main.py
176+
python -m pytest --cov=api --cov=src --cov-report=term-missing
177+
```
178+
179+
前端检查:
180+
181+
```bash
182+
cd web
183+
npm ci
184+
npm run lint
185+
npm run test
186+
npm run build
187+
```
188+
189+
GitHub Actions 会在 `main``dev` 的 Pull Request 与 push 上运行这些默认检查。真实模型 API 调用需要私有 Key,且容易受外部服务波动影响,因此不放入默认 CI。
190+
164191
## 📋 TODO
165192

166193
- [ ] 将生成的 PPT 图片增强为结构化、可编辑的 PPT 内容

api/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
app = FastAPI(
1616
title="AI PPT Generator API",
1717
description="API for AI-powered PPT generation with WebUI",
18-
version="1.0.0"
18+
version="1.0.0",
1919
)
2020

2121
# 配置 CORS 中间件
@@ -50,4 +50,5 @@ async def health_check():
5050

5151
if __name__ == "__main__":
5252
import uvicorn
53+
5354
uvicorn.run(app, host="0.0.0.0", port=8000)

0 commit comments

Comments
 (0)