Repository navigation
71 lines (56 loc) · 2.21 KB
/
Copy pathci.yml
File metadata and controls
71 lines (56 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: python-learning CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: python-learning-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
name: 后端测试 + 前端构建
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: backend/requirements.txt
- name: 安装后端依赖
run: pip install -r backend/requirements.txt
- name: 后端测试(SQLite,无需外部服务)
run: python -m pytest backend/tests -q
- name: 冒烟验证免登录契约(无 token 应拿到默认用户)
run: |
python - <<'PY'
import sys, tempfile
sys.path.insert(0, "backend")
from fastapi.testclient import TestClient
from app.main import create_app
db = tempfile.mktemp(suffix=".db")
client = TestClient(create_app(database_url=f"sqlite:///{db}"))
me = client.get("/api/auth/me")
assert me.status_code == 200, f"/api/auth/me 应免登录放行,实际 {me.status_code}: {me.text}"
print("免登录身份:", me.json())
for path in ["/api/health", "/api/summary", "/api/chapters"]:
r = client.get(path)
assert r.status_code == 200, f"{path} -> {r.status_code}: {r.text[:200]}"
print(f" {path} OK")
w = client.patch("/api/progress", json={"chapter_no": 1, "layer": "theory", "done": True})
assert w.status_code == 200, f"免登录写入应成功,实际 {w.status_code}: {w.text}"
print("免登录写入 OK:", w.json())
print("✅ 免登录契约验证通过")
PY
- name: 安装 Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: 安装前端依赖
run: npm ci --no-audit --no-fund
- name: TypeScript 类型检查 + 构建
run: npm run build
# 注:仓库结构检查(tools/check_learning_repo.py)已在 quality.yml 中单独运行,此处不重复