Peach: Local-first video metadata scraper and media manager.
chore(ci): 优化工作流分工与项目测试执行
longmeidaocbe94a33ed30
diff --git a/.github/actions/actionlint/Dockerfile b/.github/actions/actionlint/Dockerfilenew file mode 100644index 000000000..546b7de3c--- /dev/null+++ b/.github/actions/actionlint/Dockerfile@@ -0,0 +1 @@+FROM rhysd/actionlint:1.7.12diff --git a/.github/actions/actionlint/action.yml b/.github/actions/actionlint/action.ymlnew file mode 100644index 000000000..b82c4a706--- /dev/null+++ b/.github/actions/actionlint/action.yml@@ -0,0 +1,5 @@+name: Actions 工作流静态检查+description: 使用固定版本 actionlint 校验工作流+runs:+ using: docker+ image: Dockerfilediff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex 55ce54507..f19e49363 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -3,6 +3,14 @@# semver-major 不进组,照常一个包一个 PR,接管前单独看变更说明。version: 2updates:+ - package-ecosystem: docker+ directory: /.github/actions/actionlint+ schedule:+ interval: weekly+ day: monday+ time: "09:45"+ timezone: Asia/Taipei+- package-ecosystem: dockerdirectory: /schedule:diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex 1a7095078..374ec0900 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -6,16 +6,22 @@ on:push:branches: [master]tags: ['v*.*.*']+ paths: [Dockerfile, .dockerignore, compose.yaml, 'src/**', 'migrations/**', 'web/**', 'resources/**', pyproject.toml, uv.lock, setup.py, MANIFEST.in, scripts/smoke_docker.py, scripts/release_tag.py, .github/workflows/docker.yml]workflow_dispatch:permissions:contents: readactions: read+concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+jobs:image:name: Linux amd64 镜像验收runs-on: ubuntu-latest+ timeout-minutes: 25steps:- uses: actions/checkout@v7- uses: actions/setup-python@v7@@ -56,9 +62,8 @@ jobs:fi- name: 发布已验收镜像if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && vars.DOCKERHUB_USERNAME != ''- uses: docker/build-push-action@v7- with:- context: .- push: true- tags: ${{ steps.tags.outputs.value }}- cache-from: type=gha+ env:+ PUBLISH_TAG: ${{ steps.tags.outputs.value }}+ run: |+ docker tag longmeidao/peach:test "$PUBLISH_TAG"+ docker push "$PUBLISH_TAG"diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 594ddd89d..d43a83db6 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -9,33 +9,71 @@ permissions:contents: readactions: read+concurrency:+ group: ${{ github.workflow }}-${{ github.ref }}+ cancel-in-progress: false+env:PYTHONUTF8: "1"PYTHONIOENCODING: "utf-8"jobs:+ validate:+ name: 核对发布提交与版本+ runs-on: ubuntu-latest+ timeout-minutes: 5+ steps:+ - uses: actions/checkout@v7+ - uses: actions/setup-python@v7+ with:+ python-version: '3.14'+ - name: 核对标签提交的主线 CI+ if: github.ref_type == 'tag'+ env:+ GH_TOKEN: ${{ github.token }}+ run: python scripts/release_tag.py --repo "$GITHUB_REPOSITORY" --verify-sha "$GITHUB_SHA"+ffmpeg:name: Windows FFmpeg 与对应源码runs-on: ubuntu-latest+ needs: validate+ timeout-minutes: 40steps:- uses: actions/checkout@v7+ - name: 复用固定源码的媒体工具与对应源码包+ id: media-cache+ uses: actions/[email protected]+ with:+ key: windows-media-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build_ffmpeg_windows.sh', 'scripts/build_untrunc_windows.sh', 'scripts/fetch_ffmpeg_sources.py', 'scripts/fetch_untrunc_sources.py', 'scripts/ffmpeg-sources.json', 'scripts/untrunc-sources.json') }}+ path: |+ build/ffmpeg-windows/ffmpeg+ build/ffmpeg-windows/ffmpeg-corresponding-source.zip+ build/untrunc-windows/untrunc+ build/untrunc-windows/untrunc-corresponding-source.zip- name: 安装交叉编译工具+ if: steps.media-cache.outputs.cache-hit != 'true'run: |sudo apt-get updatesudo apt-get install -y build-essential gcc-mingw-w64-x86-64-posix g++-mingw-w64-x86-64-posix mingw-w64-x86-64-dev nasm pkg-config python3 clang ca-certificates curl xz-utils- name: 构建固定版本媒体工具+ if: steps.media-cache.outputs.cache-hit != 'true'run: bash scripts/build_ffmpeg_windows.sh build/ffmpeg-windows- name: 构建固定版本索引修复工具+ if: steps.media-cache.outputs.cache-hit != 'true'run: bash scripts/build_untrunc_windows.sh build/untrunc-windows- uses: actions/upload-artifact@v7with:name: ffmpeg-windows+ if-no-files-found: error+ retention-days: 7path: |build/ffmpeg-windows/ffmpeg/build/ffmpeg-windows/ffmpeg-corresponding-source.zip- uses: actions/upload-artifact@v7with:name: untrunc-windows+ if-no-files-found: error+ retention-days: 7path: |build/untrunc-windows/untrunc/build/untrunc-windows/untrunc-corresponding-source.zip@@ -44,6 +82,7 @@ jobs:name: Windows x64 独立测试包runs-on: windows-latestneeds: ffmpeg+ timeout-minutes: 40outputs:version: ${{ steps.version.outputs.version }}steps:@@ -51,17 +90,11 @@ jobs:- uses: actions/setup-python@v7with:python-version: '3.14'- - name: 核对标签提交的主线 CI- if: github.ref_type == 'tag'- env:- GH_TOKEN: ${{ github.token }}- shell: pwsh- run: |- python scripts/release_tag.py --repo "$env:GITHUB_REPOSITORY" --verify-sha "$env:GITHUB_SHA"- if ($LASTEXITCODE -ne 0) { throw '发布提交未通过主线 CI' }- uses: actions/setup-node@v7with:node-version: '24'+ cache: npm+ cache-dependency-path: frontend/package-lock.json- name: 核对发布版本id: versionshell: pwsh@@ -122,11 +155,14 @@ jobs:with:name: desktop-candidatepath: release/*+ if-no-files-found: error+ retention-days: 7desktop-smoke:name: 仅下载制品验收needs: windowsruns-on: windows-latest+ timeout-minutes: 25steps:- uses: actions/download-artifact@v8with:@@ -170,12 +206,14 @@ jobs:name: desktop-smoke-failurepath: smoke-evidence/if-no-files-found: ignore+ retention-days: 14release:name: GitHub 预发布if: github.ref_type == 'tag'needs: [windows, desktop-smoke]runs-on: ubuntu-latest+ timeout-minutes: 10permissions:contents: writesteps:diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 1b13fcfc9..d88f43e5f 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -9,6 +9,10 @@ on:permissions:contents: read+concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+# Windows runner 的 stdout 默认按本机 ANSI(cp1252)编码,而项目里的脚本和错误# 消息大量是中文——`print(f"首尾帧审计失败:{error}")` 在 runner 上直接抛# UnicodeEncodeError,15 个脚本类用例因此全红,本地却全绿。@@ -21,12 +25,28 @@ env:PYTHONIOENCODING: "utf-8"jobs:+ workflow-lint:+ name: Actions 工作流静态检查+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@v7+ - uses: ./.github/actions/actionlint+plan:+ needs: workflow-lintruns-on: ubuntu-latest+ timeout-minutes: 10outputs:matrix: ${{ steps.plan.outputs.matrix }}wheel_matrix: ${{ steps.plan.outputs.wheel_matrix }}wide: ${{ steps.plan.outputs.wide }}+ browser_matrix: ${{ steps.plan.outputs.browser_matrix }}+ browser: ${{ steps.plan.outputs.browser }}+ frontend: ${{ steps.plan.outputs.frontend }}+ vendor: ${{ steps.plan.outputs.vendor }}+ wheel: ${{ steps.plan.outputs.wheel }}+ required_jobs: ${{ steps.plan.outputs.required_jobs }}steps:- uses: actions/checkout@v7with:@@ -43,7 +63,10 @@ jobs:run: uv run --locked --python 3.14 scripts/ci_plan.py --event "$EVENT_NAME" --base "$BASE_SHA"wheel-build:+ needs: plan+ if: needs.plan.outputs.wheel == 'true'runs-on: ubuntu-latest+ timeout-minutes: 15steps:- uses: actions/checkout@v7- uses: actions/setup-python@v7@@ -58,15 +81,19 @@ jobs:- uses: actions/upload-artifact@v7with:name: wheel-smoke+ if-no-files-found: error+ retention-days: 7path: |wheelhouse/*.whlscripts/smoke_wheel.pywheel-smoke:name: wheel 最小安装 / ${{ matrix.os }} / ${{ matrix.python }}needs: [plan, wheel-build]+ if: needs.plan.outputs.wheel == 'true'strategy:matrix: ${{ fromJSON(needs.plan.outputs.wheel_matrix) }}runs-on: ${{ matrix.os }}+ timeout-minutes: 15steps:- uses: actions/download-artifact@v8with:@@ -88,6 +115,7 @@ jobs:name: ${{ matrix.os }} / Python ${{ matrix.python }} / ${{ matrix.scope }} / ${{ matrix.shard_index }}needs: planruns-on: ${{ matrix.os }}+ timeout-minutes: 60strategy:fail-fast: falsematrix: ${{ fromJSON(needs.plan.outputs.matrix) }}@@ -141,16 +169,10 @@ jobs:- name: 运行 Windows 正式测试if: runner.os == 'Windows'shell: pwsh- run: '& .\scripts\test.ps1 -Scope ${{ matrix.scope }} -Fresh -Base $env:BASE_SHA -ShardIndex ${{ matrix.shard_index }} -ShardCount ${{ matrix.shard_count }}'- - name: 保存浏览器测试日志- if: always() && runner.os == 'Windows' && matrix.scope != 'core'- uses: actions/upload-artifact@v7- with:- name: browser-${{ matrix.python }}-${{ matrix.scope }}-${{ matrix.shard_index }}- path: |- build/agent-verification/browser/*.tap- build/agent-verification/browser/network/*.json- if-no-files-found: ignore+ run: |+ New-Item -ItemType Directory -Path build -Force | Out-Null+ & .\scripts\test.ps1 -Scope ${{ matrix.scope }} -Fresh -Base $env:BASE_SHA -ShardIndex ${{ matrix.shard_index }} -ShardCount ${{ matrix.shard_count }} *>&1 | Tee-Object -FilePath build/ci-tests.log+ if ($LASTEXITCODE -ne 0) { throw 'Python 分片未通过,详见 ci-tests.log' }- name: 安装 macOS 依赖if: runner.os == 'macOS'shell: bash@@ -160,11 +182,24 @@ jobs:- name: 运行 macOS 正式测试if: runner.os == 'macOS'shell: bash- run: ./scripts/test.sh ${{ matrix.scope }} --fresh --base "$BASE_SHA" --shard-index ${{ matrix.shard_index }} --shard-count ${{ matrix.shard_count }}+ run: |+ mkdir -p build+ ./scripts/test.sh ${{ matrix.scope }} --fresh --base "$BASE_SHA" --shard-index ${{ matrix.shard_index }} --shard-count ${{ matrix.shard_count }} 2>&1 | tee build/ci-tests.log+ - name: 保存分片测试日志+ if: always()+ uses: actions/upload-artifact@v7+ with:+ name: python-${{ matrix.os }}-${{ matrix.scope }}-${{ matrix.shard_index }}+ path: build/ci-tests.log+ if-no-files-found: ignore+ retention-days: 14web-bundle:name: island 产物与前端测试runs-on: ubuntu-latest+ needs: plan+ if: needs.plan.outputs.frontend == 'true'+ timeout-minutes: 20steps:- uses: actions/checkout@v7- uses: actions/setup-node@v7@@ -190,26 +225,21 @@ jobs:run: |git add --intent-to-add -- web/distgit diff --exit-code -- web/dist- # 与下面 web-vendor 的 audit 同一口径:advisories 端点偶发 503,退避重试三次。- name: npm audit (frontend)- shell: bash- run: |- for attempt in 1 2 3; do- npm --prefix frontend audit --audit-level=high && exit 0- echo "npm audit 第 ${attempt} 次未成功,60 秒后重试"- sleep 60- done- exit 1+ run: python scripts/npm_audit.py --prefix frontend- # 浏览器冒烟(`frontend/e2e/smoke.test.ts`)、设计决定断言(`design-*.test.ts`)与交互回归。- # runner 上 `GITHUB_ACTIONS=true`,浏览器用例按设计、交互、冒烟三批串行跑。- # `python` 矩阵的 Windows 行平时只跑 `core`,这几组用例靠这里执行;矩阵扩成全量- # (`plan` 的 `wide`)时 Windows 行已经把 `web` 域跑过一遍,这里就不再跑第二遍。+ # 每片拥有独立服务与演示库;文件内的浏览器交互保持串行。web-e2e:- name: 浏览器冒烟与设计决定断言+ name: 浏览器回归 / ${{ matrix.index }}needs: [plan]- if: needs.plan.outputs.wide != 'true'+ if: needs.plan.outputs.browser == 'true'runs-on: windows-latest+ timeout-minutes: 40+ strategy:+ fail-fast: false+ matrix: ${{ fromJSON(needs.plan.outputs.browser_matrix) }}+ env:+ BROWSER_FILES: ${{ matrix.files }}steps:- uses: actions/checkout@v7- uses: actions/setup-python@v7@@ -241,22 +271,31 @@ jobs:run: |uv sync --locked --all-extras --python pythonif ($LASTEXITCODE -ne 0) { throw 'uv 锁定安装失败' }- - name: 运行 web 域+ - name: 运行本片浏览器用例shell: pwsh- run: '& .\scripts\test.ps1 -Scope web -Fresh'+ run: |+ $peachBrowserFiles = @($env:BROWSER_FILES | ConvertFrom-Json)+ & .\scripts\test.ps1 -Scope web -Focus $peachBrowserFiles+ if ($LASTEXITCODE -ne 0) { throw '浏览器分片未通过' }- name: 保存浏览器测试日志if: always()uses: actions/upload-artifact@v7with:- name: browser-web+ name: browser-${{ matrix.index }}path: |build/agent-verification/browser/*.tap+ build/agent-verification/browser/serve.log+ build/agent-verification/browser/setup-serve.logbuild/agent-verification/browser/network/*.jsonif-no-files-found: ignore+ retention-days: 14web-vendor:name: 固定前端依赖runs-on: ubuntu-latest+ needs: plan+ if: needs.plan.outputs.vendor == 'true'+ timeout-minutes: 15steps:- uses: actions/checkout@v7- uses: actions/setup-node@v7@@ -265,29 +304,19 @@ jobs:cache: npm- run: npm ci --ignore-scripts- run: npm run check:vendor- # 审计结果来自 registry.npmjs.org 的 advisories 端点,它偶发 503;- # 退避重试三次,仍失败才算红——那时是真的查不到,不是本仓库的问题。- name: npm audit- shell: bash- run: |- for attempt in 1 2 3; do- npm audit --audit-level=high && exit 0- echo "npm audit 第 ${attempt} 次未成功,60 秒后重试"- sleep 60- done- exit 1+ run: python scripts/npm_audit.pyverified:name: 完整验证结果if: always()- needs: [plan, python, wheel-smoke, web-bundle, web-e2e, web-vendor]+ needs: [plan, workflow-lint, python, wheel-build, wheel-smoke, web-bundle, web-e2e, web-vendor]runs-on: ubuntu-latest+ timeout-minutes: 5steps:- # `web-e2e` 只在矩阵没扩成全量时执行;全量矩阵下它按条件跳过,`web` 域已由- # Windows 全量行覆盖。别的 job 跳过或失败都算红。+ - uses: actions/checkout@v7- name: 所有必需任务均成功env:RESULTS: ${{ toJSON(needs) }}- WIDE: ${{ needs.plan.outputs.wide }}- run: |- python -c 'import json, os; results=json.loads(os.environ["RESULTS"]); wide=os.environ["WIDE"] == "true"; bad={name: job["result"] for name, job in results.items() if job["result"] != "success" and not (name == "web-e2e" and wide and job["result"] == "skipped")}; assert not bad, (bad, results)'+ REQUIRED_JOBS: ${{ needs.plan.outputs.required_jobs }}+ run: python scripts/ci_plan.py --verify-resultsdiff --git a/.github/workflows/upgrade-smoke.yml b/.github/workflows/upgrade-smoke.ymlindex f0b7ee46a..059b5b6fc 100644--- a/.github/workflows/upgrade-smoke.yml+++ b/.github/workflows/upgrade-smoke.yml@@ -10,19 +10,22 @@ on:to_version:description: 已发布的目标版本required: true- default: '0.40.1'to_commit:description: 目标制品的完整构建提交required: true- default: '6e5e8b48d0bfe5203c9af998792ce9c31c02542b'permissions:contents: read+concurrency:+ group: ${{ github.workflow }}-${{ inputs.from_version }}-${{ inputs.to_version }}-${{ inputs.to_commit }}+ cancel-in-progress: false+jobs:overlay:name: ${{ matrix.kind }} / ${{ matrix.data_location }} 原位覆盖runs-on: windows-latest+ timeout-minutes: 30strategy:fail-fast: falsematrix:@@ -56,3 +59,5 @@ jobs:path: |overlay.logsmoke-evidence/+ if-no-files-found: error+ retention-days: 14diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 13255ea5c..97f488329 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -1,5 +1,7 @@# 复用清单+Actions 工作流静态检查复用 actionlint 1.7.12(MIT,`rhysd/actionlint:1.7.12` 官方 Docker 镜像),由本地 Docker action 使用,独立 Docker 目录纳入 Dependabot 与接管入口。GitHub Actions 生态不更新 `docker://` 镜像引用。Windows 官方二进制按发布校验和完成本地 POC;CI 在 Linux 容器检查语法、表达式、任务依赖与脚本。Python 与浏览器回归继续使用现有统一入口及 Playwright;六片浏览器权重来自 [已通过的 CI](https://github.com/peach-mitao/peach/actions/runs/38981261189) 的 69 份 TAP,记录在 `scripts/ci-browser-timings.json`,没有新增应用运行依赖。+目录浏览的 `media_folders` 复用 `PureWindowsPath`、媒体库声明根和账本路径,不访问媒体挂载。`folder_rules` 复用 profile 偏好、规范实体、字段归属、身份断言、逐件归属否定和扫描登记入口;规则以 `user:directory-<目录标识>` 保存独立来源,预览摘要绑定资产版本与关系,撤回只处理本来源。已有明确归属保持独立。界面逐字采用 MIT 许可的 BoardUI Tree View、Breadcrumb 与 Direction,固定源码 SHA-256 见 `frontend/src/react/boardui/ORIGIN.md`;复用现有 React 19.3.0、React Aria Components 1.22.1、Motion 14.1.0 与 Remix Icon 4.9.0,无新增依赖。Peach 的原生链接适配上游 `next/link` 槽,领域逻辑仅承担目录归属、冲突保留、范围确认和来源撤回。能力检索覆盖当前媒体库分组、目录否定、字段归属和 `media_libraries.py` 的 Git 历史;物理目录整理继续使用既有入口。验证只使用临时账本与合成馆藏。diff --git a/docs/TESTING.md b/docs/TESTING.mdindex 3911dc7cf..c2d8057a8 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -69,18 +69,24 @@ Python 静态检查使用开发依赖 Ruff,随每个正式测试域扫描全| 场景 | 验证 || --- | --- || 本机修改 | 正式入口默认 `auto`,按影响域取并集;同代码、环境与范围的有效记录可复用 |-| 普通 PR | Python 3.14:macOS 影响域;Windows 关键系统 |-| 普通主线提交 | Python 3.14:macOS 全量;Windows 关键系统 |+| 普通 PR | Python 3.14:macOS 与 Windows 均按影响域验证 |+| 普通主线提交 | Python 3.14:macOS 与 Windows 全量 Python 回归;前端与浏览器按影响选择 || 实际依赖、迁移、共享测试设施、未知影响面 | Windows 与 macOS 的 Python 3.14 全量 || 手动 CI | 完整系统矩阵 || wheel | Windows 与 macOS 各一次 Python 3.14 独立最小安装 || Release | 复用同 SHA 主线成功 CI;构建后执行独立 EXE 冒烟 |-全量在两个独立 runner 按测试文件稳定分片;汇总任务要求所有分片和必需任务成功。分片子进程不签发记录。+Python 全量按文件稳定分片,Windows 四片、macOS 两片,每片使用独立 runner;汇总任务要求所有分片和计划选择的任务成功。分片子进程不签发记录。-Test 工作流的 `web-bundle` 在 Ubuntu 上统一执行 tsc、lint、Vitest、构建及产物差异检查;lint 同时检查无诊断且扫描文件数大于零。`python` 与 `web-e2e` 任务仅从 Python 测试集合中移交这三个工具用例,产物契约、系统功能和浏览器回归照常执行。任务身份由 GitHub Actions 的固定工作流与 job 名识别,未知任务和本机完整保留三个用例。承担部分 CI 职责的运行不签发本机测试记录,最终结果由必须依赖 `web-bundle` 的 `verified` 任务汇总。+Test 工作流的 `web-bundle` 在 Ubuntu 上统一执行 tsc、lint、Vitest、构建及产物差异检查;lint 同时检查无诊断且扫描文件数大于零。CI 的 Python 任务把这三个工具用例交给前端任务,把两个真实浏览器用例交给浏览器矩阵;同模块的契约测试仍执行。任务身份由固定工作流与 job 名识别,未知任务和本机保留完整测试。承担部分 CI 职责的运行不签发本机测试记录。-浏览器冒烟与设计决定断言(`tests/test_web_e2e.py`)由 `web-e2e` job 在 `windows-latest` 上执行 `web` 域。它装 Node 24、`frontend/node_modules`、ffmpeg,并经 `PEACH_E2E_CHROME` 指定 runner 自带的 Chrome。矩阵扩成全量(`plan` 输出的 `wide`)时,Windows 全量行本身就跑 `web` 域,这个 job 按条件跳过;`verified` 只在这种情况接受它的 skipped,别的 job 跳过照样算红。+浏览器用例由 `web-e2e` 的六个 Windows runner 分担,每片有自己的服务、演示库与日志。`ci_plan.py` 按 `ci-browser-timings.json` 的实测秒数分配文件,新文件使用默认权重;每个文件恰好执行一次。每片经项目入口的 `-Focus` 运行分配的浏览器文件,首启文件始终归首次设置服务。它装 Node 24、前端依赖、ffmpeg,并经 `PEACH_E2E_CHROME` 指定 Chrome。本机浏览器入口与并发语义保持完整。++计划按改动选择前端、vendor、wheel 与浏览器任务,文档 PR 只执行适用检查;依赖、未知影响与手动验证包含全部任务。`verified` 根据计划核对必需任务,缺失、失败、取消及必需任务跳过均判失败。Actions 工作流本身由固定版 actionlint 检查语法、表达式、依赖与脚本。PR 更新取消同 PR 的过期运行,主线 Test 按提交各自保留结果。++Python 分片上传完整测试输出;浏览器分片上传 TAP、服务日志及已脱敏网络日志,保留 14 天。npm 审计遇到 high 或 critical 漏洞直接失败;只有临时网络错误最多请求三次,在前两次失败后分别等待 15 与 30 秒,未知响应不当成通过。++Release 在媒体工具编译前核对同 SHA 主线 CI,缓存键绑定媒体工具源码清单与构建脚本,缓存内容同时含二进制和对应源码包;制品与独立开箱验收仍是发布前置。Docker 只在镜像相关主线改动、匹配 PR、版本标签或手动请求时运行,验收后推送同一个本地镜像。版本发布与覆盖升级验收不取消进行中的同目标运行;覆盖升级需明确选择目标版本及完整构建提交。浏览器用例覆盖 `frontend/e2e` 下全部 `*.test.ts`,包括子目录。`setup.test.ts` 由 `SetupE2ETests` 在首次设置服务上执行,其余文件在已配置的演示库服务上按文件并发、文件内串行。并发数取 `PEACH_E2E_CONCURRENCY`;未设时本机取逻辑核数的四分之一、上限 4,CI(`GITHUB_ACTIONS=true`)为 1。并发批最多 12 个文件,串行批每批一个文件,各自取得完整 TAP 结果。测量动画、密度切换与等待态替换的文件(`tests/test_web_e2e.py` 的 `TIMING_SENSITIVE_SUITES`)在并发批之后串行;并发为 1 时按设计决定、交互回归和路由冒烟排序。每批限时 600 秒,任一批失败,整轮验证失败。并发的文件共用一个服务和演示库:用例触发的写请求只能落在别的用例不断言的状态上,否则用 `page.route` 拦下或归进串行批。控制台逐批输出文件名;完整 TAP 日志与服务访问日志 `serve.log` 保存在 `build/agent-verification/browser/`,CI 在测试结束后上传其中的 TAP 日志。@@ -94,6 +100,8 @@ Windows 的路径、挂载、托盘、证书、进程编码、更新、认证及## 写什么测试+纯 HTTP 请求契约可使用 `tests/support/web.py` 的 `route_client`:请求经过真实路由、中间件和依赖,不启动后台服务;调用方仍须准备完整临时账本。服务启动、恢复与关闭语义使用正常 lifespan,由集成测试覆盖。+浏览器入口通过 `PEACH_E2E_NET_LOG_DIR` 保存 Chromium 网络事件日志;模式为 `HeavilyRedacted`,文件位于 `build/agent-verification/browser/network/`,CI 与 TAP 一起上传。网络请求失败仍使测试失败;排查 `ERR_NO_BUFFER_SPACE` 时同时核对 TAP 与该次浏览器的网络事件,不根据错误字样推断机器资源状态,也不添加放行重试。测试应在用户可感知的行为错误时失败。页面的请求、缓存、选择、错误反馈和路由由组件测试与浏览器测试验证;CSS 层叠、主题、尺寸和交互后的样式由浏览器读取计算值。diff --git a/scripts/adopt_dependency_bump.py b/scripts/adopt_dependency_bump.pyindex e59e42cec..287c86d63 100644--- a/scripts/adopt_dependency_bump.py+++ b/scripts/adopt_dependency_bump.py@@ -47,6 +47,13 @@ ROOT = Path(__file__).resolve().parents[1]#: 可能变的路径,`commands` 是重算命令,`checks` 只核对不产出文件。以 `/` 结尾的条目按#: 目录算,其余按整条路径比。RECIPES = {+ "docker": {+ "label": "应用与工作流 Docker 镜像",+ "manifests": ("Dockerfile", ".github/actions/actionlint/Dockerfile"),+ "derived": (),+ "commands": (),+ "checks": (),+ },"web": {"label": "根 package.json(手工 vendor 的四个 web 包)","manifests": ("package.json", "package-lock.json"),diff --git a/scripts/ci-browser-timings.json b/scripts/ci-browser-timings.jsonnew file mode 100644index 000000000..34ecbaa51--- /dev/null+++ b/scripts/ci-browser-timings.json@@ -0,0 +1,74 @@+{+ "source_run": "https://github.com/peach-mitao/peach/actions/runs/38981261189",+ "seconds": {+ "frontend/e2e/canonical-routes.test.ts": 41.0,+ "frontend/e2e/card-collections.test.ts": 21.2,+ "frontend/e2e/card-layout.test.ts": 37.13,+ "frontend/e2e/catalog-filter.test.ts": 102.54,+ "frontend/e2e/catalog-folders.test.ts": 14.05,+ "frontend/e2e/catalog-list.test.ts": 26.89,+ "frontend/e2e/code-samples.test.ts": 7.59,+ "frontend/e2e/configuration-skeleton.test.ts": 25.43,+ "frontend/e2e/copy-editor.test.ts": 3.18,+ "frontend/e2e/design-cards.test.ts": 88.82,+ "frontend/e2e/design-configuration-controls.test.ts": 39.23,+ "frontend/e2e/design-controls.test.ts": 70.83,+ "frontend/e2e/design-detail-continuation.test.ts": 42.17,+ "frontend/e2e/design-detail.test.ts": 111.62,+ "frontend/e2e/design-follow-alignment.test.ts": 24.49,+ "frontend/e2e/design-manage.test.ts": 123.68,+ "frontend/e2e/design-people.test.ts": 117.51,+ "frontend/e2e/design-seller-identity.test.ts": 17.5,+ "frontend/e2e/design-settings.test.ts": 110.24,+ "frontend/e2e/entity-cold-skeleton.test.ts": 12.53,+ "frontend/e2e/entity-favorites.test.ts": 8.46,+ "frontend/e2e/entity-filter.test.ts": 45.52,+ "frontend/e2e/entity-online.test.ts": 11.69,+ "frontend/e2e/external-playback.test.ts": 9.09,+ "frontend/e2e/fc2-artwork.test.ts": 67.05,+ "frontend/e2e/feed-cover.test.ts": 43.1,+ "frontend/e2e/follow-alias.test.ts": 11.57,+ "frontend/e2e/follow-detail.test.ts": 59.47,+ "frontend/e2e/follow-feed.test.ts": 146.06,+ "frontend/e2e/follow-manage-cache.test.ts": 8.09,+ "frontend/e2e/follow-source-icons.test.ts": 16.13,+ "frontend/e2e/home-feed.test.ts": 11.86,+ "frontend/e2e/home-loading.test.ts": 26.06,+ "frontend/e2e/immerse.test.ts": 20.23,+ "frontend/e2e/index-people.test.ts": 28.27,+ "frontend/e2e/item-detail.test.ts": 216.4,+ "frontend/e2e/item-gallery.test.ts": 66.39,+ "frontend/e2e/jav-comments-paint.test.ts": 8.5,+ "frontend/e2e/jav-detail.test.ts": 51.77,+ "frontend/e2e/jav-discovery-metadata.test.ts": 17.98,+ "frontend/e2e/jav-recommendations.test.ts": 35.52,+ "frontend/e2e/library-completion.test.ts": 14.95,+ "frontend/e2e/library-shortcuts.test.ts": 32.01,+ "frontend/e2e/loading-fidelity.test.ts": 22.53,+ "frontend/e2e/manage-header.test.ts": 50.85,+ "frontend/e2e/management-headings.test.ts": 6.06,+ "frontend/e2e/management-layout.test.ts": 56.8,+ "frontend/e2e/media-byline.test.ts": 10.68,+ "frontend/e2e/media-navigation.test.ts": 10.39,+ "frontend/e2e/offscreen-cards.test.ts": 89.51,+ "frontend/e2e/orphan-table.test.ts": 11.87,+ "frontend/e2e/photo-lightbox.test.ts": 23.54,+ "frontend/e2e/playback-resume.test.ts": 56.46,+ "frontend/e2e/search.test.ts": 63.08,+ "frontend/e2e/settings-panel.test.ts": 67.85,+ "frontend/e2e/sidebar-motion.test.ts": 6.27,+ "frontend/e2e/sidebar.test.ts": 39.41,+ "frontend/e2e/smoke.test.ts": 196.69,+ "frontend/e2e/source-credentials-layout.test.ts": 18.62,+ "frontend/e2e/stage.test.ts": 73.92,+ "frontend/e2e/taste-browsers.test.ts": 7.49,+ "frontend/e2e/theme-switch.test.ts": 3.95,+ "frontend/e2e/toast-accent.test.ts": 40.9,+ "frontend/e2e/toast-layout.test.ts": 6.57,+ "frontend/e2e/tooltip-fidelity.test.ts": 34.43,+ "frontend/e2e/trash-cards.test.ts": 10.05,+ "frontend/e2e/video-wall.test.ts": 144.78,+ "frontend/e2e/want-resources.test.ts": 11.79,+ "frontend/e2e/wide-cover.test.ts": 8.24+ }+}diff --git a/scripts/ci_plan.py b/scripts/ci_plan.pyindex 4483e85ba..64cffecc2 100644--- a/scripts/ci_plan.py+++ b/scripts/ci_plan.py@@ -11,31 +11,85 @@ import sysif not __package__:sys.path.insert(0, str(Path(__file__).resolve().parents[1]))__package__ = "scripts"-from . import test_runner as runner+ROOT = Path(__file__).resolve().parents[1]+++def browser_matrix(root: Path = ROOT, count: int = 6) -> dict:+ """以实测秒数分配文件;每个文件只属于一个独立 runner。"""+ timing_file = root / "scripts/ci-browser-timings.json"+ timings = json.loads(timing_file.read_text(encoding="utf-8"))["seconds"] if timing_file.is_file() else {}+ files = [path.relative_to(root).as_posix() for path in (root / "frontend/e2e").rglob("*.test.ts")]+ if not files or count < 1:+ raise ValueError("浏览器矩阵须包含用例且分片数为正整数")+ groups = [[] for _ in range(min(count, len(files)))]+ totals = [0.0 for _ in groups]+ for name in sorted(files, key=lambda name: (-timings.get(name, 30.0), name)):+ slot = min(range(len(groups)), key=lambda index: (totals[index], index))+ groups[slot].append(name)+ totals[slot] += timings.get(name, 30.0)+ return {"include": [{"index": index, "files": json.dumps(sorted(group)),+ "estimated_seconds": round(totals[index])}+ for index, group in enumerate(groups)]}+++def validate_results(results: dict, required: list[str]) -> None:+ """所选任务全部成功;未选择的任务可以跳过,不能隐藏失败。"""+ if not {"plan", "python", "workflow-lint"}.issubset(required):+ raise ValueError("验证计划缺少必需任务")+ bad = {name: results.get(name, {}).get("result", "missing")+ for name in required if results.get(name, {}).get("result") != "success"}+ bad.update({name: item["result"] for name, item in results.items()+ if item["result"] not in {"success", "skipped"}})+ if bad:+ raise ValueError(f"验证任务未通过:{bad}")def plan(event: str, paths: list[str], contents: dict | None = None) -> dict:+ from . import test_runner as runnerscopes, _ = runner.scopes_for_changes(paths, contents=contents)wide = event == "workflow_dispatch" or "full" in scopesrows = []for system in ("macos-latest", "windows-latest"):- scope = "full" if wide or event == "push" and system == "macos-latest" else (- "core" if system == "windows-latest" else "auto")+ scope = "full" if wide or event == "push" else "auto"# 独立 runner 承担分片,避免共享文件、端口和全量证据锁。- shards = 2 if scope == "full" else 1+ shards = (4 if system == "windows-latest" else 2) if scope == "full" else 1for index in range(shards):rows.append({"os": system, "python": "3.14", "scope": scope,"shard_index": index, "shard_count": shards})wheels = [{"os": "windows-latest", "python": "3.14"},{"os": "macos-latest", "python": "3.14"}]- return {"matrix": {"include": rows}, "wheel_matrix": {"include": wheels}, "wide": wide}+ shared = event == "workflow_dispatch" or "full" in scopes+ browser = shared or any(path.startswith(("src/", "web/", "frontend/", "migrations/", "resources/",+ "tests/", ".github/workflows/test.yml"))+ or path in {"pyproject.toml", "uv.lock"} for path in paths)+ frontend = shared or any(path.startswith(("frontend/", "web/dist/", ".github/workflows/test.yml"))+ for path in paths)+ vendor = shared or any(path.startswith(("web/vendor/", ".github/workflows/test.yml"))+ or path in {"package.json", "package-lock.json", "web/index.html",+ "scripts/vendor_web_dependencies.mjs"} for path in paths)+ wheel = shared or "packaging" in scopes or any(path.startswith(("src/", "migrations/", "web/", "resources/"))+ for path in paths)+ required = ["plan", "python", "workflow-lint"]+ required += [name for enabled, names in ((browser, ["web-e2e"]), (frontend, ["web-bundle"]),+ (vendor, ["web-vendor"]), (wheel, ["wheel-build", "wheel-smoke"]))+ if enabled for name in names]+ return {"matrix": {"include": rows}, "wheel_matrix": {"include": wheels}, "wide": wide,+ "browser_matrix": browser_matrix(), "browser": browser, "frontend": frontend,+ "vendor": vendor, "wheel": wheel, "required_jobs": required}def main() -> None:parser = argparse.ArgumentParser(description=__doc__)- parser.add_argument("--event", required=True, choices=("push", "pull_request", "workflow_dispatch"))- parser.add_argument("--base", required=True)+ parser.add_argument("--event", choices=("push", "pull_request", "workflow_dispatch"))+ parser.add_argument("--base")+ parser.add_argument("--verify-results", action="store_true")args = parser.parse_args()+ if args.verify_results:+ validate_results(json.loads(os.environ["RESULTS"]), json.loads(os.environ["REQUIRED_JOBS"]))+ return+ if not args.event or not args.base:+ parser.error("生成计划需要 --event 与 --base")+ from . import test_runner as runnerroot = Path(__file__).resolve().parents[1]try:paths = runner.changed_files(root, args.base)@@ -46,8 +100,7 @@ def main() -> None:print(json.dumps(result, ensure_ascii=False, indent=2))if output := os.environ.get("GITHUB_OUTPUT"):with Path(output).open("a", encoding="utf-8") as stream:- # `wide` 给 `web-e2e` job 的执行条件用:全量矩阵已含 `web` 域,它就不再跑。- for key in ("matrix", "wheel_matrix", "wide"):+ for key in result:stream.write(f"{key}={json.dumps(result[key])}\n")diff --git a/scripts/npm_audit.py b/scripts/npm_audit.pynew file mode 100644index 000000000..50d1291fe--- /dev/null+++ b/scripts/npm_audit.py@@ -0,0 +1,62 @@+"""按漏洞严重性判定 npm 审计,仅为临时网络错误退避重试。"""+from __future__ import annotations++import argparse+import json+from pathlib import Path+import shutil+import subprocess+import time++TRANSIENT = {"EAI_AGAIN", "ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND",+ "E429", "E500", "E502", "E503", "E504"}+++def classify(payload: dict, returncode: int) -> str:+ error = payload.get("error") or {}+ if not isinstance(error, dict):+ return "error"+ if error:+ return "retry" if error.get("code") in TRANSIENT else "error"+ counts = payload.get("metadata", {}).get("vulnerabilities")+ if not isinstance(counts, dict) or not {"high", "critical"}.issubset(counts):+ return "error"+ if counts["high"] or counts["critical"]:+ return "vulnerable"+ return "clean" if returncode == 0 else "error"+++def audit(project: Path, *, runner=subprocess.run, sleep=time.sleep) -> int:+ for attempt in range(3):+ try:+ result = runner([shutil.which("npm") or "npm", "audit", "--json", "--audit-level=high"],+ cwd=project, capture_output=True, text=True, encoding="utf-8", timeout=90)+ try:+ payload = json.loads(result.stdout)+ if not isinstance(payload, dict):+ raise ValueError("审计结果不是 JSON 对象")+ except (ValueError, TypeError):+ print(result.stdout or result.stderr)+ return 1+ decision = classify(payload, result.returncode)+ print(json.dumps({"attempt": attempt + 1, "project": str(project),+ "decision": decision, "audit": payload}, ensure_ascii=False), flush=True)+ except subprocess.TimeoutExpired:+ decision = "retry"+ print(f"npm audit 第 {attempt + 1} 次超时", flush=True)+ if decision == "clean":+ return 0+ if decision != "retry" or attempt == 2:+ return 1+ sleep(15 * (2 ** attempt))+ return 1+++def main() -> int:+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--prefix", type=Path, default=Path("."))+ return audit(parser.parse_args().prefix.resolve())+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/scripts/test_runner.py b/scripts/test_runner.pyindex d4437c1eb..8a6a37157 100644--- a/scripts/test_runner.py+++ b/scripts/test_runner.py@@ -504,6 +504,11 @@ CI_FRONTEND_TESTS = frozenset({"test_frontend_build.VitestTests.test_the_island_suite_passes",})+CI_BROWSER_TESTS = frozenset({+ "test_web_e2e.WebE2ESmokeTests.test_every_route_holds_the_layout_and_runtime_invariants",+ "test_web_e2e.SetupE2ETests.test_the_first_run_page_writes_errors_back_and_finishes",+})+def ci_frontend_delegated() -> bool:"""Test 工作流的 Python 与浏览器任务由 web-bundle 承担前端工具检查。"""@@ -518,7 +523,8 @@ def without_ci_frontend_tests(suite: unittest.TestSuite) -> unittest.TestSuite:for test in suite:if isinstance(test, unittest.TestSuite):selected.addTests(without_ci_frontend_tests(test))- elif test.id() not in CI_FRONTEND_TESTS:+ elif test.id() not in CI_FRONTEND_TESTS and not (+ os.environ.get("GITHUB_JOB") == "python" and test.id() in CI_BROWSER_TESTS):selected.addTest(test)return selecteddiff --git a/tests/support/web.py b/tests/support/web.pynew file mode 100644index 000000000..6041f63d9--- /dev/null+++ b/tests/support/web.py@@ -0,0 +1,14 @@+"""HTTP 请求契约夹具;后台服务生命周期由集成用例验证。"""+from contextlib import contextmanager+++@contextmanager+def route_client(app):+ """请求经过真实路由、中间件与依赖,只管理 HTTP 客户端的关闭。"""+ from fastapi.testclient import TestClient++ client = TestClient(app)+ try:+ yield client+ finally:+ client.close()diff --git a/tests/test_dependency_policy.py b/tests/test_dependency_policy.pyindex 958ace3c9..9b41280b2 100644--- a/tests/test_dependency_policy.py+++ b/tests/test_dependency_policy.py@@ -9,6 +9,7 @@ import sysimport tempfileimport tomllibimport unittest+from unittest import mockfrom scripts import adopt_dependency_bump as adoptfrom tests.support.gitrepo import seed_repository@@ -16,6 +17,41 @@ from tests.support.gitrepo import seed_repositoryROOT = Path(__file__).resolve().parents[1]+class NpmAuditTests(unittest.TestCase):+ def test_docker_dependency_updates_have_a_takeover_recipe(self):+ for manifest in ('Dockerfile', '.github/actions/actionlint/Dockerfile'):+ self.assertEqual(adopt.recipe_for([manifest])[0], 'docker')++ def test_high_and_critical_vulnerabilities_fail_without_network_retries(self):+ from scripts import npm_audit+ for severity in ('high', 'critical'):+ counts = {'high': 0, 'critical': 0, severity: 1}+ with self.subTest(severity=severity):+ response = subprocess.CompletedProcess([], 1, json.dumps(+ {'metadata': {'vulnerabilities': counts}}), '')+ run, sleep = mock.Mock(return_value=response), mock.Mock()+ self.assertEqual(npm_audit.audit(ROOT, runner=run, sleep=sleep), 1)+ self.assertEqual(run.call_count, 1)+ sleep.assert_not_called()++ def test_temporary_registry_failures_retry_and_clean_results_pass(self):+ from scripts import npm_audit+ transient = subprocess.CompletedProcess([], 1, '{"error":{"code":"E503"}}', '')+ clean = subprocess.CompletedProcess([], 0, '{"metadata":{"vulnerabilities":{"high":0,"critical":0}}}', '')+ run, sleep = mock.Mock(side_effect=[transient, transient, clean]), mock.Mock()+ self.assertEqual(npm_audit.audit(ROOT, runner=run, sleep=sleep), 0)+ self.assertEqual(run.call_count, 3)+ self.assertEqual(sleep.call_args_list, [mock.call(15), mock.call(30)])++ def test_network_exhaustion_and_malformed_results_never_pass(self):+ from scripts import npm_audit+ for body, attempts in (('{"error":{"code":"E503"}}', 3), ('not json', 1), ('{}', 1)):+ with self.subTest(body=body):+ run = mock.Mock(return_value=subprocess.CompletedProcess([], 1, body, ''))+ self.assertEqual(npm_audit.audit(ROOT, runner=run, sleep=mock.Mock()), 1)+ self.assertEqual(run.call_count, attempts)++def git(repo: Path, *args: str) -> str:return subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True,text=True, encoding="utf-8").stdout.strip()diff --git a/tests/test_scan.py b/tests/test_scan.pyindex 966d12354..6991f8c56 100644--- a/tests/test_scan.py+++ b/tests/test_scan.py@@ -72,11 +72,11 @@ class WindowsShapeTests(_ScanCase):self.assertTrue(Path(path).is_file(), path)def test_scanned_video_is_visible_without_a_thumbnail_filter(self):- from fastapi.testclient import TestClient+ from support.web import route_clientfrom peach.api import create_appfrom peach.config import PeachSettingsself._scan(str(self.media), declared_roots={"local": (str(self.media),)}, windows=True)- with TestClient(create_app(PeachSettings(db_path=self.db, configured=True, token=""))) as client:+ with route_client(create_app(PeachSettings(db_path=self.db, configured=True, token=""))) as client:self.assertEqual(client.get('/api/items').json()['total'], 1)self.assertEqual(client.get('/api/items?thumb=0').json()['total'], 1)self.assertEqual(client.get('/api/items?thumb=1').json()['total'], 0)diff --git a/tests/test_subtitles.py b/tests/test_subtitles.pyindex 8974783ff..493904c6a 100644--- a/tests/test_subtitles.py+++ b/tests/test_subtitles.py@@ -333,10 +333,10 @@ class SubtitleApiTests(unittest.TestCase):connection.close()def _client(self):- from fastapi.testclient import TestClient+ from support.web import route_clientfrom peach.api import create_appfrom peach.config import PeachSettings- return TestClient(create_app(PeachSettings(+ return route_client(create_app(PeachSettings(db_path=self.db, configured=True, token="",allowed_media_roots=(self.media,))))@@ -378,13 +378,13 @@ class SubtitleApiTests(unittest.TestCase):self.assertEqual(client.get("/api/assets/404/subtitles").status_code, 404)def test_the_endpoints_require_the_same_token_as_the_rest(self):- from fastapi.testclient import TestClient+ from support.web import route_clientfrom peach.api import create_appfrom peach.config import PeachSettingsapp = create_app(PeachSettings(db_path=self.db, configured=True, token="secret",allowed_media_roots=(self.media,)))- with TestClient(app) as client:+ with route_client(app) as client:self.assertEqual(client.get("/api/assets/1/subtitles").status_code, 401)self.assertEqual(client.get("/api/assets/1/subtitles/0?t=secret").status_code, 200)diff --git a/tests/test_test_planning.py b/tests/test_test_planning.pyindex 4de9977e5..bbcb5119e 100644--- a/tests/test_test_planning.py+++ b/tests/test_test_planning.py@@ -57,6 +57,22 @@ class CIFrontendOwnershipTests(unittest.TestCase):self.assertCountEqual(serial, shards[0] + shards[1])self.assertEqual(len(serial), len(set(serial)))+ def test_python_jobs_delegate_browser_cases_and_keep_their_contract_tests(self):+ def collect(environment):+ with patch.dict(os.environ, environment, clear=True), patch.object(+ runner, 'selected_files', return_value=(runner.TESTS / 'test_web_e2e.py',)):+ return set(self.ids(runner.build_suite('web')))+ local = collect({})+ selected = collect(self.CI)+ self.assertEqual(local - selected, {+ 'test_web_e2e.WebE2ESmokeTests.test_every_route_holds_the_layout_and_runtime_invariants',+ 'test_web_e2e.SetupE2ETests.test_the_first_run_page_writes_errors_back_and_finishes',+ })+ self.assertTrue(any('.MissingPrerequisiteTests.' in name for name in selected))+ for environment in ({**self.CI, 'GITHUB_JOB': 'web-e2e'},+ {**self.CI, 'GITHUB_WORKFLOW': 'Release'}):+ self.assertEqual(collect(environment), local)+def test_delegated_ci_returns_results_without_local_evidence(self):for scope in ('web', 'full'):for success, count, expected in ((True, 3, 0), (False, 3, 1), (True, 0, 1)):@@ -152,13 +168,43 @@ class TestPlanningTests(unittest.TestCase):def test_matrix_keeps_full_mainline_and_platform_coverage(self):result = ci_plan.plan('push', ['web/app.js'])rows = result['matrix']['include']- self.assertEqual(len([r for r in rows if r['scope'] == 'full']), 2)- self.assertTrue(all(r['os'] == 'macos-latest' for r in rows if r['scope'] == 'full'))+ self.assertEqual(len([r for r in rows if r['scope'] == 'full']), 6)+ self.assertEqual({r['os'] for r in rows}, {'windows-latest', 'macos-latest'})self.assertEqual({r['python'] for r in rows}, {'3.14'})- self.assertEqual([(r['os'], r['scope']) for r in rows if r['scope'] != 'full'],- [('windows-latest', 'core')])+ self.assertTrue(all(r['scope'] == 'full' for r in rows))self.assertEqual(len(result['wheel_matrix']['include']), 2)+ def test_browser_partitions_cover_every_file_once_and_balance_recorded_duration(self):+ matrix = ci_plan.browser_matrix()['include']+ groups = [json.loads(row['files']) for row in matrix]+ expected = {path.relative_to(runner.ROOT).as_posix()+ for path in (runner.ROOT / 'frontend/e2e').rglob('*.test.ts')}+ collected = [name for group in groups for name in group]+ self.assertEqual(set(collected), expected)+ self.assertEqual(len(collected), len(set(collected)))+ self.assertTrue(all(groups))+ costs = [row['estimated_seconds'] for row in matrix]+ self.assertLess(max(costs) - min(costs), 60)++ def test_document_changes_avoid_optional_jobs_and_unknown_changes_require_them(self):+ documents = ci_plan.plan('pull_request', ['docs/TESTING.md'])+ self.assertEqual(documents['required_jobs'], ['plan', 'python', 'workflow-lint'])+ unknown = ci_plan.plan('pull_request', ['unknown.file'])+ self.assertLessEqual({'web-e2e', 'web-bundle', 'web-vendor', 'wheel-smoke'},+ set(unknown['required_jobs']))++ def test_result_gate_rejects_missing_failed_cancelled_or_required_skipped_jobs(self):+ required = ['plan', 'python', 'workflow-lint', 'web-e2e']+ passed = {name: {'result': 'success'} for name in required}+ ci_plan.validate_results({**passed, 'web-vendor': {'result': 'skipped'}}, required)+ for result in ('failure', 'cancelled', 'skipped'):+ with self.subTest(result=result), self.assertRaises(ValueError):+ ci_plan.validate_results({**passed, 'web-e2e': {'result': result}}, required)+ with self.assertRaises(ValueError):+ ci_plan.validate_results({name: value for name, value in passed.items() if name != 'python'}, required)+ with self.assertRaises(ValueError):+ ci_plan.validate_results(passed, [])+def test_dependency_and_manual_runs_cover_both_systems(self):for event, paths in [('push', ['uv.lock']), ('pull_request', ['migrations/0025.sql']),('workflow_dispatch', [])]: