Repository navigation
139 lines (133 loc) · 4.7 KB
/
Copy pathpr-check.yml
File metadata and controls
139 lines (133 loc) · 4.7 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: PR Quality Check
on:
pull_request:
branches: [main, dev]
jobs:
# ===========================================================================
# 路径变更检测 —— 决定哪些子项目需要执行检查
# ===========================================================================
changes:
runs-on: ubuntu-latest
outputs:
client: ${{ steps.filter.outputs.client }}
sync-service: ${{ steps.filter.outputs.sync-service }}
ai-gateway: ${{ steps.filter.outputs.ai-gateway }}
website: ${{ steps.filter.outputs.website }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
client:
- 'client/**'
sync-service:
- 'server/sync-service/**'
- 'server/shared/**'
ai-gateway:
- 'server/ai-gateway/**'
- 'server/shared/**'
website:
- 'website/**'
# ===========================================================================
# Client —— React + Vite + Electron 前端
# ===========================================================================
client:
needs: changes
if: needs.changes.outputs.client == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- run: cd client && npm ci
- name: Lint
run: cd client && npm run lint
- name: Typecheck (renderer)
# 渲染进程(React + Vite)的 TypeScript 编译检查
run: cd client && npx tsc --noEmit
# Electron 主进程使用独立的 tsconfig(CommonJS / Node 目标),
# 与渲染进程的 Vite+DOM 配置不同,需单独检查以捕获主进程类型错误
- name: Typecheck (Electron main process)
run: cd client && npx tsc -p electron/tsconfig.json --noEmit
- name: Test (with coverage)
# 启用覆盖率收集,与 vitest.config.ts 中配置的阈值配合,
# 确保新增代码的测试覆盖不低于设定门槛
run: cd client && npm run test -- --run --coverage
- name: Build
run: cd client && npm run build
# ===========================================================================
# Server / sync-service —— Go + Gin 同步服务
# ===========================================================================
sync-service:
needs: changes
if: needs.changes.outputs.sync-service == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: server/sync-service
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
# Go 1.25 尚未发布,使用当前最新稳定版 1.24(截至 2026 年 8 月)
go-version: '1.24'
cache-dependency-path: server/sync-service/go.sum
- name: Lint (go vet)
run: go vet ./...
- name: Build
run: go build ./...
- name: Test
run: go test ./... -v -count=1
# ===========================================================================
# Server / ai-gateway —— Python + FastAPI AI 网关
# ===========================================================================
ai-gateway:
needs: changes
if: needs.changes.outputs.ai-gateway == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: server/ai-gateway
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: server/ai-gateway/requirements.txt
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install ruff pytest pytest-asyncio httpx
- name: Lint (ruff)
run: ruff check .
- name: Test
run: pytest tests/ -v --tb=short
# ===========================================================================
# Website —— Next.js 官网
# ===========================================================================
website:
needs: changes
if: needs.changes.outputs.website == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: website/package-lock.json
- run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npx tsc --noEmit
- name: Build
run: npm run build