From 240896329518d8fb669a8c6d92abb14187ba22a4 Mon Sep 17 00:00:00 2001 From: wangyu <410167048@qq.com> Date: Mon, 16 Nov 2026 17:47:21 +0800 Subject: [PATCH 1/2] feat(pre-commit): enhance testing framework with explicit test marks and new scripts - Added a pre-commit hook to check for explicit test marks in Python and JavaScript files. - Updated `package.json` to include new test commands for unit tests and browser tests. - Introduced `check_test_marks.py` for Python and `check-test-marks.mjs` for JavaScript to validate test classifications. - Created `select_checks.py` to determine the scope of heavy checks based on the PR diff. - Added new scripts for listing browser tests and running unit tests with specified layers and hardware. - Updated `pyproject.toml` to register new pytest markers for hardware and CI layers. - Enhanced documentation to reflect changes in test classification and validation processes. Signed-off-by: wangyu <410167048@qq.com> --- .github/workflows/pre-commit.yml | 55 ++ .github/workflows/release-checks.yml | 35 +- .pre-commit-config.yaml | 9 + docs/architecture/test-contracts.md | 10 +- docs/development/validation.md | 84 ++- package.json | 7 +- pyproject.toml | 5 + scripts/check-browser-manifest.mjs | 5 + scripts/list-browser-tests.mjs | 11 + scripts/pre-commit/check-test-marks.mjs | 10 + scripts/pre-commit/check_test_marks.py | 146 +++++ scripts/{ci => pre-commit}/select_checks.py | 0 scripts/pre-commit/test-marks.ts | 107 ++++ scripts/run-browser-suite.mjs | 28 +- scripts/run-unit-tests.mjs | 20 + tests/browser/manifest.json | 290 ++++++--- tests/frontend-manifest.json | 635 ++++++++++++++++++++ tests/testMarks.test.ts | 106 ++++ tests/test_agent_artifacts.py | 3 + tests/test_agent_citations.py | 3 + tests/test_agent_gateway.py | 3 + tests/test_agent_metadata.py | 3 + tests/test_agent_tools_voices.py | 3 + tests/test_app_settings.py | 3 + tests/test_asset_names.py | 3 + tests/test_assistant_conversations.py | 3 + tests/test_bench_creation_projects.py | 4 + tests/test_bigmodel_image.py | 3 + tests/test_bigmodel_video.py | 3 + tests/test_canvas_sources.py | 3 + tests/test_capability_contract.py | 3 + tests/test_ci_hardware.py | 138 +++++ tests/test_ci_layers.py | 2 +- tests/test_ci_profile.py | 2 +- tests/test_ci_scope.py | 24 +- tests/test_ci_summary.py | 2 +- tests/test_cli.py | 3 + tests/test_cli_discovery.py | 2 +- tests/test_creation_api.py | 3 + tests/test_creation_artifacts.py | 3 + tests/test_creation_assembly.py | 3 + tests/test_creation_assets.py | 3 + tests/test_creation_canvas_service.py | 3 + tests/test_creation_contracts.py | 3 + tests/test_creation_crop.py | 3 + tests/test_creation_generation_service.py | 3 + tests/test_creation_history_service.py | 3 + tests/test_creation_image_edits.py | 3 + tests/test_creation_layers.py | 4 + tests/test_creation_media_publication.py | 3 + tests/test_creation_node_versions.py | 3 + tests/test_creation_parameters.py | 3 + tests/test_creation_reference_editor.py | 3 + tests/test_creation_storage.py | 3 + tests/test_creation_timeline_render.py | 3 + tests/test_creation_timeline_text.py | 3 + tests/test_creation_tool_drafts.py | 3 + tests/test_creation_workflow.py | 3 + tests/test_daily_benchmark.py | 4 + tests/test_deepseek_engine.py | 2 +- tests/test_deepseek_runtime.py | 3 + tests/test_directory_links.py | 3 + tests/test_execution_files.py | 3 + tests/test_fasth3_inputs.py | 3 + tests/test_ffmpeg_frame_sync.py | 3 + tests/test_generation_errors.py | 3 + tests/test_generation_recovery.py | 3 + tests/test_heif.py | 3 + tests/test_hidden_reference_roundtrip.py | 3 + tests/test_installation.py | 4 + tests/test_jiuwenswarm_engine.py | 2 +- tests/test_jiuwenswarm_media.py | 1 + tests/test_jiuwenswarm_runtime.py | 3 + tests/test_kling_video.py | 3 + tests/test_launcher.py | 4 + tests/test_layer_boundary.py | 4 + tests/test_library.py | 5 +- tests/test_local_json.py | 3 + tests/test_localization.py | 4 + tests/test_minimax_image.py | 3 + tests/test_minimax_speech.py | 3 + tests/test_minimax_video.py | 3 + tests/test_model_catalog.py | 3 + tests/test_model_configs.py | 3 + tests/test_model_gateway.py | 3 + tests/test_model_http_logging.py | 3 + tests/test_model_reasoning_trace.py | 4 + tests/test_moss.py | 3 + tests/test_multimodal_references.py | 3 + tests/test_native_runtime.py | 2 +- tests/test_native_sessions.py | 3 + tests/test_nightly_perf_artifact.py | 3 + tests/test_openai_images.py | 3 + tests/test_owner_rights.py | 3 + tests/test_owner_rights_journal.py | 3 + tests/test_owner_rights_lifecycle.py | 2 +- tests/test_owner_rights_resume.py | 2 +- tests/test_posix_execution_files.py | 3 + tests/test_process_helpers.py | 3 + tests/test_public_target.py | 3 + tests/test_query_guidance.py | 3 + tests/test_rename.py | 3 + tests/test_result_download_security.py | 3 + tests/test_retired_entry.py | 4 + tests/test_rule_facts.py | 3 + tests/test_runtime_catalog.py | 3 + tests/test_runtime_readiness.py | 3 + tests/test_self_hosted.py | 3 + tests/test_self_hosted_proxy.py | 3 + tests/test_self_hosted_queue.py | 3 + tests/test_skill_snapshot.py | 3 + tests/test_subject_library.py | 4 + tests/test_timeline_fonts.py | 3 + tests/test_timeline_packages.py | 3 + tests/test_timeline_source_connections.py | 4 + tests/test_tool_lifecycle.py | 3 + tests/test_tool_task_history.py | 3 + tests/test_tool_tasks.py | 3 + tests/test_video_capabilities.py | 3 + tests/test_video_resolution.py | 3 + tests/test_vllm_omni_h3.py | 3 + tests/test_vllm_omni_image.py | 3 + tests/test_voice_library.py | 3 + tests/test_zhipu.py | 3 + 124 files changed, 1910 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 scripts/list-browser-tests.mjs create mode 100644 scripts/pre-commit/check-test-marks.mjs create mode 100644 scripts/pre-commit/check_test_marks.py rename scripts/{ci => pre-commit}/select_checks.py (100%) create mode 100644 scripts/pre-commit/test-marks.ts create mode 100644 scripts/run-unit-tests.mjs create mode 100644 tests/frontend-manifest.json create mode 100644 tests/testMarks.test.ts create mode 100644 tests/test_ci_hardware.py diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..f4d667426 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,55 @@ +name: Pre-commit + +on: + workflow_call: + outputs: + run-heavy: + description: Whether heavy checks are required / 是否需要重检查 + value: ${{ jobs.check.outputs.run-heavy }} + scope-reason: + description: Reason for the selected scope / 检查范围依据 + value: ${{ jobs.check.outputs.scope-reason }} + changed-files: + description: Number of changed paths / 变更路径数量 + value: ${{ jobs.check.outputs.changed-files }} + workflow_dispatch: + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + outputs: + run-heavy: ${{ steps.scope.outputs.run-heavy }} + scope-reason: ${{ steps.scope.outputs.scope-reason }} + changed-files: ${{ steps.scope.outputs.changed-files }} + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + fetch-depth: ${{ (github.event_name == 'pull_request' || (github.event_name == 'push' && github.event.before && github.event.before != '0000000000000000000000000000000000000000')) && '0' || '1' }} + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + with: + python-version: '3.12' + cache: pip + cache-dependency-path: requirements-static.txt + - name: Install static tooling + run: python -m pip install -r requirements-static.txt + - name: Check static configuration + env: + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + PUSH_BASE_SHA: ${{ github.event.before }} + run: | + if [ "$GITHUB_EVENT_NAME" = pull_request ]; then + python -m pre_commit run --from-ref "$PR_BASE_SHA" --to-ref HEAD + elif [ "$GITHUB_EVENT_NAME" = push ] && [ -n "$PUSH_BASE_SHA" ] && [ "$PUSH_BASE_SHA" != 0000000000000000000000000000000000000000 ]; then + python -m pre_commit run --from-ref "$PUSH_BASE_SHA" --to-ref HEAD + else + python -m pre_commit run --all-files + fi + - id: scope + name: Select check scope / 判断检查范围 + env: + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: python scripts/pre-commit/select_checks.py diff --git a/.github/workflows/release-checks.yml b/.github/workflows/release-checks.yml index 9a8ee4500..3e42fb07a 100644 --- a/.github/workflows/release-checks.yml +++ b/.github/workflows/release-checks.yml @@ -22,40 +22,7 @@ permissions: jobs: static: if: inputs.static-checks - runs-on: ubuntu-22.04 - timeout-minutes: 10 - outputs: - run-heavy: ${{ steps.scope.outputs.run-heavy }} - scope-reason: ${{ steps.scope.outputs.scope-reason }} - changed-files: ${{ steps.scope.outputs.changed-files }} - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - with: - fetch-depth: ${{ (github.event_name == 'pull_request' || (github.event_name == 'push' && github.event.before && github.event.before != '0000000000000000000000000000000000000000')) && '0' || '1' }} - - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: '3.12' - cache: pip - cache-dependency-path: requirements.txt - - name: Install static tooling - run: python -m pip install -r requirements-static.txt - - name: Check static configuration - env: - PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} - PUSH_BASE_SHA: ${{ github.event.before }} - run: | - if [ "$GITHUB_EVENT_NAME" = pull_request ]; then - python -m pre_commit run --from-ref "$PR_BASE_SHA" --to-ref HEAD - elif [ "$GITHUB_EVENT_NAME" = push ] && [ -n "$PUSH_BASE_SHA" ] && [ "$PUSH_BASE_SHA" != 0000000000000000000000000000000000000000 ]; then - python -m pre_commit run --from-ref "$PUSH_BASE_SHA" --to-ref HEAD - else - python -m pre_commit run --all-files - fi - - id: scope - name: Select check scope / 判断检查范围 - env: - PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: python scripts/ci/select_checks.py + uses: ./.github/workflows/pre-commit.yml python: needs: static diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0483bf1b6..514a473c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,15 @@ default_install_hook_types: [pre-commit] default_stages: [pre-commit] repos: + - repo: local + hooks: + - id: check-test-marks + name: Check explicit test marks + entry: python scripts/pre-commit/check_test_marks.py + language: python + pass_filenames: false + files: ^(tests/|scripts/pre-commit/|pyproject\.toml$|\.pre-commit-config\.yaml$) + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: diff --git a/docs/architecture/test-contracts.md b/docs/architecture/test-contracts.md index f4f73081b..a2f2c5a86 100644 --- a/docs/architecture/test-contracts.md +++ b/docs/architecture/test-contracts.md @@ -41,13 +41,17 @@ Business areas under `frontend/` and `python/` may expand with coverage. Move on | --- | --- | --- | | Directory / 目录 | `frontend`, `python`, `creation`, `agent`, etc. | Organization and discovery only; never pytest CI-layer marks. / 仅组织与发现,不是 pytest CI 层 mark。 | | CI layer / CI 层 | `ready`, `merge`, `nightly` | At most one per Python case; unmarked cases remain ready during migration. PR runs ready, queue runs ready + merge, nightly runs nightly plus intentional watchlist reruns after cutover. / 每个 Python 用例至多一个;迁移期未标记仍为 ready。切换后 PR 跑 ready,队列跑 ready + merge,nightly 跑 nightly 和明确的 watchlist 重跑。 | -| Hardware platform / 机型 | Target `cpu`; accelerators and SKUs later / 目标 `cpu`,加速器与 SKU 后续 | Independent of the CI layer. Current default cases are CPU-only; registration/tagging/selection is follow-up work. Do not infer hardware from a folder or capability skip. / 与 CI 层正交;现有默认用例只需 CPU,注册、打标和筛选后续交付,不从目录或能力跳过推断机型。 | +| Hardware platform / 机型 | `cpu`; reserved `cuda`, `rocm`, `xpu`, `npu` / `cpu` 与预留平台 | Independent of the CI layer. Current Python test modules carry `pytest.mark.cpu`; missing, unknown or conflicting hardware marks fail the shared pre-commit check; runtime collection never adds marks. Workflow filters remain unchanged. Do not infer hardware from a folder or capability skip. / 与 CI 层正交;现有 Python 测试模块显式标记 `cpu`,缺失、未知或冲突的机型标记由共享 pre-commit 检查拒绝,运行时不补标;工作流筛选保持不变,不从目录或能力跳过推断机型。 | | Capability / 能力 | `requires_ffmpeg`, `requires_posix` | Skip with a reason when unavailable; not lane or hardware selectors. / 缺能力时带原因跳过,不用于分车道或分机型。 | | Browser lane / 浏览器车道 | `gate`, `extended`, `extendedFixture`, `production`, `perf`, `manual` | Only `tests/browser/manifest.json` owns membership; these are not pytest marks. / 归属只由 manifest 管理,不是 pytest mark。 | -`unit`、`integration`、`e2e` 可以描述场景,但不注册为 CI 层 mark。`gpu`、`cuda`、`rocm`、`xpu`、`npu` 与 SKU/卡数只预留后续计划;真实硬件车道需要负责人、环境和凭证方案,后续通过共享 helper 引入平台与 SKU,不要求本季度运行。 +TypeScript 单元与 JavaScript 浏览器测试也使用相同的 `ready / merge / nightly`、`cpu` 及预留平台词汇。前端以 `tests/frontend-manifest.json` 按文件登记;浏览器以现有 manifest 按旅程登记 `layer` 和 `hardware`,与运行环境 lane 分开。两条轴均须显式声明,缺失或未知值拒绝;helper 不标为测试。文件内需要不同分类时先拆分,不用标题匹配模拟逐用例标记。筛选入口、清单审计与当前执行边界见[验证指南](../development/validation.md#跨语言测试标记--cross-language-test-marks)。 -`unit`, `integration` and `e2e` may describe scenarios but are not CI-layer marks. `gpu`, `cuda`, `rocm`, `xpu`, `npu`, SKUs and card counts are reserved for follow-up plans. Real-hardware lanes need owners, environments and credential arrangements; introduce platforms and SKUs through a shared helper when needed, without requiring those lanes to run this quarter. +TypeScript units and JavaScript browser journeys use the same `ready / merge / nightly`, `cpu` and reserved-platform vocabulary. Register unit files in `tests/frontend-manifest.json`; register journey `layer` and `hardware` in the browser manifest, independently of environment lanes. Both axes must be explicit; missing or unknown values fail, and helpers carry no test marks. Split files when classifications differ rather than encoding per-case marks in test titles. The [validation guide](../development/validation.md#跨语言测试标记--cross-language-test-marks) owns selectors, catalog auditing and current execution boundaries. + +`unit`、`integration`、`e2e` 可以描述场景,但不注册为 CI 层 mark。`cuda`、`rocm`、`xpu`、`npu` 已注册为预留名称,本季度不新增对应硬件用例或 CI 车道;SKU 与 `cards_n` 暂不注册。真实硬件车道需要负责人、环境和凭证方案,后续通过共享 helper 引入平台与 SKU,不要求本季度运行。 + +`unit`, `integration` and `e2e` may describe scenarios but are not CI-layer marks. `cuda`, `rocm`, `xpu` and `npu` are registered reserved names, with no accelerator cases or CI lanes added this quarter. SKUs and `cards_n` are not registered yet. Real-hardware lanes need owners, environments and credential arrangements; introduce platforms and SKUs through a shared helper when needed, without requiring those lanes to run this quarter. L1 包含单元、静态与构建;L2 是模型替身浏览器 E2E;L3 是 flake 分诊与扩展覆盖;L4 是生产构建、性能与输出;L5 是后续稳定性与恢复。它们表示覆盖范围,不等于目录、Python CI 层或执行阶段。切换前保留的 main HEAD 复核和 gate-parity 属于过渡执行,不是未来 nightly 永久重复门槛的要求。 diff --git a/docs/development/validation.md b/docs/development/validation.md index 641691a8d..663e6cebe 100644 --- a/docs/development/validation.md +++ b/docs/development/validation.md @@ -53,9 +53,9 @@ Budgets measure stage wall time, not the sum of parallel job limits, and never j ### 过渡与必需检查 / Transition and required checks -当前 [`ci.yml`](../../.github/workflows/ci.yml) 对 PR 和 main push 开启静态门禁;纯文档 PR 按下方白名单跳过重检查,其余仍跑全量 Python。[`nightly.yml`](../../.github/workflows/nightly.yml) 保留 gate-parity 和全量 Python flake 分诊。已注册 CI 层 mark,但机型轴、安全扫描、合并队列与 main 证据归集仍是后续交付。当前 job 限额见下方静态检查说明;PR 和队列各 30 分钟是阶段目标,不代表已强制端到端总上限。 +当前 [`ci.yml`](../../.github/workflows/ci.yml) 对 PR 和 main push 开启静态门禁;纯文档 PR 按下方白名单跳过重检查,其余仍跑全量 Python。[`nightly.yml`](../../.github/workflows/nightly.yml) 保留 gate-parity 和全量 Python flake 分诊。已注册 CI 层与机型 mark;安全扫描、合并队列与 main 证据归集仍是后续交付。当前 job 限额见下方静态检查说明;PR 和队列各 30 分钟是阶段目标,不代表已强制端到端总上限。 -Currently [`ci.yml`](../../.github/workflows/ci.yml) enables static checks on PRs and main pushes. Documentation-only PRs use the allowlist below to skip heavy checks; other changes retain full Python selection. [`nightly.yml`](../../.github/workflows/nightly.yml) retains gate parity and full-suite Python flake triage. CI-layer marks are registered; hardware tagging, security scanning, the merge queue and main evidence collection remain follow-up delivery. Current job limits are documented below; 30 minutes each for PR and queue are stage targets, not enforced end-to-end deadlines. +Currently [`ci.yml`](../../.github/workflows/ci.yml) enables static checks on PRs and main pushes. Documentation-only PRs use the allowlist below to skip heavy checks; other changes retain full Python selection. [`nightly.yml`](../../.github/workflows/nightly.yml) retains gate parity and full-suite Python flake triage. CI-layer and hardware-platform marks are registered; security scanning, the merge queue and main evidence collection remain follow-up delivery. Current job limits are documented below; 30 minutes each for PR and queue are stage targets, not enforced end-to-end deadlines. - 本地 hook 可未安装或被绕过,不能在 GitHub 上普遍阻止 PR 创建。必需 CI 必须复核同一配置;静态失败阻止启动重测试,并使稳定汇总检查失败。/ Local hooks can be absent or bypassed and cannot universally prevent PR creation. Required CI repeats the same configuration; static failure blocks heavy jobs and fails the stable aggregate. - 纯文档变更可跳过重 Python/浏览器任务,但必须保留稳定的必需检查,报告跳过依据并成功结束。合并队列按整个 merge-group 差异判断,不能只看最后一个 PR;无法确定范围时执行完整门禁。/ Documentation-only changes may skip heavy Python/browser jobs, but a stable required check must report the reason and succeed. Queue filtering covers the whole merge-group diff, not only its last PR; uncertain scope runs the full gate. @@ -98,9 +98,13 @@ The range command checks committed changes from the merge base to HEAD, excludin Checks cover YAML/JSON/TOML and Python syntax, conflict markers, Python debug statements, file endings, mixed line endings, trailing whitespace and GitHub Actions workflow syntax. Markdown hard line breaks are preserved. actionlint disables optional shellcheck/pyflakes integrations to avoid extra platform toolchains. GPU/CUDA, Buildkite, model-specific checks, commit sign-off rewriting and repository-wide typing/style migrations are excluded. -本地 hook 可未安装或被绕过,不能保证阻止 GitHub 上所有 PR 的创建。PR 与 main push 的 Release checks 在独立 static job 中安装 `requirements-static.txt` 并执行同一配置。PR 检查 base 到测试用合并提交的差异,push 检查 before 到 HEAD 的差异;只有需要范围比较的 static checkout 拉取完整历史,其他 job 保持浅克隆。手动或首次 push 的全仓审计无需完整历史。 +本地 hook 可未安装或被绕过,不能保证阻止 GitHub 上所有 PR 的创建。[`pre-commit.yml`](../../.github/workflows/pre-commit.yml) 独立维护静态检查,可通过 `workflow_dispatch` 单独运行,也通过 `workflow_call` 提供给 Release checks 的 static job。PR 与 main push 由现有 CI 调用一次,不另设重复事件触发;static 成功后才启动重检查。工作流安装 `requirements-static.txt` 并执行同一本地配置,输出范围判定供下游使用。PR 检查 base 到测试用合并提交的差异,push 检查 before 到 HEAD 的差异;只有需要范围比较的 static checkout 拉取完整历史,其他 job 保持浅克隆。手动或首次 push 的全仓审计无需完整历史。 -Local hooks can be absent or bypassed. PR and main Release checks run the same configuration in a separate static job. PRs compare base to tested merge HEAD; pushes compare before to HEAD. Only the static checkout needing a range comparison fetches full history; other jobs use shallow checkouts. Manual/initial-push full-file audits do not need full history. +Local hooks can be absent or bypassed. [`pre-commit.yml`](../../.github/workflows/pre-commit.yml) owns static checks independently, supports standalone `workflow_dispatch`, and exposes `workflow_call` for the Release checks static job. Existing CI calls it once on PRs and main pushes, without duplicate event triggers; heavy checks wait for static success. It installs `requirements-static.txt`, runs the same local configuration and returns scope outputs to downstream jobs. PRs compare base to tested merge HEAD; pushes compare before to HEAD. Only the static checkout needing a range comparison fetches full history; other jobs use shallow checkouts. Manual/initial-push full-file audits do not need full history. + +提交前脚本集中在 `scripts/pre-commit/`:`check_test_marks.py` 执行全语言显式标记检查,`test-marks.ts` 与 `check-test-marks.mjs` 提供 Node 侧共享分类及检查入口,`select_checks.py` 在静态检查通过后判定重检查范围。`scripts/ci/check_test_layers.py` 仍负责测试收集/执行报告审计,不属于提交前静态检查;汇总回执也留在 `scripts/ci/`。移动脚本不改变原有 mark、lane、必需汇总名称、失败处理或 Nightly 的完整门槛。 + +Pre-commit tooling lives in `scripts/pre-commit/`: `check_test_marks.py` checks explicit classifications across languages; `test-marks.ts` and `check-test-marks.mjs` provide the shared Node classification/check entry; `select_checks.py` selects the heavy-check scope after static success. `scripts/ci/check_test_layers.py` remains a post-collection/execution report audit, while receipt aggregation also stays in `scripts/ci/`. Moving scripts changes no marks, lanes, required aggregate names, failure behavior or Nightly full gate. 静态通过后,范围检查仅对 PR 比较 base 与测试用合并 HEAD 的 merge-base 差异,保留整个 PR 的变更。只有非空差异全部属于根目录 `README.md`、`README.zh-CN.md`、`CONTRIBUTING.md`、`CHANGELOG.md`,或 `docs/` 内的 Markdown、PNG/JPEG/GIF/WebP,才跳过 Python、前端/构建/wheel 和全部 browser matrix。重命名同时检查旧、新路径;文档目录内的代码/配置、AGENTS/skill、工作流、测试、混合变更、空差异或比较失败都跑完整门禁。分类不会访问 PR API,路径使用 NUL 分隔,含空格或中文不会截断。 @@ -118,8 +122,80 @@ The final `checks` aggregate preserves its required-check name and always runs. The reusable workflow's `static-checks` defaults to false and is enabled by `ci.yml`; nightly does not duplicate static checks. CI never commits automatic fixes; hook edits remain failures. The PR stage budget is 30 minutes for now. Static has 10 minutes, Python/frontend/each browser job 30 minutes, and the aggregate 5 minutes. These remain per-job limits, not a summed or enforced workflow-wide deadline; improve end-to-end time using actual measurements. +## 跨语言测试标记 / Cross-language test marks + +Python、TypeScript 单元和 JavaScript 浏览器测试共用两条分类轴:CI 层为 `ready`、`merge`、`nightly`,机型为 `cpu` 与预留的 `cuda`、`rocm`、`xpu`、`npu`。每个分类单元各选一个层级与机型。`cpu` 表示不需要本地加速器,不表示快速或默认进入 PR;保留环境能力检查与真实服务授权。 + +Python, TypeScript units and JavaScript browser tests share two independent axes: CI layer (`ready`, `merge`, `nightly`) and hardware (`cpu`, with reserved `cuda`, `rocm`, `xpu`, `npu`). Each classification unit has one layer and platform. `cpu` means no local accelerator is required, not that a test is fast or belongs on every PR. Capability checks and real-service authorization still apply. + +| 类型 / Kind | 标记所有者 / Mark owner | 粒度 / Granularity | +| --- | --- | --- | +| Python | 显式 pytest markers,由 `scripts/pre-commit/check_test_marks.py` 静态检查 / Explicit pytest markers, statically checked | 模块、类、函数或参数 / Module, class, function or parameter | +| TypeScript 单元 / Units | [`tests/frontend-manifest.json`](../../tests/frontend-manifest.json) | 测试文件;同文件硬件或层级不同时先拆文件 / Test file; split files when requirements differ | +| JavaScript 浏览器 / Browser | [`tests/browser/manifest.json`](../../tests/browser/manifest.json) 的 `layer`、`hardware` / `layer` and `hardware` fields | 浏览器旅程脚本 / Journey script | + +前端清单当前显式登记原有根目录单元测试为 `ready + cpu`,Node 原生 `test`、hooks、参数化与 skip 写法不变。默认 `npm test` 仍运行全部登记文件,不按 mark 缩减;缺失、过时、重复或越界路径登记会失败,避免静默丢失文件。新增文件与清单一起提交。清单条目必须显式声明 `layer` 和 `hardware`;缺失或未知值报错,不自动补全。 + +The frontend catalog explicitly registers existing root-level unit files as `ready + cpu`, retaining native Node tests, hooks, parameterization and skips. Default `npm test` still runs every registered file without mark filtering. Missing, stale, duplicate or unsafe registrations fail rather than silently dropping files; register new files in the same change. Entries must explicitly declare `layer` and `hardware`; missing or unknown values fail without automatic defaults. + +浏览器条目仍保留 `lanes`、`fixture`、`previewSafe` 和 `args` 等环境信息,helper 不带测试标记。含 gate 的旅程标记为 `ready`,其余可执行旅程标记为 `nightly`,全部为 `cpu`;manual 仍须手动明确调用,标为 nightly 不会自动加入 CI。跨 lane 复用脚本仍可在当前工作流重复执行,标记本身不代表已完成 Nightly 去重。外部 gate 入口 `scripts/verify_creation_browser.mjs` 在 `externalScripts` 中登记。 + +Browser entries retain environment metadata such as `lanes`, `fixture`, `previewSafe` and `args`; helpers have no test marks. Gate journeys are `ready`, other executable journeys are `nightly`, and all are `cpu`. Manual journeys still require explicit manual invocation; a nightly label does not add them to CI. Existing workflows may still reuse a script across lanes: labels do not establish nightly deduplication. The external gate entry `scripts/verify_creation_browser.mjs` is registered under `externalScripts`. + +```sh +# All unit files, unchanged default / 全量单元,默认范围不变 +npm test +# Explicit CPU selections / 显式 CPU 筛选 +npm run test:ready +npm run test:merge # ready + merge +npm run test:nightly +# Inspect without importing test bodies / 仅查看,不导入测试体 +npm test -- --layer ready,merge --hardware cpu --list +npm run test:browser -- --layer ready --hardware cpu --list +npm run list:browser-tests -- --layer nightly --hardware cpu --lane extendedFixture +# Validate both catalogs / 校验两份清单 +npm run check:test-marks +npm run check:browser-manifest +``` + +`--layer` 与 `--hardware` 各支持逗号分隔的并集,两条轴之间取交集;浏览器清单查询还支持 `--lane`。`--list` 和 `list:browser-tests` 只输出 JSON,不启动测试、浏览器或服务。执行时无匹配项则失败;列表查询允许空数组。当前没有前端 nightly 文件,因此对应执行命令会明确失败,不把未执行报告为成功。Node 原生选项可通过 `npm test -- --test-name-pattern=...` 继续传递。 + +`--layer` and `--hardware` accept comma-separated unions, intersected across axes; browser inventory queries also accept `--lane`. `--list` and `list:browser-tests` emit JSON without starting tests, browsers or services. Execution fails on an empty selection; inventory queries may return an empty array. There are currently no frontend nightly files, so that execution command fails explicitly rather than reporting unexecuted tests as success. Native Node options remain available, for example `npm test -- --test-name-pattern=...`. + +`test:browser` 保留原来的 20 项普通 gate 流程及各自参数、环境和失败后继续的行为,可按标记筛选;voice 与 assistant fixture 阶段仍由现有工作流单独运行。其他 lane 先用 `list:browser-tests` 筛选,再由原有执行阶段准备正确的夹具、生产构建或性能环境。此入口不会将不同服务环境的所有旅程混在一次运行中,也不自动开启 manual 或真实服务。`check:browser-manifest` 同时检查两类标记,因此现有 CI 能发现清单错误;本次不修改工作流层级筛选或开启加速器车道。 + +`test:browser` preserves the original 20 regular gate workflows, their arguments/environment and continue-after-failure behavior, with optional mark filtering. Voice and assistant-fixture phases remain separate workflow steps. Query other lanes with `list:browser-tests`, then let their existing execution phases prepare the correct fixture, production or performance environment. This runner does not combine incompatible service environments or automatically enable manual/real-service checks. `check:browser-manifest` validates both mark catalogs, so existing CI detects registration errors. Workflow layer selection and accelerator lanes are unchanged. + ## Python 分层与迁移 / Python layers and transition +### 机型标记 / Hardware-platform marks + +机型与 CI 层相互独立:`cpu` 表示测试不需要本地加速器,不表示 `ready`,也不替代 ffmpeg/POSIX 能力门禁或真实服务的环境变量开关。现有 Python 测试模块使用 `pytestmark = pytest.mark.cpu`,已有层级或 skip 标记时合并为列表;新用例可直接使用 `@pytest.mark.cpu`。同一模块的硬件需求分化时,将机型标记移到类、函数或参数上,避免从模块继承错误的 `cpu`。 + +Hardware platform is independent of CI layer: `cpu` means no local accelerator is required, not `ready`, and does not replace capability skips or real-service environment gates. Existing Python test modules use `pytestmark = pytest.mark.cpu`, combined in a list with existing layer/skip marks. New cases may use `@pytest.mark.cpu` directly. If a module gains different hardware requirements, move platform marks to classes, functions or parameters so accelerator cases do not inherit `cpu`. + +pre-commit 的 `check-test-marks` hook 调用 [`scripts/pre-commit/check_test_marks.py`](../../scripts/pre-commit/check_test_marks.py),只用 Python 标准库解析源码与 JSON,不导入测试、应用或模型依赖。每个 Python 用例必须显式声明或继承唯一机型;模块、类、函数及字面量 `pytest.param` 标记合并检查,缺失、未知或冲突均失败。动态参数矩阵应在模块、类或函数声明共同机型。Python 缺少 CI 层 mark 仍按原有 ready 迁移规则处理,但不允许冲突层级。前端及浏览器清单必须显式声明两条轴,helper 不带测试标记。 + +The pre-commit `check-test-marks` hook runs [`scripts/pre-commit/check_test_marks.py`](../../scripts/pre-commit/check_test_marks.py), parsing source and JSON with the Python standard library, without importing tests, the application or model dependencies. Every Python test must explicitly declare or inherit exactly one platform. Module, class, function and literal `pytest.param` marks are checked together; missing, unknown or conflicting marks fail. Declare a common platform on the module, class or function for dynamic matrices. Missing Python CI layers retain the existing ready migration rule, but conflicting layers fail. Frontend and browser catalogs require both axes explicitly; helpers have no test marks. + +检查覆盖整个测试清单,不只看本次文件;变更测试、清单、标记注册或检查器时触发。CI 的静态门禁执行相同 pre-commit 配置,因此绕过本地 hook 后仍会失败。运行时不补标、不修改测试;漏标用例不会自动进入 `-m cpu`。可以单独运行 `python scripts/pre-commit/check_test_marks.py` 或 `python -m pre_commit run check-test-marks --all-files`。 + +The check covers the complete test inventory and triggers on test, catalog, registry or checker changes. CI runs the same pre-commit configuration, catching local-hook bypasses. Runtime collection never adds marks or rewrites tests; missing platform marks do not automatically enter `-m cpu`. Run `python scripts/pre-commit/check_test_marks.py` or `python -m pre_commit run check-test-marks --all-files` directly. + +`pyproject.toml` 注册 `cpu` 及预留的 `cuda`、`rocm`、`xpu`、`npu`,本季度不新增加速器测试或车道。SKU 与 `cards_n` 等到真实硬件套件存在后再通过共享 `hardware_test` 类 helper 引入。当前工作流的 `-m` 表达式、watchlist、环境跳过和独立 CLI 回归均不变;以下是本地验证命令,不是 CI 分层切换: + +`pyproject.toml` registers `cpu` and reserves `cuda`, `rocm`, `xpu` and `npu`; no accelerator tests or lanes are added this quarter. Introduce SKUs and `cards_n` through a shared helper such as `hardware_test` only when real hardware suites exist. Workflow `-m` expressions, watchlists, environment skips and dedicated CLI regression remain unchanged. These are local verification commands, not a CI cutover: + +```sh +python -m pytest tests --collect-only -qq --strict-markers +python -m pytest tests --collect-only -qq --strict-markers -m cpu +python -m pytest tests/test_ci_hardware.py tests/test_ci_profile.py tests/test_ci_layers.py -q +``` + +前两条命令应保留相同的现有用例身份与数量;收集成功不代表用例已执行,也不改变真实服务授权。回归检查用临时合成用例仅验证收集与筛选,不访问加速器或服务。 + +The first two commands must retain the same existing case identities and count. Collection is not execution or real-service authorization. Regression checks use temporary synthetic cases only for collection and selection, without accelerator or service access. + ### 耗时证据 / Timing evidence Python CI 为全量套件和独立 bundled OpenCode 回归分别保存 JUnit XML、`--durations=50` 日志,以及 `--ci-profile` 生成的 JSON/Markdown;从运行的 `python-test-evidence-` artifact 下载,保存 14 天。JSON 记录 SHA、系统、Python/pytest 版本、筛选条件、逐用例 setup/call/teardown 耗时、结果、显式层级与未标记默认归属,不记录 stdout、失败正文或局部变量。 diff --git a/package.json b/package.json index 210cb44d6..987e25fdd 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,12 @@ "dev": "vite --host 127.0.0.1", "build": "tsc --noEmit && vite build", "preview": "vite preview --host 127.0.0.1", - "test": "node --test tests/*.test.ts", + "test": "node scripts/run-unit-tests.mjs", + "test:ready": "node scripts/run-unit-tests.mjs --layer ready --hardware cpu", + "test:merge": "node scripts/run-unit-tests.mjs --layer ready,merge --hardware cpu", + "test:nightly": "node scripts/run-unit-tests.mjs --layer nightly --hardware cpu", + "check:test-marks": "node scripts/pre-commit/check-test-marks.mjs", + "list:browser-tests": "node scripts/list-browser-tests.mjs", "check:i18n": "node scripts/check-i18n.mjs", "check:browser-locale": "node scripts/check-browser-locale.mjs", "check:browser-manifest": "node scripts/check-browser-manifest.mjs", diff --git a/pyproject.toml b/pyproject.toml index ebe2f2f9c..870812a1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,11 @@ opendirector = "opendirector.cli:main" [tool.pytest.ini_options] markers = [ + "cpu: tests requiring no local accelerator", + "cuda: reserved NVIDIA CUDA platform; no default CI lane", + "rocm: reserved AMD ROCm platform; no default CI lane", + "xpu: reserved Intel XPU platform; no default CI lane", + "npu: reserved NPU platform; no default CI lane", "ready: fast deterministic checks for PR feedback", "merge: broader stubbed integration checks for the pre-merge gate", "nightly: timing-sensitive or opt-in external-service checks", diff --git a/scripts/check-browser-manifest.mjs b/scripts/check-browser-manifest.mjs index 90c714160..00418f299 100644 --- a/scripts/check-browser-manifest.mjs +++ b/scripts/check-browser-manifest.mjs @@ -18,6 +18,11 @@ import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; +import { browserCatalog, unitCatalog } from "./pre-commit/test-marks.ts"; + +// Existing required CI validation also checks both classification inventories. +browserCatalog(); +unitCatalog(); const browserDir = "tests/browser"; const manifestPath = path.join(browserDir, "manifest.json"); diff --git a/scripts/list-browser-tests.mjs b/scripts/list-browser-tests.mjs new file mode 100644 index 000000000..0080c4ded --- /dev/null +++ b/scripts/list-browser-tests.mjs @@ -0,0 +1,11 @@ +import { browserCatalog, options, select } from "./pre-commit/test-marks.ts"; + +try { + const { selection, forwarded } = options(process.argv.slice(2)); + if (forwarded.length) throw new Error("Unsupported browser arguments"); + // An inventory query only: never starts browsers, providers or fixture servers. + console.log(JSON.stringify(select(browserCatalog(), selection), null, 2)); +} catch (error) { + console.error(error.message); + process.exitCode = 1; +} diff --git a/scripts/pre-commit/check-test-marks.mjs b/scripts/pre-commit/check-test-marks.mjs new file mode 100644 index 000000000..64ffd2f6a --- /dev/null +++ b/scripts/pre-commit/check-test-marks.mjs @@ -0,0 +1,10 @@ +import { browserCatalog, unitCatalog } from "./test-marks.ts"; + +try { + const units = unitCatalog(); + const browser = browserCatalog(); + console.log(`Test marks OK: unit=${units.length}, browser=${browser.length}`); +} catch (error) { + console.error(error.message); + process.exitCode = 1; +} diff --git a/scripts/pre-commit/check_test_marks.py b/scripts/pre-commit/check_test_marks.py new file mode 100644 index 000000000..2e813f561 --- /dev/null +++ b/scripts/pre-commit/check_test_marks.py @@ -0,0 +1,146 @@ +"""Check explicit Python hardware marks and JS/TS catalogs without importing tests.""" +import ast +import itertools +import json +from pathlib import Path +import sys +import tomllib + + +ROOT = Path(__file__).resolve().parents[2] +HARDWARE = {'cpu', 'cuda', 'rocm', 'xpu', 'npu'} +LAYERS = {'ready', 'merge', 'nightly'} +BUILTINS = {'parametrize', 'skip', 'skipif', 'xfail', 'usefixtures', 'filterwarnings', 'anyio'} + + +def marker(node): + if isinstance(node, ast.Call): + node = node.func + if isinstance(node, ast.Attribute) and ast.unparse(node.value) == 'pytest.mark': + return node.attr + return None + + +def marker_list(node): + if isinstance(node, (ast.List, ast.Tuple)): + return [name for item in node.elts for name in marker_list(item)] + name = marker(node) + if name: + return [name] + raise ValueError('Use explicit pytest.mark declarations') + + +def scope_marks(body): + values = [] + for node in body: + if isinstance(node, ast.Assign) and any(isinstance(target, ast.Name) and target.id == 'pytestmark' for target in node.targets): + values.extend(marker_list(node.value)) + return values + + +def parameter_groups(decorators): + groups = [] + for decorator in decorators: + if marker(decorator) != 'parametrize' or not isinstance(decorator, ast.Call): + continue + values = decorator.args[1] if len(decorator.args) > 1 else next( + (kw.value for kw in decorator.keywords if kw.arg == 'argvalues'), None) + if not isinstance(values, (ast.List, ast.Tuple)): + # Dynamic matrices require a statically declared common platform. + continue + group = [] + for value in values.elts: + names = [] + if isinstance(value, ast.Call) and ast.unparse(value.func) == 'pytest.param': + for keyword in value.keywords: + if keyword.arg == 'marks': + names.extend(marker_list(keyword.value)) + group.append(names) + groups.append(group or [[]]) + return groups + + +def check_python(source, known): + tree = ast.parse(source) + problems = [] + for node in ast.walk(tree): + name = marker(node) + if name and name not in known: + problems.append(f'{node.lineno}: unknown mark: {name}') + + def walk(body, inherited): + inherited = inherited + scope_marks(body) + for node in body: + if isinstance(node, ast.ClassDef) and node.name.startswith('Test'): + walk(node.body, inherited + [name for d in node.decorator_list if (name := marker(d))]) + elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name.startswith('test_'): + names = inherited + [name for d in node.decorator_list if (name := marker(d))] + for combination in itertools.product(*parameter_groups(node.decorator_list)): + effective = set(names + [name for group in combination for name in group]) + if len(effective & HARDWARE) != 1: + problems.append(f'{node.lineno}: {node.name}: require exactly one hardware mark') + # Preserve the existing unmarked-as-ready CI-layer migration. + if len(effective & LAYERS) > 1: + problems.append(f'{node.lineno}: {node.name}: conflicting CI layers / CI 层级冲突') + walk(tree.body, []) + return sorted(set(problems)) + + +def check_catalog(entries, *, browser=False): + problems, names = [], set() + for entry in entries: + name = entry.get('file') + if not isinstance(name, str) or name in names: + problems.append('Invalid or duplicate file: ' + str(name)) + names.add(name) + if browser and entry.get('helper'): + if 'layer' in entry or 'hardware' in entry: + problems.append(f'{name}: helper carries test marks') + continue + if entry.get('layer') not in LAYERS or entry.get('hardware') not in HARDWARE: + problems.append(f'{name}: require explicit valid layer and hardware') + return problems + + +def audit(root=ROOT): + config = tomllib.loads((root / 'pyproject.toml').read_text(encoding='utf-8')) + registered = {value.split(':', 1)[0].strip() for value in config['tool']['pytest']['ini_options']['markers']} + known = registered | BUILTINS | {'requires_ffmpeg', 'requires_posix'} + problems = [] + if not (HARDWARE | LAYERS) <= registered: + problems.append('Missing registered platform/layer marks') + for path in sorted((root / 'tests').rglob('test_*.py')): + try: + problems.extend(f'{path.relative_to(root)}:{problem}' for problem in check_python(path.read_text(encoding='utf-8'), known)) + except (SyntaxError, ValueError) as error: + problems.append(f'{path.relative_to(root)}: {error}') + units = json.loads((root / 'tests/frontend-manifest.json').read_text(encoding='utf-8')) + if units.get('schemaVersion') != 1: + problems.append('Unsupported unit catalog schema') + problems.extend(check_catalog(units['tests'])) + if sorted(entry['file'] for entry in units['tests']) != sorted(path.name for path in (root / 'tests').glob('*.test.ts')): + problems.append('Unit inventory differs from discovery') + browser = json.loads((root / 'tests/browser/manifest.json').read_text(encoding='utf-8')) + problems.extend(check_catalog(browser['scripts'] + browser.get('externalScripts', []), browser=True)) + if sorted(entry['file'] for entry in browser['scripts']) != sorted(path.name for path in (root / 'tests/browser').glob('*.mjs')): + problems.append('Browser inventory differs from discovery') + for entry in browser.get('externalScripts', []): + if entry['file'] != 'scripts/verify_creation_browser.mjs' or not (root / entry['file']).is_file(): + problems.append('Invalid external browser registration') + return problems + + +def main(): + try: + problems = audit() + except (ValueError, KeyError, TypeError, OSError) as error: + problems = [str(error)] + if problems: + print('Test mark check failed:\n' + '\n'.join(problems)) + return 1 + print('Explicit test marks OK') + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/scripts/ci/select_checks.py b/scripts/pre-commit/select_checks.py similarity index 100% rename from scripts/ci/select_checks.py rename to scripts/pre-commit/select_checks.py diff --git a/scripts/pre-commit/test-marks.ts b/scripts/pre-commit/test-marks.ts new file mode 100644 index 000000000..6e71c6b15 --- /dev/null +++ b/scripts/pre-commit/test-marks.ts @@ -0,0 +1,107 @@ +/** Shared classification for Node unit files and browser journeys. */ +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +export const ROOT = fileURLToPath(new URL("../../", import.meta.url)); +export const LAYERS = ["ready", "merge", "nightly"] as const; +export const HARDWARE = ["cpu", "cuda", "rocm", "xpu", "npu"] as const; +export type Layer = (typeof LAYERS)[number]; +export type Hardware = (typeof HARDWARE)[number]; +export type Marks = { layer: Layer; hardware: Hardware }; +export type Entry = Marks & { + file: string; + script: string; + lanes?: string[]; + fixture?: boolean; +}; +export type Selection = { layers?: Layer[]; hardware?: Hardware[]; lane?: string }; + +function fail(message: string): never { + throw new Error(`Test marks: ${message}`); +} + +export function marks(value: { layer?: unknown; hardware?: unknown }): Marks { + const { layer, hardware } = value; + if (!LAYERS.includes(layer as Layer)) fail(`unknown layer: ${layer}`); + if (!HARDWARE.includes(hardware as Hardware)) fail(`unknown hardware: ${hardware}`); + return { layer: layer as Layer, hardware: hardware as Hardware }; +} + +export function select(entries: Entry[], selection: Selection): Entry[] { + return entries.filter((entry) => + (!selection.layers || selection.layers.includes(entry.layer)) && + (!selection.hardware || selection.hardware.includes(entry.hardware)) && + (!selection.lane || entry.lanes?.includes(selection.lane)), + ); +} + +function unique(entries: Entry[]): Entry[] { + const names = new Set(); + for (const entry of entries) { + if (names.has(entry.script)) fail(`duplicate script: ${entry.script}`); + names.add(entry.script); + } + return entries; +} + +export function unitCatalog(root = ROOT): Entry[] { + const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/frontend-manifest.json"), "utf8")); + if (manifest.schemaVersion !== 1 || !Array.isArray(manifest.tests)) fail("invalid unit manifest"); + const entries = unique(manifest.tests.map((entry: { file: string; layer?: unknown; hardware?: unknown }) => { + if (typeof entry.file !== "string" || !/^[\w.-]+\.test\.ts$/.test(entry.file)) fail("invalid unit path"); + return { file: entry.file, script: `tests/${entry.file}`, ...marks(entry) }; + })); + const actual = fs.readdirSync(path.join(root, "tests")).filter((file) => file.endsWith(".test.ts")).sort(); + const listed = entries.map((entry) => entry.file).sort(); + if (JSON.stringify(actual) !== JSON.stringify(listed)) fail("unit discovery differs from manifest"); + return entries.sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0); +} + +export function browserCatalog(root = ROOT): Entry[] { + const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/browser/manifest.json"), "utf8")); + const entries: Entry[] = []; + const names = new Set(); + for (const entry of [...manifest.scripts, ...(manifest.externalScripts ?? [])]) { + if (typeof entry.file !== "string" || names.has(entry.file)) fail("invalid or duplicate browser path"); + names.add(entry.file); + if (entry.helper) { + if (entry.layer !== undefined || entry.hardware !== undefined) fail("helpers cannot carry marks"); + continue; + } + const external = manifest.externalScripts?.includes(entry); + if (external ? entry.file !== "scripts/verify_creation_browser.mjs" : !/^[\w.-]+\.mjs$/.test(entry.file)) fail("invalid browser path"); + const script = external ? entry.file : `tests/browser/${entry.file}`; + if (!fs.existsSync(path.join(root, script))) fail(`missing browser script: ${script}`); + entries.push({ file: entry.file, script, lanes: entry.lanes, + ...(entry.fixture === undefined ? {} : { fixture: entry.fixture }), ...marks(entry) }); + } + return unique(entries); +} + +export function options(args: string[], { passthrough = false } = {}) { + const selection: Selection = {}; + const forwarded: string[] = []; + let list = false; + for (let i = 0; i < args.length; i++) { + const arg = args[i]; + if (arg === "--list") { list = true; continue; } + if (arg === "--") { forwarded.push(...args.slice(i + 1)); break; } + if (["--layer", "--hardware", "--lane"].includes(arg)) { + const value = args[++i]; + if (!value || value.startsWith("--")) fail(`missing value: ${arg}`); + if (arg === "--lane") { + if (!["gate", "extended", "extendedFixture", "production", "perf", "manual"].includes(value)) fail(`unknown lane: ${value}`); + selection.lane = value; + } else { + const values = value.split(","); + const known: readonly string[] = arg === "--layer" ? LAYERS : HARDWARE; + if (values.some((v) => !known.includes(v))) fail(`invalid selection: ${arg} ${value}`); + if (arg === "--layer") selection.layers = values as Layer[]; + else selection.hardware = values as Hardware[]; + } + } else if (passthrough) forwarded.push(arg); + else fail(`unknown argument: ${arg}`); + } + return { selection, list, forwarded }; +} diff --git a/scripts/run-browser-suite.mjs b/scripts/run-browser-suite.mjs index b64bb9576..ab3d37312 100644 --- a/scripts/run-browser-suite.mjs +++ b/scripts/run-browser-suite.mjs @@ -11,6 +11,7 @@ * node scripts/run-browser-suite.mjs */ import { spawnSync } from "node:child_process"; +import { browserCatalog, options, ROOT, select } from "./pre-commit/test-marks.ts"; const workflows = [ { name: "locale", script: "tests/browser/locale.mjs" }, @@ -63,9 +64,31 @@ const workflows = [ }, ]; +const { selection, list, forwarded } = options(process.argv.slice(2)); +if (forwarded.length) throw new Error("Unsupported browser arguments"); +if (selection.lane && selection.lane !== "gate") { + throw new Error("This runner uses gate services; inspect other lanes with list:browser-tests:browser-tests 查询"); +} +const catalog = browserCatalog(); +const selected = new Set(select(catalog, selection).map((entry) => entry.script)); +for (const workflow of workflows) { + if (!catalog.some((entry) => entry.script === workflow.script)) { + throw new Error(`Unregistered browser workflow: ${workflow.script}`); + } +} +const scheduled = workflows.filter((workflow) => selected.has(workflow.script)); +if (list) { + console.log(JSON.stringify(scheduled.map((workflow) => ({ + ...catalog.find((entry) => entry.script === workflow.script), + args: workflow.args ?? [], env: workflow.env ?? {}, + })), null, 2)); + process.exit(0); +} +if (!scheduled.length) throw new Error("No matching browser workflows"); + const failures = []; const started = Date.now(); -for (const workflow of workflows) { +for (const workflow of scheduled) { console.log(`\n=== ${workflow.name}: ${workflow.script} ===`); const begin = Date.now(); const result = spawnSync( @@ -73,6 +96,7 @@ for (const workflow of workflows) { [workflow.script, ...(workflow.args ?? [])], { stdio: "inherit", + cwd: ROOT, env: { ...process.env, ...(workflow.env ?? {}) }, }, ); @@ -88,7 +112,7 @@ for (const workflow of workflows) { const total = ((Date.now() - started) / 1000).toFixed(1); console.log( - `\n${workflows.length - failures.length}/${workflows.length} browser workflows passed in ${total}s`, + `\n${scheduled.length - failures.length}/${scheduled.length} browser workflows passed in ${total}s`, ); if (failures.length > 0) { console.error(`failed: ${failures.join(", ")}`); diff --git a/scripts/run-unit-tests.mjs b/scripts/run-unit-tests.mjs new file mode 100644 index 000000000..a4395bdb2 --- /dev/null +++ b/scripts/run-unit-tests.mjs @@ -0,0 +1,20 @@ +import { spawnSync } from "node:child_process"; +import { options, ROOT, select, unitCatalog } from "./pre-commit/test-marks.ts"; + +try { + const { selection, list, forwarded } = options(process.argv.slice(2), { passthrough: true }); + if (selection.lane) throw new Error("Unit tests have no browser lane"); + const entries = select(unitCatalog(), selection); + if (list) console.log(JSON.stringify(entries, null, 2)); + else { + if (!entries.length) throw new Error("No matching unit files"); + const result = spawnSync(process.execPath, ["--test", ...forwarded, ...entries.map((entry) => entry.script)], { + cwd: ROOT, stdio: "inherit", env: process.env, + }); + if (result.error) throw result.error; + process.exitCode = result.status ?? 1; + } +} catch (error) { + console.error(error.message); + process.exitCode = 1; +} diff --git a/tests/browser/manifest.json b/tests/browser/manifest.json index 19d52300c..931153d8a 100644 --- a/tests/browser/manifest.json +++ b/tests/browser/manifest.json @@ -4,24 +4,32 @@ "file": "heif_upload_recovery.mjs", "lanes": ["extended", "production"], "previewSafe": true, - "note": "HEIF upload, drop, fresh-node/reference save acknowledgement, preview failure and reload in both languages. Optional HEIF_REVIEW_FILE supplies a local camera sample." + "note": "HEIF upload, drop, fresh-node/reference save acknowledgement, preview failure and reload in both languages. Optional HEIF_REVIEW_FILE supplies a local camera sample.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "heif_import.mjs", "lanes": ["extended"], - "note": "Real HEIC/HEIF import, orientation, reload, bilingual errors and original export; fixture generation. Imports /src through Vite." + "note": "Real HEIC/HEIF import, orientation, reload, bilingual errors and original export; fixture generation. Imports /src through Vite.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "kling_video.mjs", "lanes": ["extendedFixture"], - "note": "Uses isolated creation fixtures for bilingual Kling configuration, default preservation and image-based generation." + "note": "Uses isolated creation fixtures for bilingual Kling configuration, default preservation and image-based generation.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "assistant_activity.mjs", "lanes": [ "gate" ], - "note": "Mounts /tests/browser/assistant_activity_fixture.tsx through Vite. vite preview cannot serve that module, so this script is not in the production lane." + "note": "Mounts /tests/browser/assistant_activity_fixture.tsx through Vite. vite preview cannot serve that module, so this script is not in the production lane.", + "layer": "ready", + "hardware": "cpu" }, { "file": "assistant_auxiliary_panels.mjs", @@ -30,7 +38,9 @@ "lanes": [ "gate" ], - "note": "Controls the model-stub gate; runs on its own fixture services." + "note": "Controls the model-stub gate; runs on its own fixture services.", + "layer": "ready", + "hardware": "cpu" }, { "file": "assistant_run_navigation.mjs", @@ -40,7 +50,9 @@ "extendedFixture", "production" ], - "note": "Needs --assistant-fixture services; holds the fixture gate." + "note": "Needs --assistant-fixture services; holds the fixture gate.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "assistant_sessions.mjs", @@ -50,27 +62,35 @@ "extendedFixture", "production" ], - "note": "Needs --assistant-fixture services." + "note": "Needs --assistant-fixture services.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_crop.mjs", "previewSafe": true, "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "canvas_generation_reference.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "canvas_keyboard.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_layers.mjs", @@ -79,91 +99,119 @@ ], "args": [ "--generated" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "canvas_node_titles.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_notifications.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_reference_sources.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_selection_history.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "canvas_switch.mjs", "previewSafe": true, "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "canvas_wheel.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "composer_duration.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "composer_expansion.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "context_menu_dismissal.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "control_theme.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "created_node_focus.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "creation_ripple.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "creation_asset_list.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "creation_history.mjs", @@ -171,13 +219,17 @@ "lanes": [ "extended", "production" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "creation_journey.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "cross_canvas_paste.mjs", @@ -185,7 +237,9 @@ "lanes": [ "gate", "production" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "default_entry.mjs", @@ -193,26 +247,34 @@ "lanes": [ "extended", "production" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "double_shift_chat.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "edge_selection.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "editor_save.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "engine.mjs", @@ -224,27 +286,35 @@ "lanes": [ "extended", "production" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "generation_feedback.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "generation_parameters.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "hidden_references.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "host.mjs", @@ -256,7 +326,9 @@ "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "layerApply.mjs", @@ -267,7 +339,9 @@ "file": "local_output_delivery.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "locale.mjs", @@ -275,27 +349,35 @@ "lanes": [ "gate", "production" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "minimax_h3.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "model_picker.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "moss_provider.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "moss_speech.mjs", @@ -306,39 +388,51 @@ "file": "mp4_export.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "mp4_render_probe.mjs", "lanes": [ "perf" ], - "note": "Writes the rendered MP4 to disk and verifies it with ffprobe." + "note": "Writes the rendered MP4 to disk and verifies it with ffprobe.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "multi_selection_references.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "new_image_node_outputs.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "node_connections.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "node_versions.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "paste_undo.mjs", @@ -346,7 +440,9 @@ "lanes": [ "extended", "production" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "project_list_overflow.mjs", @@ -354,21 +450,27 @@ "lanes": [ "gate", "production" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "session_lease.mjs", "lanes": [ "gate" ], - "note": "Reload after a lost lease release reopens at once; a second window is refused with project_open_elsewhere (#277)." + "note": "Reload after a lost lease release reopens at once; a second window is refused with project_open_elsewhere (#277).", + "layer": "ready", + "hardware": "cpu" }, { "file": "project_title_enter.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "provider_settings.mjs", @@ -376,33 +478,43 @@ "lanes": [ "gate", "production" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "reference_drag_performance.mjs", "lanes": [ "perf" ], - "note": "Diagnostic CPU profiles to /tmp; no pass/fail thresholds." + "note": "Diagnostic CPU profiles to /tmp; no pass/fail thresholds.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "reference_parity.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "reference_picker.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "reference_reconnect.mjs", "lanes": [ "gate" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "structured_editors.mjs", @@ -411,63 +523,83 @@ ], "args": [ "--publish" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "subject_library.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "subject_node_editing.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "subject_node_media.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_archive.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_coverage.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_desktop.mjs", "lanes": [ "manual" ], - "note": "Requires a visible desktop Chrome session and platform memory sampling; run as native platform acceptance." + "note": "Requires a visible desktop Chrome session and platform memory sampling; run as native platform acceptance.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_editing.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_installed.mjs", "lanes": [ "manual" ], - "note": "Requires OPENDIRECTOR_INSTALLED_PYTHON from a fresh platform wheel installation." + "note": "Requires OPENDIRECTOR_INSTALLED_PYTHON from a fresh platform wheel installation.", + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_text_render.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "timeline_workflow.mjs", @@ -476,13 +608,17 @@ ], "args": [ "--full-creation" - ] + ], + "layer": "ready", + "hardware": "cpu" }, { "file": "tool_drafts.mjs", "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "voice_library.mjs", @@ -490,19 +626,33 @@ "lanes": [ "gate" ], - "note": "Runs with voice_library_server.py in the Release checks voice library phase." + "note": "Runs with voice_library_server.py in the Release checks voice library phase.", + "layer": "ready", + "hardware": "cpu" }, { "file": "zhipu_provider.mjs", "previewSafe": true, "lanes": [ "extended" - ] + ], + "layer": "nightly", + "hardware": "cpu" }, { "file": "zhipu_real.mjs", "helper": true, "note": "Manual acceptance against the real Zhipu BigModel service; needs ZHIPU_API_KEY and incurs charges, so no lane runs it." } + ], + "externalScripts": [ + { + "file": "scripts/verify_creation_browser.mjs", + "lanes": [ + "gate" + ], + "layer": "ready", + "hardware": "cpu" + } ] } diff --git a/tests/frontend-manifest.json b/tests/frontend-manifest.json new file mode 100644 index 000000000..91eb144a5 --- /dev/null +++ b/tests/frontend-manifest.json @@ -0,0 +1,635 @@ +{ + "schemaVersion": 1, + "tests": [ + { + "file": "agentPreferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "archiveGenerationImport.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "assistantActivity.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "assistantCitations.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "assistantReadiness.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "assistantResume.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "assistantToolText.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "autoLabels.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "backendRules.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "backendWorkspace.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "bannerSnapshot.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "browserHost.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasArchive.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasAssembly.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasCapabilities.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasComposerPopover.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasDomains.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasGenerationResults.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasHistory.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasInteraction.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasLinkedResults.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasMediaStorage.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasModel.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasNodeTitles.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasOperations.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasPendingResults.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasPointerGesture.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasReferenceMigration.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasRemaining.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasSelectionPresentation.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasSnapping.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasStage.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasStorage.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasTimeline.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasTimelineExport.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasTimelineLibrary.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "canvasWorkspaceEntry.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "chatReferenceContent.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "chatReferenceDOM.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "chatRuntimes.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "claudeTrace.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "clipboardMedia.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "codexTrace.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "conversationEmpty.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationClient.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationContracts.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationEditorSession.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationJobs.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationLayers.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationParameters.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "creationRipples.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "deepseekTrace.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "doubleShift.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "downloadAssets.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "dragGeometry.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "edgeSelection.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "editorMedia.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "exampleDocument.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "frameReferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "generationActivity.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "generationCatalog.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "generationFailureText.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "generationRecovery.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "i18n.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "imageActionGeometry.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "imageCrop.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "imageSelection.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "issueLabels.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "layerDocument.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "libraryCache.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "libraryNaming.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "localMedia.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "locale.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "mediaPublication.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "modelBrands.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "modelResolution.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "node-action-workflow.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "nodeReferencePorts.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "nodeSearch.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "nodeStats.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "nodeTitle.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "nodeVersionReferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "pendingCanvasReferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "projectAssets.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "projectManagement.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "promptMentions.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "providerPresets.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "referenceFingerprint.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "referenceMentions.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "referenceParity.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "referenceSystem.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "requestCache.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "reviewerRouting.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "ruleFacts.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "rulesDerivation.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "sameJsonValue.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "saveQueue.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "selectionBarPlacement.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "selectionReferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "sessionClose.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "sessionLease.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "softwareAac.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "storageRequest.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "subjectLibraryImport.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "subjectMedia.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "subjectReferences.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "testMarks.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "textGeneration.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelineExchange.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelineFontBudget.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelinePackages.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelinePublication.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelineText.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "timelineTextLayout.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolCatalog.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolDeliveries.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolHistoryReads.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolReasonText.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolTaskText.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "toolTasks.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "traceCategory.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "videoActionRuntime.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "videoCapabilities.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "videoPreview.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "videoResolution.test.ts", + "layer": "ready", + "hardware": "cpu" + }, + { + "file": "voiceLibrary.test.ts", + "layer": "ready", + "hardware": "cpu" + } + ] +} diff --git a/tests/testMarks.test.ts b/tests/testMarks.test.ts new file mode 100644 index 000000000..5d06d8930 --- /dev/null +++ b/tests/testMarks.test.ts @@ -0,0 +1,106 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { spawnSync } from "node:child_process"; +import { + browserCatalog, marks, options, ROOT, select, unitCatalog, +} from "../scripts/pre-commit/test-marks.ts"; +import type { Entry } from "../scripts/pre-commit/test-marks.ts"; + +function fixture(t: { after: (fn: () => void) => void }) { + const root = mkdtempSync(join(tmpdir(), "test marks 中文 ")); + t.after(() => rmSync(root, { recursive: true, force: true })); + mkdirSync(join(root, "tests/browser"), { recursive: true }); + return root; +} + +function json(root: string, file: string, value: unknown) { + writeFileSync(join(root, file), JSON.stringify(value), "utf8"); +} + +test("classifications must be explicit and invalid marks fail", () => { + assert.throws(() => marks({}), /unknown layer/); + assert.throws(() => marks({ layer: "merge" }), /unknown hardware/); + assert.throws(() => marks({ hardware: "cuda" }), /unknown layer/); + assert.deepEqual(marks({ layer: "merge", hardware: "cuda" }), { layer: "merge", hardware: "cuda" }); + for (const value of ["unit", "Ready", "", null, ["ready", "merge"]]) { + assert.throws(() => marks({ layer: value }), /unknown layer/); + } + for (const value of ["gpu", "CPU", "cards_2", "", null, ["cpu", "gpu"]]) { + assert.throws(() => marks({ layer: "ready", hardware: value }), /unknown hardware/); + } +}); + +test("layer and hardware selection intersect and preserve environment lanes", () => { + const entries: Entry[] = [ + { file: "a", script: "a", layer: "ready", hardware: "cpu", lanes: ["gate", "production"] }, + { file: "b", script: "b", layer: "merge", hardware: "cpu", lanes: ["extended"] }, + { file: "c", script: "c", layer: "nightly", hardware: "cuda", lanes: ["perf"] }, + ]; + assert.deepEqual(select(entries, {}), entries); + assert.deepEqual(select(entries, options(["--layer", "ready,merge", "--hardware", "cpu"]).selection), entries.slice(0, 2)); + assert.deepEqual(select(entries, { lane: "production", layers: ["ready"] }), [entries[0]]); + assert.deepEqual(select(entries, { hardware: ["cpu"], layers: ["nightly"] }), []); +}); + +test("selectors reject typos and missing values rather than running everything", () => { + for (const args of [["--layer"], ["--hardware", "--list"], ["--layer", "read"], ["--hardware", "cpu,"], ["--lane", "nightly"], ["--typo"]]) { + assert.throws(() => options(args)); + } + assert.deepEqual(options(["--test-name-pattern=保存"], { passthrough: true }).forwarded, ["--test-name-pattern=保存"]); +}); + +test("unit inventory rejects missing, stale, duplicate and unsafe registrations", (t) => { + const root = fixture(t); + writeFileSync(join(root, "tests/one.test.ts"), "throw new Error('never import during discovery')"); + const save = (tests: unknown[]) => json(root, "tests/frontend-manifest.json", { schemaVersion: 1, tests }); + save([{ file: "one.test.ts", layer: "ready", hardware: "cpu" }]); + assert.deepEqual(unitCatalog(root), [{ file: "one.test.ts", script: "tests/one.test.ts", layer: "ready", hardware: "cpu" }]); + for (const entries of [[], [{ file: "missing.test.ts" }], [{ file: "one.test.ts" }, { file: "one.test.ts" }], [{ file: "../one.test.ts" }]]) { + save(entries); + assert.throws(() => unitCatalog(root)); + } +}); + +test("browser inventories preserve helpers, fixture requirements and multiple lanes", (t) => { + const root = fixture(t); + writeFileSync(join(root, "tests/browser/sample.mjs"), "throw new Error('inventory must not execute scripts')"); + const entry = { file: "sample.mjs", lanes: ["extendedFixture", "production"], fixture: true, layer: "nightly", hardware: "cpu" }; + json(root, "tests/browser/manifest.json", { scripts: [entry, { file: "helper.mjs", helper: true }] }); + assert.deepEqual(browserCatalog(root), [{ ...entry, layer: "nightly", hardware: "cpu", script: "tests/browser/sample.mjs" }]); + json(root, "tests/browser/manifest.json", { scripts: [entry, entry] }); + assert.throws(() => browserCatalog(root), /duplicate/); + json(root, "tests/browser/manifest.json", { scripts: [{ file: "helper.mjs", helper: true, hardware: "cpu" }] }); + assert.throws(() => browserCatalog(root), /helpers/); +}); + +test("live catalogs conserve unit discovery and the default browser gate schedule", () => { + const units = unitCatalog(); + assert.equal(units.length, new Set(units.map((entry) => entry.file)).size); + const listing = spawnSync(process.execPath, ["scripts/run-browser-suite.mjs", "--list"], { cwd: ROOT, encoding: "utf8" }); + assert.equal(listing.status, 0, listing.stderr); + const scheduled = JSON.parse(listing.stdout); + assert.equal(scheduled.length, 20); + assert.deepEqual(scheduled.find((entry: Entry) => entry.file === "timeline_workflow.mjs").env, { PYTHON: "python" }); + assert.deepEqual(scheduled.find((entry: Entry) => entry.file === "canvas_layers.mjs").args, ["--generated"]); +}); + +test("list queries and empty selections cannot accidentally start test bodies", () => { + const listed = spawnSync(process.execPath, ["scripts/run-unit-tests.mjs", "--layer", "ready", "--hardware", "cpu", "--list"], { cwd: ROOT, encoding: "utf8" }); + assert.equal(listed.status, 0, listed.stderr); + assert.deepEqual(JSON.parse(listed.stdout), unitCatalog()); + for (const runner of ["scripts/run-unit-tests.mjs", "scripts/run-browser-suite.mjs"]) { + const empty = spawnSync(process.execPath, [runner, "--hardware", "cuda"], { cwd: ROOT, encoding: "utf8" }); + assert.equal(empty.status, 1); + assert.match(empty.stderr, /No matching/); + } + const listedBrowser = spawnSync(process.execPath, ["scripts/list-browser-tests.mjs", "--layer", "nightly", "--hardware", "cpu", "--lane", "extendedFixture"], { cwd: ROOT, encoding: "utf8" }); + assert.equal(listedBrowser.status, 0, listedBrowser.stderr); + const entries = JSON.parse(listedBrowser.stdout); + assert.ok(entries.length > 0); + assert.deepEqual(entries, select(browserCatalog(), { + layers: ["nightly"], hardware: ["cpu"], lane: "extendedFixture", + })); +}); diff --git a/tests/test_agent_artifacts.py b/tests/test_agent_artifacts.py index 2149d7fd3..038ceb95e 100644 --- a/tests/test_agent_artifacts.py +++ b/tests/test_agent_artifacts.py @@ -23,6 +23,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + @pytest.fixture def publication(tmp_path): projects = CreationProjects(LocalProjects(tmp_path)) diff --git a/tests/test_agent_citations.py b/tests/test_agent_citations.py index 9f6284bf8..5b66ee297 100644 --- a/tests/test_agent_citations.py +++ b/tests/test_agent_citations.py @@ -8,6 +8,9 @@ from opendirector.agent.native import text_events +pytestmark = pytest.mark.cpu + + def search_result(ref='turn1search0', url='https://example.test/a', title='Source A'): return {'type': 'item.completed', 'item': {'type': 'mcp_tool_call', 'tool': 'search_service.web_run', 'status': 'completed', diff --git a/tests/test_agent_gateway.py b/tests/test_agent_gateway.py index 815871963..991493338 100644 --- a/tests/test_agent_gateway.py +++ b/tests/test_agent_gateway.py @@ -15,6 +15,9 @@ from opendirector.infrastructure.model_configs import ModelConfigs +pytestmark = pytest.mark.cpu + + @pytest.fixture def anyio_backend(): return 'asyncio' diff --git a/tests/test_agent_metadata.py b/tests/test_agent_metadata.py index 67dca9e96..c5fd5b5a4 100644 --- a/tests/test_agent_metadata.py +++ b/tests/test_agent_metadata.py @@ -12,6 +12,9 @@ from opendirector.infrastructure.model_configs import ModelConfigs +pytestmark = pytest.mark.cpu + + def test_all_registered_commands_have_explicit_metadata(): for name, model in COMMAND_MODELS.items(): description = model.__dict__.get('__doc__') diff --git a/tests/test_agent_tools_voices.py b/tests/test_agent_tools_voices.py index 5d7ddeb36..7d89dbac7 100644 --- a/tests/test_agent_tools_voices.py +++ b/tests/test_agent_tools_voices.py @@ -10,6 +10,9 @@ from opendirector.domain.projects import ProjectError +pytestmark = pytest.mark.cpu + + def test_voice_list_exposes_page_options(): function = next(tool['function'] for tool in tools() if tool['function']['name'] == 'voice_list') parameters = function['parameters'] diff --git a/tests/test_app_settings.py b/tests/test_app_settings.py index ba49dd4eb..d54ab1597 100644 --- a/tests/test_app_settings.py +++ b/tests/test_app_settings.py @@ -16,6 +16,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def test_default_and_saved_settings_survive_application_restart(tmp_path): headers = {'X-OpenDirector-Request': '1'} store = LocalProjects(tmp_path) diff --git a/tests/test_asset_names.py b/tests/test_asset_names.py index 765e7df00..bc7ee6e29 100644 --- a/tests/test_asset_names.py +++ b/tests/test_asset_names.py @@ -3,6 +3,9 @@ from opendirector.media.filenames import with_extension +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize(('name', 'suffix', 'expected'), [ ('原版', 'mp4', '原版.mp4'), ('原版.mp4', 'mp4', '原版.mp4'), diff --git a/tests/test_assistant_conversations.py b/tests/test_assistant_conversations.py index 8480e1619..969d2f3e8 100644 --- a/tests/test_assistant_conversations.py +++ b/tests/test_assistant_conversations.py @@ -12,6 +12,9 @@ from opendirector_api import agent +pytestmark = pytest.mark.cpu + + def frames(response): return [json.loads(line[6:]) for line in response.text.splitlines() if line.startswith('data: ')] diff --git a/tests/test_bench_creation_projects.py b/tests/test_bench_creation_projects.py index 676e82b32..b2a048902 100644 --- a/tests/test_bench_creation_projects.py +++ b/tests/test_bench_creation_projects.py @@ -10,6 +10,10 @@ from opendirector.infrastructure.local_projects import LocalProjects +import pytest + +pytestmark = pytest.mark.cpu + ROOT = Path(__file__).resolve().parents[1] SCRIPT = ROOT / 'scripts/bench_creation_projects.py' diff --git a/tests/test_bigmodel_image.py b/tests/test_bigmodel_image.py index 8eceeb321..1565611b3 100644 --- a/tests/test_bigmodel_image.py +++ b/tests/test_bigmodel_image.py @@ -25,6 +25,9 @@ from test_creation_canvas_service import send, ver +pytestmark = pytest.mark.cpu + + SECRET = 'bigmodel-private-test-key' URL = 'https://93.184.216.34/output?signature=private-result' CONFIG = dict(kind='image', url='https://open.bigmodel.cn/api/paas/v4', modelId='glm-image', diff --git a/tests/test_bigmodel_video.py b/tests/test_bigmodel_video.py index 142b1a29f..493101053 100644 --- a/tests/test_bigmodel_video.py +++ b/tests/test_bigmodel_video.py @@ -28,6 +28,9 @@ from generation_helpers import command, new_project, prepared, settled from test_creation_canvas_service import send, ver + +pytestmark = pytest.mark.cpu + SECRET = 'synthetic-bigmodel-video-secret' URL = 'https://cdn.test/video.mp4?signature=private-result' CONFIG = dict(kind='video', modelId='cogvideox-3', protocol='bigmodel_video', diff --git a/tests/test_canvas_sources.py b/tests/test_canvas_sources.py index 747c074f1..510ba213c 100644 --- a/tests/test_canvas_sources.py +++ b/tests/test_canvas_sources.py @@ -21,6 +21,9 @@ from test_subject_library import register_image +pytestmark = pytest.mark.cpu + + def canvas_source(store, kind='image', payload=None): projects, owner, session = new_project(store.repository, 'Canvas source') assets = CreationToolAssets(projects) diff --git a/tests/test_capability_contract.py b/tests/test_capability_contract.py index 19cc01b21..f1ea00907 100644 --- a/tests/test_capability_contract.py +++ b/tests/test_capability_contract.py @@ -48,6 +48,9 @@ classified_capabilities, declarations, required_roles_for, resolve, role_verdict, route_path) + +pytestmark = pytest.mark.cpu + FIXTURES = Path(__file__).parent / 'fixtures' / 'omni-capabilities' CONTRACT_DOC = Path(__file__).resolve().parents[1] / 'docs' / 'architecture' / 'capability-contract.md' CONTRACT_RULE = FIXTURES / 'contract-rule.txt' diff --git a/tests/test_ci_hardware.py b/tests/test_ci_hardware.py new file mode 100644 index 000000000..eb3b771d8 --- /dev/null +++ b/tests/test_ci_hardware.py @@ -0,0 +1,138 @@ +"""Check static mark validation without importing or modifying test modules.""" +import importlib.util +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys + +import pytest + + +pytestmark = [pytest.mark.ready, pytest.mark.cpu] +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('mark_check', ROOT / 'scripts/pre-commit/check_test_marks.py') +checker = importlib.util.module_from_spec(spec) +spec.loader.exec_module(checker) +KNOWN = checker.HARDWARE | checker.LAYERS | checker.BUILTINS + + +def test_module_class_function_and_parameter_marks_are_inherited(): + source = '''import pytest +raise RuntimeError('static checks must never import this module') +pytestmark = pytest.mark.cpu +@pytest.mark.merge +class TestExample: + @pytest.mark.parametrize('value', [1, 2]) + def test_save(self, value): pass +''' + assert checker.check_python(source, KNOWN) == [] + + +@pytest.mark.parametrize('decorators', [ + '@pytest.mark.cpu', + '@pytest.mark.parametrize("value", [pytest.param(1, marks=pytest.mark.cpu)])', +]) +def test_function_and_parameter_platforms_are_accepted(decorators): + assert checker.check_python('import pytest\n' + decorators + '\ndef test_sample(value=None): pass\n', KNOWN) == [] + + +@pytest.mark.parametrize('source,diagnostic', [ + ('def test_missing(): pass', 'exactly one hardware'), + ('@pytest.mark.cpou\ndef test_typo(): pass', 'unknown mark'), + ('@pytest.mark.gpu\ndef test_removed(): pass', 'unknown mark'), + ('pytestmark = pytest.mark.cpu\n@pytest.mark.cuda\ndef test_conflict(): pass', 'exactly one hardware'), + ('pytestmark = [pytest.mark.cpu, pytest.mark.merge]\n@pytest.mark.ready\ndef test_conflict(): pass', 'conflicting CI'), + ('@pytest.mark.parametrize("value", [pytest.param(1, marks=pytest.mark.cpu), 2])\ndef test_partial(value): pass', 'exactly one hardware'), + ('pytestmark = pytest.mark.cpu\n@pytest.mark.parametrize("value", [pytest.param(1, marks=pytest.mark.cuda)])\ndef test_conflict(value): pass', 'exactly one hardware'), +]) +def test_missing_typo_conflicting_and_partial_marks_fail(source, diagnostic): + assert any(diagnostic in problem for problem in checker.check_python('import pytest\n' + source, KNOWN)) + + +def test_unmarked_ci_layer_migration_is_not_a_hardware_default(): + assert checker.check_python('import pytest\npytestmark = pytest.mark.cpu\ndef test_old(): pass', KNOWN) == [] + assert checker.check_python('import pytest\n@pytest.mark.ready\ndef test_new(): pass', KNOWN) + + +@pytest.mark.parametrize('entry', [ + {'file': 'one.test.ts'}, + {'file': 'one.test.ts', 'layer': 'ready'}, + {'file': 'one.test.ts', 'layer': 'read', 'hardware': 'cpu'}, + {'file': 'one.test.ts', 'layer': 'ready', 'hardware': 'cpou'}, +]) +def test_catalogs_require_explicit_known_axes(entry): + assert checker.check_catalog([entry]) + + +def test_helpers_cannot_be_marked_as_executable_tests(): + assert checker.check_catalog([{'file': 'helper.mjs', 'helper': True}], browser=True) == [] + assert checker.check_catalog([{'file': 'helper.mjs', 'helper': True, 'hardware': 'cpu'}], browser=True) + + +def test_repository_marks_pass_static_validation(): + assert checker.audit() == [] + + +def test_pytest_does_not_add_cpu_to_unmarked_cases(tmp_path): + sample = tmp_path / 'test_sample.py' + sample.write_text('def test_unmarked(): pass\n', encoding='utf-8') + result = subprocess.run([ + sys.executable, '-m', 'pytest', str(sample), '--noconftest', + '-c', str(ROOT / 'pyproject.toml'), '--collect-only', '-q', '-m', 'cpu', + ], capture_output=True, text=True, encoding='utf-8', timeout=30) + assert result.returncode == 5, result.stdout + result.stderr + + +@pytest.mark.parametrize('scenario,expected,diagnostic', [ + ('valid', 0, 'Explicit test marks OK'), + ('missing_python_hardware', 1, 'exactly one hardware'), + ('unknown_python_hardware', 1, 'unknown mark'), + ('conflicting_python_hardware', 1, 'exactly one hardware'), + ('conflicting_python_layers', 1, 'conflicting CI layers'), + ('partial_parameter_hardware', 1, 'exactly one hardware'), + ('missing_unit_hardware', 1, 'explicit valid layer and hardware'), + ('unknown_browser_hardware', 1, 'explicit valid layer and hardware'), + ('missing_unit_registration', 1, 'Unit inventory differs'), + ('marked_helper', 1, 'helper carries test marks'), +]) +def test_cli_checks_constructed_files_without_importing_tests(tmp_path, scenario, expected, diagnostic): + scripts = tmp_path / 'scripts/pre-commit' + scripts.mkdir(parents=True) + shutil.copyfile(ROOT / 'scripts/pre-commit/check_test_marks.py', scripts / 'check_test_marks.py') + shutil.copyfile(ROOT / 'pyproject.toml', tmp_path / 'pyproject.toml') + tests = tmp_path / 'tests' + (tests / 'browser').mkdir(parents=True) + source = "import pytest\npytestmark = pytest.mark.cpu\nraise RuntimeError('must not import')\ndef test_sample(): pass\n" + unit = {'file': 'one.test.ts', 'layer': 'ready', 'hardware': 'cpu'} + browser = {'file': 'one.mjs', 'layer': 'ready', 'hardware': 'cpu', 'lanes': ['gate']} + if scenario == 'missing_python_hardware': + source = 'def test_missing(): pass\n' + elif scenario == 'unknown_python_hardware': + source = 'import pytest\n@pytest.mark.gpu\ndef test_removed(): pass\n' + elif scenario == 'conflicting_python_hardware': + source = 'import pytest\npytestmark = pytest.mark.cpu\n@pytest.mark.cuda\ndef test_conflict(): pass\n' + elif scenario == 'conflicting_python_layers': + source = 'import pytest\npytestmark = [pytest.mark.cpu, pytest.mark.ready]\n@pytest.mark.merge\ndef test_conflict(): pass\n' + elif scenario == 'partial_parameter_hardware': + source = 'import pytest\n@pytest.mark.parametrize("x", [pytest.param(1, marks=pytest.mark.cpu), 2])\ndef test_partial(x): pass\n' + elif scenario == 'missing_unit_hardware': + del unit['hardware'] + elif scenario == 'unknown_browser_hardware': + browser['hardware'] = 'gpu' + elif scenario == 'marked_helper': + browser['helper'] = True + (tests / 'test_sample.py').write_text(source, encoding='utf-8') + (tests / 'one.test.ts').write_text("throw new Error('must not execute');\n", encoding='utf-8') + (tests / 'browser/one.mjs').write_text("throw new Error('must not execute');\n", encoding='utf-8') + (tests / 'frontend-manifest.json').write_text(json.dumps({ + 'schemaVersion': 1, 'tests': [] if scenario == 'missing_unit_registration' else [unit], + }), encoding='utf-8') + (tests / 'browser/manifest.json').write_text(json.dumps({'scripts': [browser]}), encoding='utf-8') + result = subprocess.run([sys.executable, str(scripts / 'check_test_marks.py')], + cwd=tmp_path, capture_output=True, text=True, encoding='utf-8', timeout=30, + env={**os.environ, 'PYTHONIOENCODING': 'utf-8'}) + assert result.returncode == expected, result.stdout + result.stderr + assert diagnostic in result.stdout, result.stdout + result.stderr + assert 'must not import' not in result.stdout + result.stderr diff --git a/tests/test_ci_layers.py b/tests/test_ci_layers.py index 7ebff1b7b..1cb77d3ca 100644 --- a/tests/test_ci_layers.py +++ b/tests/test_ci_layers.py @@ -6,7 +6,7 @@ import pytest -pytestmark = pytest.mark.ready +pytestmark = [pytest.mark.ready, pytest.mark.cpu] spec = importlib.util.spec_from_file_location('layer_audit', Path(__file__).resolve().parents[1] / 'scripts/ci/check_test_layers.py') audit_module = importlib.util.module_from_spec(spec) diff --git a/tests/test_ci_profile.py b/tests/test_ci_profile.py index 282b4b5de..a5cb4545e 100644 --- a/tests/test_ci_profile.py +++ b/tests/test_ci_profile.py @@ -8,7 +8,7 @@ import pytest -pytestmark = pytest.mark.ready +pytestmark = [pytest.mark.ready, pytest.mark.cpu] ROOT = Path(__file__).resolve().parents[1] SAMPLE = '''import pytest @pytest.mark.ready diff --git a/tests/test_ci_scope.py b/tests/test_ci_scope.py index 147559cb9..4c79d0f0c 100644 --- a/tests/test_ci_scope.py +++ b/tests/test_ci_scope.py @@ -10,9 +10,9 @@ import yaml -pytestmark = pytest.mark.ready +pytestmark = [pytest.mark.ready, pytest.mark.cpu] ROOT = Path(__file__).resolve().parents[1] -SCRIPT = ROOT / 'scripts/ci/select_checks.py' +SCRIPT = ROOT / 'scripts/pre-commit/select_checks.py' spec = importlib.util.spec_from_file_location('check_scope', SCRIPT) scope = importlib.util.module_from_spec(spec) spec.loader.exec_module(scope) @@ -164,9 +164,23 @@ def test_real_selector_outputs_drive_real_aggregate(repository, tmp_path): def test_workflow_wires_every_heavy_lane_to_successful_static_scope(): jobs = yaml.safe_load((ROOT / '.github/workflows/release-checks.yml').read_text(encoding='utf-8'))['jobs'] - assert jobs['static']['steps'][-1]['id'] == 'scope' - assert jobs['static']['steps'][-1]['run'] == 'python scripts/ci/select_checks.py' - assert set(jobs['static']['outputs']) == {'run-heavy', 'scope-reason', 'changed-files'} + assert jobs['static'] == {'if': 'inputs.static-checks', 'uses': './.github/workflows/pre-commit.yml'} + workflow = yaml.safe_load((ROOT / '.github/workflows/pre-commit.yml').read_text(encoding='utf-8')) + static = workflow['jobs']['check'] + assert static['steps'][-1]['id'] == 'scope' + assert static['steps'][-1]['run'] == 'python scripts/pre-commit/select_checks.py' + assert set(static['outputs']) == {'run-heavy', 'scope-reason', 'changed-files'} + assert set(workflow[True]) == {'workflow_call', 'workflow_dispatch'} + outputs = workflow[True]['workflow_call']['outputs'] + assert set(outputs) == set(static['outputs']) + for name in outputs: + assert outputs[name]['value'] == '${{ jobs.check.outputs.' + name + ' }}' + assert workflow['permissions'] == {'contents': 'read'} + command = static['steps'][-2]['run'] + assert 'pre_commit run --from-ref "$PR_BASE_SHA" --to-ref HEAD' in command + assert 'pre_commit run --from-ref "$PUSH_BASE_SHA" --to-ref HEAD' in command + assert 'pre_commit run --all-files' in command + assert not any('pre_commit' in str(job) for job in jobs.values()) for lane in ['python', 'frontend', 'browser']: assert jobs[lane]['needs'] == 'static' assert "needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false'" in jobs[lane]['if'] diff --git a/tests/test_ci_summary.py b/tests/test_ci_summary.py index c2c55f105..26fc219d7 100644 --- a/tests/test_ci_summary.py +++ b/tests/test_ci_summary.py @@ -8,7 +8,7 @@ import pytest -pytestmark = pytest.mark.ready +pytestmark = [pytest.mark.ready, pytest.mark.cpu] SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/ci/summarize_checks.py' diff --git a/tests/test_cli.py b/tests/test_cli.py index 3c6689eb2..16d4b4c0e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -22,6 +22,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def test_cli_preserves_the_font_error_code_and_english_diagnostic(tmp_path, monkeypatch): api = TestClient(create_app(LocalProjects(tmp_path))) original_client = httpx.Client diff --git a/tests/test_cli_discovery.py b/tests/test_cli_discovery.py index d99d8d045..c406b5372 100644 --- a/tests/test_cli_discovery.py +++ b/tests/test_cli_discovery.py @@ -5,7 +5,7 @@ from opendirector.agent import cli_discovery as discovery from opendirector.agent import deepseek, jiuwenswarm, native, runtime -pytestmark = pytest.mark.ready +pytestmark = [pytest.mark.ready, pytest.mark.cpu] def test_path_has_priority(monkeypatch): diff --git a/tests/test_creation_api.py b/tests/test_creation_api.py index ebb732009..3af318a79 100644 --- a/tests/test_creation_api.py +++ b/tests/test_creation_api.py @@ -11,6 +11,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + @pytest.fixture def api(tmp_path): local = LocalProjects(tmp_path) diff --git a/tests/test_creation_artifacts.py b/tests/test_creation_artifacts.py index eed896ba0..b9a70848d 100644 --- a/tests/test_creation_artifacts.py +++ b/tests/test_creation_artifacts.py @@ -22,6 +22,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + @pytest.fixture def publication(tmp_path): projects = CreationProjects(LocalProjects(tmp_path)) diff --git a/tests/test_creation_assembly.py b/tests/test_creation_assembly.py index b24661c9e..c87fe3a86 100644 --- a/tests/test_creation_assembly.py +++ b/tests/test_creation_assembly.py @@ -15,6 +15,9 @@ from test_creation_canvas_service import project, media, send, ver +pytestmark = pytest.mark.cpu + + def upload_source(project, tmp_path, kind, seconds=1, color='blue'): store, pid, session = project if kind == 'image': diff --git a/tests/test_creation_assets.py b/tests/test_creation_assets.py index e25646d6f..086870651 100644 --- a/tests/test_creation_assets.py +++ b/tests/test_creation_assets.py @@ -23,6 +23,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def command(project_id, kind='project.create', **payload): return parse_command(dict(projectId=project_id, commandId=uuid4(), type=kind, payload=payload)) diff --git a/tests/test_creation_canvas_service.py b/tests/test_creation_canvas_service.py index 9b3d573c3..71e234362 100644 --- a/tests/test_creation_canvas_service.py +++ b/tests/test_creation_canvas_service.py @@ -12,6 +12,9 @@ from opendirector.infrastructure.local_projects import LocalProjects +pytestmark = pytest.mark.cpu + + @pytest.fixture def project(tmp_path): store = CreationProjects(LocalProjects(tmp_path)) diff --git a/tests/test_creation_contracts.py b/tests/test_creation_contracts.py index cd48c7854..041a98355 100644 --- a/tests/test_creation_contracts.py +++ b/tests/test_creation_contracts.py @@ -20,6 +20,9 @@ from opendirector.domain.creation.project import ViewState from opendirector.domain.input_rules import input_rules + +pytestmark = pytest.mark.cpu + ROOT = Path(__file__).resolve().parents[1] PROJECT = UUID(int=1) diff --git a/tests/test_creation_crop.py b/tests/test_creation_crop.py index c61f34d12..4335d3593 100644 --- a/tests/test_creation_crop.py +++ b/tests/test_creation_crop.py @@ -17,6 +17,9 @@ from test_creation_node_versions import versions +pytestmark = pytest.mark.cpu + + def crop_command(project, item_id, *, brightness=125): store, pid, session = project assets = CreationAssets(store) diff --git a/tests/test_creation_generation_service.py b/tests/test_creation_generation_service.py index cbad1e4ae..104988ed9 100644 --- a/tests/test_creation_generation_service.py +++ b/tests/test_creation_generation_service.py @@ -11,6 +11,9 @@ from test_creation_canvas_service import project, media, send, text_material, ver +pytestmark = pytest.mark.cpu + + @pytest.fixture def anyio_backend(): return 'asyncio' diff --git a/tests/test_creation_history_service.py b/tests/test_creation_history_service.py index daa2bf031..01bd16c60 100644 --- a/tests/test_creation_history_service.py +++ b/tests/test_creation_history_service.py @@ -8,6 +8,9 @@ from test_creation_canvas_service import project, media, send, text_material, ver +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('transition', ['undo', 'redo']) @pytest.mark.parametrize('locked_owner', ['node', 'parent', 'second_owner']) @pytest.mark.parametrize('actor', ['ui', 'agent']) diff --git a/tests/test_creation_image_edits.py b/tests/test_creation_image_edits.py index 4757c1d3b..b2c440d8e 100644 --- a/tests/test_creation_image_edits.py +++ b/tests/test_creation_image_edits.py @@ -18,6 +18,9 @@ from test_creation_node_versions import versions +pytestmark = pytest.mark.cpu + + def png(color): out = BytesIO() Image.new('RGB', (64, 64), color).save(out, 'PNG') diff --git a/tests/test_creation_layers.py b/tests/test_creation_layers.py index 9f2a29408..9f5a6903b 100644 --- a/tests/test_creation_layers.py +++ b/tests/test_creation_layers.py @@ -11,6 +11,10 @@ from test_creation_canvas_service import project, media, send, ver from opendirector.application.creation_canvas import asset_ref +import pytest + +pytestmark = pytest.mark.cpu + def layered_image(project): store, pid, session = project diff --git a/tests/test_creation_media_publication.py b/tests/test_creation_media_publication.py index 11b8ac78e..70a4eb13e 100644 --- a/tests/test_creation_media_publication.py +++ b/tests/test_creation_media_publication.py @@ -13,6 +13,9 @@ from test_creation_tool_drafts import png +pytestmark = pytest.mark.cpu + + def prepared(project, count=2): store, pid, session = project assets = CreationToolAssets(store) diff --git a/tests/test_creation_node_versions.py b/tests/test_creation_node_versions.py index 8ed90ede4..08243a048 100644 --- a/tests/test_creation_node_versions.py +++ b/tests/test_creation_node_versions.py @@ -13,6 +13,9 @@ from test_creation_generation_service import Provider, runtime, configure, anyio_backend +pytestmark = pytest.mark.cpu + + def versions(snapshot): return [ver(kind, obj) for (kind, _), obj in object_index(snapshot).items()] diff --git a/tests/test_creation_parameters.py b/tests/test_creation_parameters.py index 3176df374..ab2473a35 100644 --- a/tests/test_creation_parameters.py +++ b/tests/test_creation_parameters.py @@ -27,6 +27,9 @@ from generation_helpers import prepared +pytestmark = pytest.mark.cpu + + def png(size=(32, 24), color='blue'): out = BytesIO() Image.new('RGB', size, color).save(out, 'PNG') diff --git a/tests/test_creation_reference_editor.py b/tests/test_creation_reference_editor.py index b09d0839e..7fc74c4bb 100644 --- a/tests/test_creation_reference_editor.py +++ b/tests/test_creation_reference_editor.py @@ -7,6 +7,9 @@ from opendirector.domain.creation.commands import parse_command +pytestmark = pytest.mark.cpu + + def setup_reference(project): store, pid, session = project source, asset = text_material(project, title='Original') diff --git a/tests/test_creation_storage.py b/tests/test_creation_storage.py index dd8535881..f0939544b 100644 --- a/tests/test_creation_storage.py +++ b/tests/test_creation_storage.py @@ -20,6 +20,9 @@ from opendirector.infrastructure.local_projects import LocalProjects, read_json +pytestmark = pytest.mark.cpu + + @pytest.fixture def unrecycled(monkeypatch): """Delete through the filesystem so tests never touch the machine recycle bin.""" diff --git a/tests/test_creation_timeline_render.py b/tests/test_creation_timeline_render.py index 27e7600f6..406003645 100644 --- a/tests/test_creation_timeline_render.py +++ b/tests/test_creation_timeline_render.py @@ -13,6 +13,9 @@ from test_creation_canvas_service import project, send, ver +pytestmark = pytest.mark.cpu + + def clip(seconds=2, size='64x64'): return subprocess.run(['ffmpeg', '-v', 'error', '-f', 'lavfi', '-i', f'color=blue:s={size}:r=24', '-t', str(seconds), '-threads', '1', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', diff --git a/tests/test_creation_timeline_text.py b/tests/test_creation_timeline_text.py index 9b22986ac..4347898a3 100644 --- a/tests/test_creation_timeline_text.py +++ b/tests/test_creation_timeline_text.py @@ -11,6 +11,9 @@ from opendirector.infrastructure.creation_projects import CreationProjects from opendirector.infrastructure.local_projects import LocalProjects + +pytestmark = pytest.mark.cpu + FIXTURES = Path(__file__).parent / 'fixtures/timeline-text' FONT = dict(assetId=str(UUID(int=87101)), revision=1, kind='file', fingerprint='sha256:'+'a'*64) diff --git a/tests/test_creation_tool_drafts.py b/tests/test_creation_tool_drafts.py index af41b6c95..d5b878ca3 100644 --- a/tests/test_creation_tool_drafts.py +++ b/tests/test_creation_tool_drafts.py @@ -21,6 +21,9 @@ from test_creation_canvas_service import project, send, ver +pytestmark = pytest.mark.cpu + + def png(color='blue', size=(64, 48)): out = BytesIO() Image.new('RGBA', size, color).save(out, 'PNG') diff --git a/tests/test_creation_workflow.py b/tests/test_creation_workflow.py index ffc2a124d..67209794b 100644 --- a/tests/test_creation_workflow.py +++ b/tests/test_creation_workflow.py @@ -18,6 +18,9 @@ from test_creation_generation_service import anyio_backend, Provider, runtime, configure +pytestmark = pytest.mark.cpu + + async def submit(runner, project, spec_id, origin=None, policy='if_current', *, batch_id=None, additional=False): store, pid, session = project current = store.snapshot(pid) diff --git a/tests/test_daily_benchmark.py b/tests/test_daily_benchmark.py index ba2658dd9..1212a81d6 100644 --- a/tests/test_daily_benchmark.py +++ b/tests/test_daily_benchmark.py @@ -6,6 +6,10 @@ from datetime import datetime, timezone from pathlib import Path +import pytest + +pytestmark = pytest.mark.cpu + ROOT = Path(__file__).resolve().parents[1] CONFIG = ROOT / 'scripts/nightly/benchmark.json' SCRIPT = ROOT / 'scripts/nightly/daily_benchmark.py' diff --git a/tests/test_deepseek_engine.py b/tests/test_deepseek_engine.py index d4ac587e2..1059f0b34 100644 --- a/tests/test_deepseek_engine.py +++ b/tests/test_deepseek_engine.py @@ -18,7 +18,7 @@ from opendirector.agent.owner_rights import native_owner_access from opendirector_api.main import create_app -pytestmark = pytest.mark.nightly +pytestmark = [pytest.mark.nightly, pytest.mark.cpu] @pytest.mark.skipif(os.getenv('DEEPSEEK_ENGINE_TEST') != '1', reason='requires installed dsh CLI') diff --git a/tests/test_deepseek_runtime.py b/tests/test_deepseek_runtime.py index ae280c6a1..a0e218929 100644 --- a/tests/test_deepseek_runtime.py +++ b/tests/test_deepseek_runtime.py @@ -18,6 +18,9 @@ from opendirector_api.main import create_app from opendirector.infrastructure.local_projects import LocalProjects + +pytestmark = pytest.mark.cpu + FAKE = r''' import json, os, shutil, subprocess, sys from pathlib import Path diff --git a/tests/test_directory_links.py b/tests/test_directory_links.py index e1893e1a4..db3ebe377 100644 --- a/tests/test_directory_links.py +++ b/tests/test_directory_links.py @@ -4,6 +4,9 @@ from opendirector.agent.directory_links import link_directory, unlink_directory +pytestmark = pytest.mark.cpu + + def test_directory_alias_roundtrip_and_dangling_cleanup(tmp_path): target = tmp_path / 'private skills' target.mkdir() diff --git a/tests/test_execution_files.py b/tests/test_execution_files.py index 19ce39b08..b1430e837 100644 --- a/tests/test_execution_files.py +++ b/tests/test_execution_files.py @@ -8,6 +8,9 @@ from opendirector.infrastructure.execution_files import execution_file +pytestmark = pytest.mark.cpu + + def test_execution_file_rejects_a_hardlink_to_an_outside_file(tmp_path): work = tmp_path / 'work' work.mkdir() diff --git a/tests/test_fasth3_inputs.py b/tests/test_fasth3_inputs.py index 7a7352a46..ea3de5903 100644 --- a/tests/test_fasth3_inputs.py +++ b/tests/test_fasth3_inputs.py @@ -11,6 +11,9 @@ from opendirector.integrations.fasth3 import native_prompt, video_parameters, finalize_video_edit +pytestmark = pytest.mark.cpu + + def source(kind, name, **extra): return {'id': str(uuid4()), 'name': name, 'kind': kind, 'type': kind + '/mp4', **extra} diff --git a/tests/test_ffmpeg_frame_sync.py b/tests/test_ffmpeg_frame_sync.py index 86f85765c..51cb5b857 100644 --- a/tests/test_ffmpeg_frame_sync.py +++ b/tests/test_ffmpeg_frame_sync.py @@ -12,6 +12,9 @@ from opendirector.media import processing +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize(('help_text', 'expected'), [ (b'-fps_mode[:] set framerate mode\n', '-fps_mode'), (b'-fps_mode[:stream_specifier] fps_mode set framerate mode\n-vsync sync_mode set video sync\n', '-fps_mode'), diff --git a/tests/test_generation_errors.py b/tests/test_generation_errors.py index 27b5fb058..260be2da5 100644 --- a/tests/test_generation_errors.py +++ b/tests/test_generation_errors.py @@ -16,6 +16,9 @@ from opendirector.integrations.volcengine import VolcengineGeneration +pytestmark = pytest.mark.cpu + + SECRET = 'private-key-never-record' SIGNED_URL = 'https://cdn.test/output?signature=secret-signature' diff --git a/tests/test_generation_recovery.py b/tests/test_generation_recovery.py index 35f08eed2..345f5dcc6 100644 --- a/tests/test_generation_recovery.py +++ b/tests/test_generation_recovery.py @@ -23,6 +23,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def png(): stream = io.BytesIO() Image.new('RGB', (16, 12)).save(stream, 'PNG') diff --git a/tests/test_heif.py b/tests/test_heif.py index e3fd8e3d1..bb3623494 100644 --- a/tests/test_heif.py +++ b/tests/test_heif.py @@ -21,6 +21,9 @@ from test_creation_assets import storage, import_asset from test_agent_artifacts import publication + +pytestmark = pytest.mark.cpu + FIXTURES = Path(__file__).parent / 'fixtures' / 'heif' diff --git a/tests/test_hidden_reference_roundtrip.py b/tests/test_hidden_reference_roundtrip.py index 03a93ba9a..f9b7c4a85 100644 --- a/tests/test_hidden_reference_roundtrip.py +++ b/tests/test_hidden_reference_roundtrip.py @@ -13,6 +13,9 @@ from opendirector.infrastructure.creation_projects import CreationProjects +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('binding', ['follow_current', 'pinned']) @pytest.mark.parametrize('hide_group', [False, True]) def test_hidden_reference_survives_frontend_edit_save_and_reopen(project, tmp_path, binding, hide_group): diff --git a/tests/test_installation.py b/tests/test_installation.py index 26d57680c..f10937f1d 100644 --- a/tests/test_installation.py +++ b/tests/test_installation.py @@ -1,6 +1,10 @@ """Installed resources and writable project storage have distinct roots.""" from opendirector import installation +import pytest + +pytestmark = pytest.mark.cpu + def test_wheel_defaults_to_user_workspace_not_package(monkeypatch, tmp_path): monkeypatch.delenv('OPENDIRECTOR_ROOT', raising=False) diff --git a/tests/test_jiuwenswarm_engine.py b/tests/test_jiuwenswarm_engine.py index c2d546087..e7e7de760 100644 --- a/tests/test_jiuwenswarm_engine.py +++ b/tests/test_jiuwenswarm_engine.py @@ -13,7 +13,7 @@ from opendirector.infrastructure.local_projects import LocalProjects from opendirector_api.main import create_app -pytestmark = pytest.mark.nightly +pytestmark = [pytest.mark.nightly, pytest.mark.cpu] @pytest.mark.skipif(os.getenv('JIUWENSWARM_ENGINE_TEST') != '1', reason='requires installed JiuwenSwarm Process CLI') diff --git a/tests/test_jiuwenswarm_media.py b/tests/test_jiuwenswarm_media.py index d6c32b2a7..db990b2ba 100644 --- a/tests/test_jiuwenswarm_media.py +++ b/tests/test_jiuwenswarm_media.py @@ -23,6 +23,7 @@ pytestmark = [ + pytest.mark.cpu, pytest.mark.nightly, pytest.mark.skipif(os.getenv('JIUWENSWARM_ENGINE_TEST') != '1', reason='requires installed JiuwenSwarm and FFmpeg'), ] diff --git a/tests/test_jiuwenswarm_runtime.py b/tests/test_jiuwenswarm_runtime.py index a1cf4f3a6..ddad83d7d 100644 --- a/tests/test_jiuwenswarm_runtime.py +++ b/tests/test_jiuwenswarm_runtime.py @@ -18,6 +18,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + FAKE = r'''import json, os, shutil, subprocess, sys, time from pathlib import Path request = json.loads(sys.stdin.readline()) diff --git a/tests/test_kling_video.py b/tests/test_kling_video.py index 203e4b7da..d18dd8fde 100644 --- a/tests/test_kling_video.py +++ b/tests/test_kling_video.py @@ -26,6 +26,9 @@ from test_creation_canvas_service import send, ver +pytestmark = pytest.mark.cpu + + @pytest.fixture def anyio_backend(): return 'asyncio' diff --git a/tests/test_launcher.py b/tests/test_launcher.py index d991b4920..7ae11b3cd 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -3,6 +3,10 @@ from opendirector import launcher as launcher_module +import pytest + +pytestmark = pytest.mark.cpu + def launcher(): return launcher_module diff --git a/tests/test_layer_boundary.py b/tests/test_layer_boundary.py index 418df39db..87090b3fe 100644 --- a/tests/test_layer_boundary.py +++ b/tests/test_layer_boundary.py @@ -4,6 +4,10 @@ from opendirector.ports.gateway import gateway from opendirector.wiring import InfrastructureGateway, configure_runtime +import pytest + +pytestmark = pytest.mark.cpu + def test_runtime_binding_uses_application_dispatch(): ports = configure_runtime() diff --git a/tests/test_library.py b/tests/test_library.py index 74f3712c2..2ad2e37f9 100644 --- a/tests/test_library.py +++ b/tests/test_library.py @@ -20,6 +20,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def png(color='purple', size=(13, 7)): buffer = BytesIO() Image.new('RGB', size, color).save(buffer, format='PNG') @@ -232,4 +235,4 @@ def test_trash_writes_nothing_inside_projects(client, tmp_path, store): client.delete('/api/library/trash') after = {p.name: p.stat().st_mtime_ns for p in project_dir.rglob('*') if p.is_file()} - assert before == after \ No newline at end of file + assert before == after diff --git a/tests/test_local_json.py b/tests/test_local_json.py index ccfbaacef..930086437 100644 --- a/tests/test_local_json.py +++ b/tests/test_local_json.py @@ -15,6 +15,9 @@ from opendirector.infrastructure.creation_projects import CreationProjects +pytestmark = pytest.mark.cpu + + def test_atomic_json_publication_preserves_open_reader_and_publishes_after_close(tmp_path, monkeypatch): path = tmp_path / 'state.json' before, after = {'revision': 1}, {'revision': 2, 'text': '中文'} diff --git a/tests/test_localization.py b/tests/test_localization.py index deafa035b..ac99af881 100644 --- a/tests/test_localization.py +++ b/tests/test_localization.py @@ -6,6 +6,10 @@ wants_english, ) +import pytest + +pytestmark = pytest.mark.cpu + def request(language: str): return SimpleNamespace(headers={"accept-language": language}) diff --git a/tests/test_minimax_image.py b/tests/test_minimax_image.py index aa7d720d1..0adfcd751 100644 --- a/tests/test_minimax_image.py +++ b/tests/test_minimax_image.py @@ -20,6 +20,9 @@ from test_creation_assets import import_asset, ref from test_creation_canvas_service import project, media, send, ver + +pytestmark = pytest.mark.cpu + URL = 'https://api.minimax.cn/v1' RESULT = 'https://93.184.215.14/output.png' MODELS = ('MiniMax-H3-Image', 'MiniMax-H3-Image-Highspeed') diff --git a/tests/test_minimax_speech.py b/tests/test_minimax_speech.py index 28d4032e4..b2b0ccc82 100644 --- a/tests/test_minimax_speech.py +++ b/tests/test_minimax_speech.py @@ -34,6 +34,9 @@ from test_moss import mp3 from test_voice_library import Configs + +pytestmark = pytest.mark.cpu + URL = 'https://api.minimax.cn/v1' RESULT = 'https://93.184.215.14/speech.mp3?signature=fixture-result-signature' SECRET = 'minimax-test-key' diff --git a/tests/test_minimax_video.py b/tests/test_minimax_video.py index 890b459ef..94a1d8694 100644 --- a/tests/test_minimax_video.py +++ b/tests/test_minimax_video.py @@ -19,6 +19,9 @@ from test_multimodal_references import media, task +pytestmark = pytest.mark.cpu + + @pytest.fixture def anyio_backend(): return 'asyncio' diff --git a/tests/test_model_catalog.py b/tests/test_model_catalog.py index b28832d70..3031d19c4 100644 --- a/tests/test_model_catalog.py +++ b/tests/test_model_catalog.py @@ -12,6 +12,9 @@ from opendirector.infrastructure.model_configs import ModelConfigs +pytestmark = pytest.mark.cpu + + class Store: def __init__(self, existing=None): self.existing = existing diff --git a/tests/test_model_configs.py b/tests/test_model_configs.py index 46cd5bcfe..a7031075b 100644 --- a/tests/test_model_configs.py +++ b/tests/test_model_configs.py @@ -11,6 +11,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + @pytest.fixture def api(tmp_path): store = LocalProjects(tmp_path) diff --git a/tests/test_model_gateway.py b/tests/test_model_gateway.py index 14d5131e0..777c5aa49 100644 --- a/tests/test_model_gateway.py +++ b/tests/test_model_gateway.py @@ -10,6 +10,9 @@ from opendirector.domain.projects import ProjectError +pytestmark = pytest.mark.cpu + + class Stream(httpx.AsyncByteStream): def __init__(self, chunks, failure=None, gate=None): self.chunks, self.failure, self.gate = chunks, failure, gate diff --git a/tests/test_model_http_logging.py b/tests/test_model_http_logging.py index c2d911706..9dd639fe1 100644 --- a/tests/test_model_http_logging.py +++ b/tests/test_model_http_logging.py @@ -8,6 +8,9 @@ from opendirector.integrations.generation_errors import transport_failure +pytestmark = pytest.mark.cpu + + def test_logs_each_query_submission_poll_and_cancel(caplog): caplog.set_level('DEBUG', logger='opendirector.integrations.http_settings') diff --git a/tests/test_model_reasoning_trace.py b/tests/test_model_reasoning_trace.py index 5eb23967a..e8cd2a465 100644 --- a/tests/test_model_reasoning_trace.py +++ b/tests/test_model_reasoning_trace.py @@ -6,6 +6,10 @@ from opendirector.agent.model_gateway import ModelGateway +import pytest + +pytestmark = pytest.mark.cpu + def test_reasoning_trace_handles_fragmented_sse_without_changing_response(tmp_path): chunks = [ diff --git a/tests/test_moss.py b/tests/test_moss.py index 87b9a5dff..375e99606 100644 --- a/tests/test_moss.py +++ b/tests/test_moss.py @@ -33,6 +33,9 @@ from test_creation_parameters import png +pytestmark = pytest.mark.cpu + + SECRET = 'moss-private-test-key' VOICE = '5c8cd24a-dfd6-4fd8-8f47-93e9aec17328' OTHER_VOICE = 'f0827524-a19e-4e1c-859d-afc9fd17133e' diff --git a/tests/test_multimodal_references.py b/tests/test_multimodal_references.py index cac831c71..5b0b1d420 100644 --- a/tests/test_multimodal_references.py +++ b/tests/test_multimodal_references.py @@ -27,6 +27,9 @@ from opendirector.integrations.volcengine import VolcengineGeneration from opendirector_api.main import create_app + +pytestmark = pytest.mark.cpu + BASE = 'https://ark.cn-beijing.volces.com/api/plan/v3' diff --git a/tests/test_native_runtime.py b/tests/test_native_runtime.py index 3592b7a05..e5c909502 100644 --- a/tests/test_native_runtime.py +++ b/tests/test_native_runtime.py @@ -30,7 +30,7 @@ # Includes subprocess/gateway integration; retain the dedicated mocked-model # bundled CLI regression in Release checks independently of layer selection. -pytestmark = pytest.mark.merge +pytestmark = [pytest.mark.merge, pytest.mark.cpu] FAKE = '''import json, os, subprocess, sys from pathlib import Path diff --git a/tests/test_native_sessions.py b/tests/test_native_sessions.py index 824cc4f94..de17cc96d 100644 --- a/tests/test_native_sessions.py +++ b/tests/test_native_sessions.py @@ -8,6 +8,9 @@ from process_helpers import directory_link +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('location', ['valid', 'outside', 'invalid_turn', 'missing', 'alias', 'absent']) def test_native_session_directory_requires_owned_turn_identity(tmp_path, location): run = RunContext(runtime='opencode', project_id=uuid4(), turn_id=uuid4(), session=str(uuid4()), diff --git a/tests/test_nightly_perf_artifact.py b/tests/test_nightly_perf_artifact.py index 3ad68680b..440bff1fa 100644 --- a/tests/test_nightly_perf_artifact.py +++ b/tests/test_nightly_perf_artifact.py @@ -14,6 +14,9 @@ import pytest import yaml + +pytestmark = pytest.mark.cpu + ROOT = Path(__file__).resolve().parents[1] WORKFLOW = ROOT / '.github/workflows/nightly.yml' WORKSPACE = '/home/runner/work/OpenDirector/OpenDirector' diff --git a/tests/test_openai_images.py b/tests/test_openai_images.py index 5e2695920..996ef8870 100644 --- a/tests/test_openai_images.py +++ b/tests/test_openai_images.py @@ -24,6 +24,9 @@ from opendirector.integrations.model_adapters import OpenAIImages, adapter_for from opendirector.integrations.providers import GenerationProviders + +pytestmark = pytest.mark.cpu + GPT_IMAGE = {'kind': 'image', 'url': 'https://api.openai.com/v1', 'modelId': 'gpt-image-1', 'protocol': 'openai'} KEY = 'sk-test-never-recorded' diff --git a/tests/test_owner_rights.py b/tests/test_owner_rights.py index 235d86006..7a2ebf85f 100644 --- a/tests/test_owner_rights.py +++ b/tests/test_owner_rights.py @@ -9,6 +9,9 @@ from process_helpers import directory_link +pytestmark = pytest.mark.cpu + + USER = bytes.fromhex('010100000000000515000000') WORLD = bytes.fromhex('010100000000000100000000') diff --git a/tests/test_owner_rights_journal.py b/tests/test_owner_rights_journal.py index 6cd09b814..95b528c55 100644 --- a/tests/test_owner_rights_journal.py +++ b/tests/test_owner_rights_journal.py @@ -9,6 +9,9 @@ from opendirector.agent import owner_rights as rights +pytestmark = pytest.mark.cpu + + def failure(code): error = OSError('controlled native failure') error.winerror = code diff --git a/tests/test_owner_rights_lifecycle.py b/tests/test_owner_rights_lifecycle.py index 2e61a188c..2aa42241d 100644 --- a/tests/test_owner_rights_lifecycle.py +++ b/tests/test_owner_rights_lifecycle.py @@ -17,7 +17,7 @@ from opendirector.agent import owner_rights as rights -pytestmark = pytest.mark.skipif(os.name != 'nt', reason='requires native Windows ACL and oplock APIs') +pytestmark = [pytest.mark.skipif(os.name != 'nt', reason='requires native Windows ACL and oplock APIs'), pytest.mark.cpu] WORLD = bytes.fromhex('010100000000000100000000') diff --git a/tests/test_owner_rights_resume.py b/tests/test_owner_rights_resume.py index 1286c04f1..ac7157a3e 100644 --- a/tests/test_owner_rights_resume.py +++ b/tests/test_owner_rights_resume.py @@ -11,7 +11,7 @@ from test_owner_rights_lifecycle import security from process_helpers import directory_link -pytestmark = pytest.mark.skipif(os.name != 'nt', reason='requires native Windows ACL and file identity APIs') +pytestmark = [pytest.mark.skipif(os.name != 'nt', reason='requires native Windows ACL and file identity APIs'), pytest.mark.cpu] def initialized_work(tmp_path): diff --git a/tests/test_posix_execution_files.py b/tests/test_posix_execution_files.py index 24d6b8bde..7d6fe16c1 100644 --- a/tests/test_posix_execution_files.py +++ b/tests/test_posix_execution_files.py @@ -14,6 +14,9 @@ from opendirector.infrastructure import execution_files as files +pytestmark = pytest.mark.cpu + + @pytest.fixture def posix_files(monkeypatch): actual = os diff --git a/tests/test_process_helpers.py b/tests/test_process_helpers.py index 9469500c5..cfd13e00e 100644 --- a/tests/test_process_helpers.py +++ b/tests/test_process_helpers.py @@ -8,6 +8,9 @@ from process_helpers import project_heartbeat +pytestmark = pytest.mark.cpu + + def test_native_directory_uses_same_owner_and_is_idempotent(tmp_path): before = tmp_path.stat() report = native_user_directory(tmp_path) diff --git a/tests/test_public_target.py b/tests/test_public_target.py index 8627b5f0e..171f0b2f8 100644 --- a/tests/test_public_target.py +++ b/tests/test_public_target.py @@ -13,6 +13,9 @@ from opendirector.integrations.volcengine import _public_result_url +pytestmark = pytest.mark.cpu + + @pytest.fixture def answers(monkeypatch): values, calls = ['93.184.216.34'], [] diff --git a/tests/test_query_guidance.py b/tests/test_query_guidance.py index 08623e3f8..a7644452a 100644 --- a/tests/test_query_guidance.py +++ b/tests/test_query_guidance.py @@ -8,6 +8,9 @@ from opendirector.domain.creation.commands import Query +pytestmark = pytest.mark.cpu + + def guidance(arguments): try: TypeAdapter(Query).validate_python({'projectId': uuid4(), 'queryId': uuid4(), **arguments}) diff --git a/tests/test_rename.py b/tests/test_rename.py index 8f873069e..14d3f4a97 100644 --- a/tests/test_rename.py +++ b/tests/test_rename.py @@ -3,6 +3,9 @@ from opendirector.infrastructure.rename import rename_path +pytestmark = pytest.mark.cpu + + def test_native_rename_never_replaces_even_an_empty_destination(tmp_path): source, target = tmp_path / "source", tmp_path / "target" source.mkdir() diff --git a/tests/test_result_download_security.py b/tests/test_result_download_security.py index dd491facc..e7a17eca6 100644 --- a/tests/test_result_download_security.py +++ b/tests/test_result_download_security.py @@ -14,6 +14,9 @@ from test_openai_images import CONFIG, png +pytestmark = pytest.mark.cpu + + @pytest.fixture def resolve(monkeypatch): calls = [] diff --git a/tests/test_retired_entry.py b/tests/test_retired_entry.py index 26c477fec..584351bf2 100644 --- a/tests/test_retired_entry.py +++ b/tests/test_retired_entry.py @@ -9,6 +9,10 @@ from opendirector.infrastructure.model_configs import ModelConfigs from opendirector_api.main import create_app +import pytest + +pytestmark = pytest.mark.cpu + def files(root): return {str(p.relative_to(root)): p.read_bytes() for p in root.rglob('*') if p.is_file()} diff --git a/tests/test_rule_facts.py b/tests/test_rule_facts.py index 52525a953..00b613699 100644 --- a/tests/test_rule_facts.py +++ b/tests/test_rule_facts.py @@ -14,6 +14,9 @@ ) +pytestmark = pytest.mark.cpu + + def test_timeline_contract_limits_are_published_as_shared_facts(): from opendirector.domain.creation.editors import TimelineData, TimelineTextOverlay facts = facts_payload() diff --git a/tests/test_runtime_catalog.py b/tests/test_runtime_catalog.py index e7e0be9e9..e5034e00c 100644 --- a/tests/test_runtime_catalog.py +++ b/tests/test_runtime_catalog.py @@ -9,6 +9,9 @@ from opendirector.domain.projects import ProjectError +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('engine', ['codex', 'claude']) def test_native_model_catalog(tmp_path, monkeypatch, engine): script = tmp_path / 'cli' diff --git a/tests/test_runtime_readiness.py b/tests/test_runtime_readiness.py index 4377cd77a..3436086ff 100644 --- a/tests/test_runtime_readiness.py +++ b/tests/test_runtime_readiness.py @@ -9,6 +9,9 @@ from process_helpers import python_cli +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize(('engine', 'output', 'exit_code', 'expected'), [ ('codex', '', 0, 'ready'), ('codex', '', 1, 'needs_login'), diff --git a/tests/test_self_hosted.py b/tests/test_self_hosted.py index 2e69a56ab..ee0e983ba 100644 --- a/tests/test_self_hosted.py +++ b/tests/test_self_hosted.py @@ -20,6 +20,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def test_self_hosted_models_support_optional_auth_all_four_kinds(tmp_path): store=LocalProjects(tmp_path) headers={'X-OpenDirector-Request':'1','X-OpenDirector-Session':str(uuid4())} diff --git a/tests/test_self_hosted_proxy.py b/tests/test_self_hosted_proxy.py index dfd99fd3b..15a8c7aa2 100644 --- a/tests/test_self_hosted_proxy.py +++ b/tests/test_self_hosted_proxy.py @@ -12,6 +12,9 @@ from opendirector.integrations.providers import GenerationProviders +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('base, equivalent', [ ('http://8.92.9.154:8094/v1', 'http://8.92.9.154:8094/videos/id/content'), ('http://192.168.1.20:8093/v1', 'http://192.168.1.20:8093/videos/id/content'), diff --git a/tests/test_self_hosted_queue.py b/tests/test_self_hosted_queue.py index 577fed860..bb1165a5c 100644 --- a/tests/test_self_hosted_queue.py +++ b/tests/test_self_hosted_queue.py @@ -16,6 +16,9 @@ import httpx +pytestmark = pytest.mark.cpu + + @pytest.fixture def context(tmp_path): store, pid, session = new_project(tmp_path, '自部署排队') diff --git a/tests/test_skill_snapshot.py b/tests/test_skill_snapshot.py index 3d3a70604..84fa66ef3 100644 --- a/tests/test_skill_snapshot.py +++ b/tests/test_skill_snapshot.py @@ -9,6 +9,9 @@ from process_helpers import directory_link +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('component', ['.agents', '.agents/skills']) def test_reused_snapshot_rejects_reparse_directories_before_removal(tmp_path, monkeypatch, component): work = tmp_path / 'work' diff --git a/tests/test_subject_library.py b/tests/test_subject_library.py index 042ffc569..87c5ff137 100644 --- a/tests/test_subject_library.py +++ b/tests/test_subject_library.py @@ -7,6 +7,10 @@ from opendirector.application.creation_canvas import asset_ref from opendirector.infrastructure.creation_uploads import CreationUploads +import pytest + +pytestmark = pytest.mark.cpu + def test_subject_slot_validation_uses_actual_media_and_fifteen_second_limit(tmp_path): import wave diff --git a/tests/test_timeline_fonts.py b/tests/test_timeline_fonts.py index 7619796e9..da36ff793 100644 --- a/tests/test_timeline_fonts.py +++ b/tests/test_timeline_fonts.py @@ -96,6 +96,9 @@ def test_cmap_coverage_uses_content_identity_and_rejects_missing_characters(tmp_ from uuid import uuid4 +pytestmark = pytest.mark.cpu + + def timeline_document(project, tmp_path, *, font_bytes=None): store, pid, session = project path = tiny_font(tmp_path / 'fixture.ttf', characters='AB中') diff --git a/tests/test_timeline_packages.py b/tests/test_timeline_packages.py index ee3d203d5..ba09c4e73 100644 --- a/tests/test_timeline_packages.py +++ b/tests/test_timeline_packages.py @@ -11,6 +11,9 @@ from test_creation_assets import import_asset +pytestmark = pytest.mark.cpu + + def service(store): from opendirector.application.creation_timeline_packages import CreationTimelinePackages return CreationTimelinePackages(store) diff --git a/tests/test_timeline_source_connections.py b/tests/test_timeline_source_connections.py index 6a958ce77..27f729f01 100644 --- a/tests/test_timeline_source_connections.py +++ b/tests/test_timeline_source_connections.py @@ -7,6 +7,10 @@ from test_creation_assembly import upload_source from test_creation_canvas_service import project, send, ver +import pytest + +pytestmark = pytest.mark.cpu + def _clip(asset, clip_id, *, start=None): clip = dict(id=clip_id, resource=dict(asset=asset_ref(asset), title=asset.name), diff --git a/tests/test_tool_lifecycle.py b/tests/test_tool_lifecycle.py index 2c9aa3c0c..c2870666b 100644 --- a/tests/test_tool_lifecycle.py +++ b/tests/test_tool_lifecycle.py @@ -18,6 +18,9 @@ from test_tool_tasks import project, configure, upload, png, H3 +pytestmark = pytest.mark.cpu + + async def until(predicate): async with asyncio.timeout(5): while not predicate(): diff --git a/tests/test_tool_task_history.py b/tests/test_tool_task_history.py index 2e97cae7e..0e4753304 100644 --- a/tests/test_tool_task_history.py +++ b/tests/test_tool_task_history.py @@ -17,6 +17,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + def png(): out = BytesIO() Image.new('RGB', (64, 48), 'blue').save(out, 'PNG') diff --git a/tests/test_tool_tasks.py b/tests/test_tool_tasks.py index 4dda8eff6..922cd3266 100644 --- a/tests/test_tool_tasks.py +++ b/tests/test_tool_tasks.py @@ -18,6 +18,9 @@ from opendirector.infrastructure.model_configs import ModelConfigs from opendirector.integrations.model_adapters import OpenAIImages, adapter_for, capabilities_of + +pytestmark = pytest.mark.cpu + ZIMAGE = ('image', 'http://gpu:8210/v1', 'Tongyi-MAI/Z-Image-Turbo') H3 = ('video', 'http://gpu:8010/v1', 'MiniMaxAI/MiniMax-H3') TTS = ('audio', 'http://gpu:8220/v1', 'Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice') diff --git a/tests/test_video_capabilities.py b/tests/test_video_capabilities.py index c4504ad56..d3ae8a72e 100644 --- a/tests/test_video_capabilities.py +++ b/tests/test_video_capabilities.py @@ -19,6 +19,9 @@ from opendirector_api.main import create_app +pytestmark = pytest.mark.cpu + + CAPS = {'outputs': [ {'resolution': '540P', 'durations': [3, 5], 'width': 960, 'height': 540}, {'resolution': '720P', 'durations': [5, 7], 'width': 1280, 'height': 720}], diff --git a/tests/test_video_resolution.py b/tests/test_video_resolution.py index 90ee45976..6db5e4c06 100644 --- a/tests/test_video_resolution.py +++ b/tests/test_video_resolution.py @@ -17,6 +17,9 @@ from opendirector.integrations.vllm_omni import VllmOmniGeneration +pytestmark = pytest.mark.cpu + + @pytest.mark.parametrize('resolution, ratio, expected', [ ('480P', '16:9', '832x480'), ('480P', '9:16', '480x832'), ('768P', '16:9', '1344x768'), ('768P', '9:16', '768x1344'), diff --git a/tests/test_vllm_omni_h3.py b/tests/test_vllm_omni_h3.py index 776d6a157..bf3cda76d 100644 --- a/tests/test_vllm_omni_h3.py +++ b/tests/test_vllm_omni_h3.py @@ -23,6 +23,9 @@ from opendirector.integrations.vllm_omni import VllmOmniGeneration, h3_frames from opendirector.integrations.volcengine import VolcengineGeneration + +pytestmark = pytest.mark.cpu + H3 = {'protocol': 'vllm_omni', 'kind': 'video', 'url': 'http://gpu-box:8000/v1', 'modelId': 'MiniMaxAI/MiniMax-H3', 'apiKey': 'token'} diff --git a/tests/test_vllm_omni_image.py b/tests/test_vllm_omni_image.py index fea96ab5e..d353cc681 100644 --- a/tests/test_vllm_omni_image.py +++ b/tests/test_vllm_omni_image.py @@ -18,6 +18,9 @@ from opendirector.integrations import vllm_omni_image from opendirector.integrations.providers import GenerationProviders + +pytestmark = pytest.mark.cpu + ZIMAGE = {'kind': 'image', 'url': 'http://gpu-box:8200/v1', 'modelId': 'Tongyi-MAI/Z-Image-Turbo', 'apiKey': 'token'} diff --git a/tests/test_voice_library.py b/tests/test_voice_library.py index 47f695a1d..152461e65 100644 --- a/tests/test_voice_library.py +++ b/tests/test_voice_library.py @@ -11,6 +11,9 @@ from opendirector.domain.projects import ProjectError +pytestmark = pytest.mark.cpu + + def config(model='MOSS-TTS-Nano', **patch): return dict(id=str(uuid4()), kind='audio', url='http://voice.test/v1', modelId=model, protocol='openai', connectionType='self_hosted', authMode='bearer', apiKey='private-key', **patch) diff --git a/tests/test_zhipu.py b/tests/test_zhipu.py index e9d7b772b..315c5b6d6 100644 --- a/tests/test_zhipu.py +++ b/tests/test_zhipu.py @@ -22,6 +22,9 @@ from test_creation_generation_service import anyio_backend # noqa: F401 +pytestmark = pytest.mark.cpu + + CHAT = {"modelId": "glm-5.3", "url": "https://open.bigmodel.cn/api/paas/v4"} From 93db62cbc0702b72dc593bef418ad0b3acb1f0e7 Mon Sep 17 00:00:00 2001 From: wangyu <410167048@qq.com> Date: Mon, 16 Nov 2026 19:14:19 +0800 Subject: [PATCH 2/2] chore(pre-commit): remove bilingual descriptions from workflow outputs - Updated the `pre-commit.yml` workflow file to remove bilingual descriptions from the outputs, simplifying the language to English only for clarity. - Adjusted the names of the output parameters to maintain consistency and improve readability. No functional changes were made to the workflow logic. Signed-off-by: wangyu <410167048@qq.com> --- .github/workflows/pre-commit.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f4d667426..fcddc0e3f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -4,13 +4,13 @@ on: workflow_call: outputs: run-heavy: - description: Whether heavy checks are required / 是否需要重检查 + description: Whether heavy checks are required value: ${{ jobs.check.outputs.run-heavy }} scope-reason: - description: Reason for the selected scope / 检查范围依据 + description: Reason for the selected scope value: ${{ jobs.check.outputs.scope-reason }} changed-files: - description: Number of changed paths / 变更路径数量 + description: Number of changed paths value: ${{ jobs.check.outputs.changed-files }} workflow_dispatch: @@ -49,7 +49,7 @@ jobs: python -m pre_commit run --all-files fi - id: scope - name: Select check scope / 判断检查范围 + name: Select check scope env: PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} run: python scripts/pre-commit/select_checks.py