Repository navigation
212 lines (204 loc) · 10.1 KB
/
Copy pathpr-check.yml
File metadata and controls
212 lines (204 loc) · 10.1 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: PR Quality Check
on:
pull_request:
branches: [main, dev]
push:
branches: [dev]
jobs:
# ===========================================================================
# 路径变更检测 —— 决定哪些子项目需要执行检查
# ===========================================================================
changes:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: read
outputs:
app-frontend: ${{ steps.filter.outputs.app-frontend }}
app-rust: ${{ steps.filter.outputs.app-rust }}
docs: ${{ steps.filter.outputs.docs }}
website: ${{ steps.filter.outputs.website }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
app-frontend:
- 'app/src/**'
- 'app/package.json'
- 'app/package-lock.json'
- 'app/index.html'
- 'app/vite.config.ts'
- 'app/tsconfig*.json'
app-rust:
- 'app/src-tauri/**'
- 'app/src-tauri/Cargo.lock'
docs:
- 'docs/**'
- 'scripts/docs-check.mjs'
- '.docscheckignore'
website:
- 'website/**'
# ===========================================================================
# App 前端 —— React + Vite + TypeScript
# ===========================================================================
app-frontend:
needs: changes
if: needs.changes.outputs.app-frontend == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: app/package-lock.json
- run: cd app && npm ci
- name: Typecheck
run: cd app && npx tsc --noEmit
- name: Build
run: cd app && npm run build
# 批 8 T17(G2 分档):包体闸的**输入是前端构建产物** ⇒ 与产出它的 job 同域。`app/dist` 刚由
# 上一 step 生成(同一条 `npm run build`:app/package.json = `tsc && vite build`,vite 默认
# outDir=dist)⇒ `--no-build` 判的正是**本次构建**的产物(去掉它 = 同一条命令再构建一次)。
# 🔴 挂在无条件 job 会**恒红**(那 job 不构建、`dist` 不入库):批 8 T17 导出树实测 exit 2。
- name: First-screen bundle budget (no-build; lazy side NOT judged — first screen only)
run: node scripts/check-bundle-budget.mjs --no-build
# ===========================================================================
# App Rust 后端 —— Tauri 主进程(含单测与 lint)
# ===========================================================================
app-rust:
needs: changes
if: needs.changes.outputs.app-rust == 'true'
# 项目含 Windows 专用模块(audio_route_probe/device_probe/gdi_capture 等未做 Linux cfg 隔离),
# 测试必须在 Windows runner 执行;Linux 编译会因 E0433 失败
runs-on: windows-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: x86_64-pc-windows-msvc
# sherpa-onnx 等 crate 编译耗时较长,启用 sccache 加速重复构建
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
workspaces: app/src-tauri
# models/ 不入库(AGENTS.md 铁律),build.rs 的 bundle.resources glob 需要空目录占位
- name: Prepare models placeholder
shell: bash
run: mkdir -p app/src-tauri/models
# .cargo/config.toml 注入的是本机 Windows 预编译库绝对路径(sherpa-archive/、ort/),
# ort-sys/sherpa-onnx-sys 只要见到 ORT_LIB_LOCATION/SHERPA_ONNX_ARCHIVE_DIR 存在即跳过下载——
# CI 无法 unset env,直接移除 config 使注入消失,两库回退在线下载(CI 网络可达)
- name: Remove local cargo config (CI online download)
shell: bash
run: rm -f app/src-tauri/.cargo/config.toml
# oar-ocr 未启用 ort-sys 的 download-binaries feature(本地靠 ORT_LIB_LOCATION 链接),
# CI 必须手动提供 ONNX Runtime 库,与本地 ORT_LIB_LOCATION 同机制(CPU 包即可,测试不初始化 CUDA)
- name: Prepare ONNX Runtime for CI
shell: bash
run: |
mkdir -p app/src-tauri/ort/ci
curl -sL https://github.com/microsoft/onnxruntime/releases/download/v1.28.0/onnxruntime-win-x64-1.28.0.zip -o /tmp/ort.zip
unzip -q /tmp/ort.zip -d /tmp/ortx
cp /tmp/ortx/onnxruntime-win-x64-1.28.0/lib/onnxruntime.* app/src-tauri/ort/ci/
# sherpa-onnx-sys 自带的在线下载在 CI 上不稳定(曾出现解压残缺导致 LNK1181),
# 改用官方 SHERPA_ONNX_ARCHIVE_DIR 机制(与本地 config 一致):curl 预下载 tar 包
- name: Prepare sherpa-onnx archive for CI
shell: bash
run: |
mkdir -p app/src-tauri/sherpa-archive
curl -sL "https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.13.5/sherpa-onnx-v1.13.5-win-x64-shared-MT-Release-lib.tar.bz2" \
-o app/src-tauri/sherpa-archive/sherpa-onnx-v1.13.5-win-x64-shared-MT-Release-lib.tar.bz2
- name: Test
# ORT_PREFER_DYNAMIC_LINK=1:与本地一致走动态链接,规避 static MT 与项目 MD 运行时的 LNK2038 冲突
shell: bash
env:
ORT_LIB_LOCATION: ${{ github.workspace }}/app/src-tauri/ort/ci
ORT_PREFER_DYNAMIC_LINK: "1"
SHERPA_ONNX_ARCHIVE_DIR: ${{ github.workspace }}/app/src-tauri/sherpa-archive
# 跳过 3 个预存基线失败(CHANGELOG 已登记,与本版无关):
# ai_client 默认 Provider 断言 / note_filter 两条黄金用例——待后续版本修复
run: |
cd app/src-tauri
# rust-cache 恢复的 target/sherpa-onnx-prebuilt 可能不完整(历史 LNK1181),强制重新下载
rm -rf target/sherpa-onnx-prebuilt
cargo test -- --skip ai_client::tests::from_settings_resolves_default_provider_when_set --skip note_filter::golden_tests::session29_live_ui_excluded_from_points --skip note_filter::tests::ocr_points_exclude_watermark_junk_and_dupes
- name: Lint (clippy)
shell: bash
env:
ORT_LIB_LOCATION: ${{ github.workspace }}/app/src-tauri/ort/ci
ORT_PREFER_DYNAMIC_LINK: "1"
run: |
cd app/src-tauri
rm -rf target/sherpa-onnx-prebuilt
cargo clippy -- -D warnings
# ===========================================================================
# 官网 —— Next.js 静态站(构建验证,部署走 deploy-website.yml)
# ===========================================================================
website:
needs: changes
if: needs.changes.outputs.website == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: website/package-lock.json
- run: cd website && npm ci
- name: Build
run: cd website && npm run build
# ===========================================================================
# Docs —— 文档体系一致性检查(链接/索引/命名)
# ===========================================================================
docs:
needs: changes
if: needs.changes.outputs.docs == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Docs check
run: node scripts/docs-check.mjs
# ===========================================================================
# 行数红线 — AGENTS.md §3(全部行数口径;>600 棘轮只减不增)
# ===========================================================================
line-limits:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
# --full:CI 在结构之外额外守 (e)「登记值 == 实测值」,与**本地完全同口径**。
# 本地提交门禁(.husky/pre-commit)自 2026-09-11 起直跑
# `node scripts/line-limits.mjs --full && node scripts/docs-check.mjs`(不经 lint-staged),
# 故这条 job 是**第二道**网、不再是唯一守 (e) 的地方。--full 只读、不重写登记表
# (写表只走 --write),因此本地跑它不会逼迫任何人重新生成表。
- name: Line limits
run: node scripts/line-limits.mjs --full
# 批 0-C3 Task 1:IPC 命令注册一致性(`#[tauri::command]` 定义 ↔ app_commands.rs 注册清单,
# 三向检查漏/多/重名)。注册清单拆分后漏一条是**唯一会静默失败**的改动面(编译通过、单测全绿,
# 只有真机点到才报 `command … not found`)⇒ 与 line-limits 同 job(同为纯文本全树只读扫描)。
- name: Command registry consistency
run: node scripts/check-command-registry.mjs
# 批 8 T17(G2 · 脚本域门禁的执行者缺口):`on:` 无 `paths`,其余四个 job 都带
# `needs: changes` + `if:`,只有本 job 无条件 ⇒ **不需要构建产物**的脚本域门禁挂在这里,
# 才每次 PR/push 都跑。不补 `scripts/**` glob —— glob 属 paths-filter 域,补它只覆盖
# 「新增路径」,且会漏掉「改了 `scripts/**` 却被 filter 判为无变更」这一二次缺口(§2 G2)。
# 批 8 T17(G6):豁免表散文数字对拍探针**单列转正**为 CI step,**不并入八闸集合**
# (八闸集合是批次间对账基线;散文数字天然易漂 ⇒ 硬合并会让逐字对账漂移、频繁假红)。
- name: Exemption table prose check
run: node scripts/check-exemption-prose.mjs