Skip to content

ci(driver-deps): fork-friendly vmouse fetch via public mirror + non-fatal mode#662

Merged
qiin2333 merged 2 commits into
masterfrom
fix/fork-pr-driver-deps
May 18, 2026
Merged

ci(driver-deps): fork-friendly vmouse fetch via public mirror + non-fatal mode#662
qiin2333 merged 2 commits into
masterfrom
fix/fork-pr-driver-deps

Conversation

@qiin2333
Copy link
Copy Markdown
Collaborator

Problem

Fork PRs (e.g. external CVE backports like #659) cannot access org-scoped secrets in GitHub Actions. CMake configure downloads the vmouse driver from the private repo AlkaidLab/ZakoVirtualMouse and aborts with FATAL_ERROR when no GITHUB_TOKEN is available, blocking the entire Windows build:

CMake Error at cmake/packaging/FetchDriverDeps.cmake:272 (message):
  Missing driver dependencies:
    .../build/_driver_deps/vmouse/ZakoVirtualMouse.dll

Observed on run 26000570915 (PR #659, unrelated CVE backport).

Fix

1. Public mirror first

  • New cache var VMOUSE_PUBLIC_REPO (default AlkaidLab/zako-vmouse-release).
  • _fetch_vmouse() first tries the public mirror via plain browser_download_url (no auth); falls back to the private API path only if GITHUB_TOKEN is set.

2. Graceful degradation (DRIVER_DEPS_REQUIRED option)

  • New option DRIVER_DEPS_REQUIRED (default ON — preserves existing behavior).
  • When OFF, per-driver missing files become WARNING and a <NAME>_DRIVER_AVAILABLE cache flag is set to FALSE.
  • windows.cmake gates each driver's install(FILES ...) block on its availability flag.
  • sunshine.iss.in adds skipifsourcedoesntexist to the vmouse driver wildcard.

3. Workflow

  • Build Windows now passes -DDRIVER_DEPS_REQUIRED=${DRIVER_DEPS_REQUIRED}, evaluating to OFF only for PRs from forks. All other triggers stay ON.

Effect

Scenario Before After
Push / internal PR / release OK OK (unchanged)
Fork PR FAIL at configure OK, vmouse omitted from installer
Public mirror populated n/a OK without token
Public mirror empty + no token n/a WARNING + skip

Validation

Locally exercised both paths:

  • -DDRIVER_DEPS_REQUIRED=ON with vmouse cached → normal config
  • -DDRIVER_DEPS_REQUIRED=OFF with no token, public mirror empty → WARNING, configure completes

Follow-up

Populate AlkaidLab/zako-vmouse-release with the v1.2.0 assets (or whatever VMOUSE_DRIVER_VERSION points to) so fork PRs get a full installer.

…atal mode

Fork PRs (e.g. external CVE backports) cannot access org-scoped
secrets, so the private repo AlkaidLab/ZakoVirtualMouse download for
the vmouse driver fails and aborts CMake configure with FATAL_ERROR.
This blocked CI on PR #659 (CVE-2025-54081) even though the patch
itself was unrelated to the driver pipeline.

Two layered fixes:

1. Public mirror first (cmake/packaging/FetchDriverDeps.cmake):
   - New cache var VMOUSE_PUBLIC_REPO (default AlkaidLab/zako-vmouse-release).
   - _fetch_vmouse() now tries the public mirror via plain
     browser_download_url (no auth) before falling back to the private
     repo's GitHub API path. Public mirror release tag and asset
     filenames must match VMOUSE_DRIVER_VERSION.

2. Graceful degradation (DRIVER_DEPS_REQUIRED option):
   - New option DRIVER_DEPS_REQUIRED (default ON, preserves existing
     behavior).
   - When OFF, missing driver files become WARNING instead of
     FATAL_ERROR, per-driver _CHECK_DRIVER_AVAILABLE cache var is set,
     and packaging skips the affected driver entirely.
   - windows.cmake gates each driver's install(FILES ...) on its
     availability flag.
   - sunshine.iss.in adds 'skipifsourcedoesntexist' to the vmouse
     driver wildcard so Inno doesn't abort when the dir is empty.

3. Workflow (.github/workflows/main.yml):
   - Build Windows step now passes
     -DDRIVER_DEPS_REQUIRED=${DRIVER_DEPS_REQUIRED}, which evaluates to
     OFF only when github.event_name == 'pull_request' && head repo is
     a fork. All other triggers (push, internal PR, release) stay ON.

Net effect: fork PRs configure/build/package successfully (just
without the vmouse component); internal PRs and release builds are
unchanged.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9969e8a6-df40-40c3-baf5-fb2caff7012d

📥 Commits

Reviewing files that changed from the base of the PR and between 3560937 and 98ed50d.

📒 Files selected for processing (1)
  • cmake/packaging/FetchDriverDeps.cmake
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (1)
cmake/**

⚙️ CodeRabbit configuration file

cmake/**: CMake 构建系统文件。审查跨平台兼容性、现代 CMake 实践。

Files:

  • cmake/packaging/FetchDriverDeps.cmake
🔇 Additional comments (4)
cmake/packaging/FetchDriverDeps.cmake (4)

8-16: LGTM!

Also applies to: 35-35, 47-48


147-172: LGTM!


174-180: LGTM!


298-342: LGTM!


Summary by CodeRabbit

  • 新特性

    • 构建配置可根据触发来源自动调整驱动依赖严格性(fork PR 情况下放宽为可选)。
    • 增加公共镜像作为驱动下载备用源,缺失时在有权限的情况下回退至私有源。
  • 改进

    • 按驱动项分别跟踪可用性并在安装/打包时有条件跳过缺失驱动,避免整个流程失败。
    • 安装脚本在源目录不存在时跳过对应文件项,提升安装鲁棒性。

Walkthrough

为 Windows CI 与打包流程添加 DRIVER_DEPS_REQUIRED 开关(fork PR 可设为 OFF),FetchDriverDeps 优先尝试公共镜像再回退私有仓库,并通过 per-driver 可用性标志条件化安装或跳过驱动文件,安装脚本在源缺失时跳过条目。

更改内容

驱动依赖可选化与公共镜像回退

层级 / 文件 摘要
GitHub Actions fork 检测与传参
.github/workflows/main.yml
新增 DRIVER_DEPS_REQUIRED 环境变量:fork PR 设为 OFF,其他情况设为 ON;在 CMake 配置命令中传入 -DDRIVER_DEPS_REQUIRED=${DRIVER_DEPS_REQUIRED}
CMake 驱动依赖配置选项
cmake/packaging/FetchDriverDeps.cmake
声明 DRIVER_DEPS_REQUIRED 选项用于控制缺失驱动时的错误等级,新增 VMOUSE_PUBLIC_REPO 缓存变量并补充文档注释说明下载优先级与语义。
虚拟鼠标驱动公共镜像与回退
cmake/packaging/FetchDriverDeps.cmake
修改 _fetch_vmouse:先尝试从 VMOUSE_PUBLIC_REPO 公共镜像下载所需文件;若仍缺失且未配置 GITHUB_TOKEN 则发出 WARNING 并返回;若配置 token 则回退到私有仓库通过 GitHub API 下载。
逐驱动可用性校验与条件标志
cmake/packaging/FetchDriverDeps.cmake
新增 _check_driver 辅助函数逐驱动验证关键文件;根据 DRIVER_DEPS_REQUIRED 决定缺失时触发 FATAL_ERROR 还是仅发出 WARNING;设置 VMOUSE_DRIVER_AVAILABLEVDD_DRIVER_AVAILABLEVDD_WIN10_DRIVER_AVAILABLENEFCON_DRIVER_AVAILABLE 等缓存标志。
条件化驱动安装与跳过
cmake/packaging/windows.cmake, cmake/packaging/sunshine.iss.in
将 VDD、VDD_WIN10、VMOUSE 的 install(FILES ...) 改为基于对应可用性标志的条件安装;Inno Setup 的 vmouse 文件条目加入 skipifsourcedoesntexist,源目录不存在时跳过。

Sequence Diagram

sequenceDiagram
  participant GHA as GitHub Actions
  participant CMake as CMake 配置
  participant FetchDeps as FetchDriverDeps.cmake
  participant Check as _check_driver
  participant Installer as windows.cmake / Inno Setup
  GHA->>CMake: 设置 DRIVER_DEPS_REQUIRED (OFF for fork, ON otherwise)
  CMake->>FetchDeps: 调用 FetchDriverDeps 并传入 DRIVER_DEPS_REQUIRED
  FetchDeps->>FetchDeps: 尝试从 VMOUSE_PUBLIC_REPO 下载 vmouse 资产
  alt 公共镜像下载成功
    FetchDeps->>Check: 补齐后继续
  else 公共镜像失败且无 GITHUB_TOKEN
    FetchDeps->>Check: 发出 WARNING 并返回
  else 公共镜像失败且有 GITHUB_TOKEN
    FetchDeps->>FetchDeps: 回退到私有仓库通过 GitHub API 下载
  end
  FetchDeps->>Check: 对每个驱动调用 _check_driver,设置 *_DRIVER_AVAILABLE 标志或触发 FATAL/WARNING
  Check->>Installer: Installer 根据 *_DRIVER_AVAILABLE 条件化安装或跳过文件
  Installer->>Installer: Inno Setup 跳过缺失源目录的 vmouse 条目 (skipifsourcedoesntexist)
Loading

相关 PR


🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了此 PR 的核心变化:通过公开镜像实现对 fork PR 友好的 vmouse 获取,并添加非致命失败模式。
Description check ✅ Passed 描述详细阐述了问题根源、三个解决方案组件及其效果,与所有代码变更直接相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fork-pr-driver-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmake/packaging/FetchDriverDeps.cmake`:
- Around line 331-334: The current _check_driver calls only verify ZakoVDD.dll
and thus report availability even when driver package files are missing; update
the checks to require the full installer set by either extending _check_driver
to accept multiple expected file paths or by invoking it with all required files
(ZakoVDD.dll, the .inf, .cat and .cer) for both VDD_DRIVER_DIR and
VDD_WIN10_DRIVER_DIR, and ensure the availability flags VDD_DRIVER_AVAILABLE and
VDD_WIN10_DRIVER_AVAILABLE only become true if every required file exists so
install(FILES ...) won't fail later.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0ba8c7cb-b4ce-4739-bb4c-f444916ac3f0

📥 Commits

Reviewing files that changed from the base of the PR and between 3d75ab0 and 3560937.

📒 Files selected for processing (4)
  • .github/workflows/main.yml
  • cmake/packaging/FetchDriverDeps.cmake
  • cmake/packaging/sunshine.iss.in
  • cmake/packaging/windows.cmake
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (1)
cmake/**

⚙️ CodeRabbit configuration file

cmake/**: CMake 构建系统文件。审查跨平台兼容性、现代 CMake 实践。

Files:

  • cmake/packaging/sunshine.iss.in
  • cmake/packaging/windows.cmake
  • cmake/packaging/FetchDriverDeps.cmake
🔇 Additional comments (4)
.github/workflows/main.yml (1)

197-201: LGTM!

Also applies to: 211-211

cmake/packaging/FetchDriverDeps.cmake (1)

35-36: LGTM!

Also applies to: 47-48, 149-179, 301-326

cmake/packaging/windows.cmake (1)

68-83: LGTM!

Also applies to: 90-97

cmake/packaging/sunshine.iss.in (1)

231-231: LGTM!

Comment thread cmake/packaging/FetchDriverDeps.cmake Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • cmake/packaging/FetchDriverDeps.cmake

Commit: 98ed50de8d6b3396be88e9910e92d0b3d5a5612c

The changes have been pushed to the fix/fork-pr-driver-deps branch.

Time taken: 1m 55s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@qiin2333 qiin2333 merged commit 98d1e94 into master May 18, 2026
4 checks passed
@qiin2333 qiin2333 deleted the fix/fork-pr-driver-deps branch May 18, 2026 11:18
qiin2333 added a commit that referenced this pull request May 19, 2026
…atal mode (#662)

* ci(driver-deps): fork-friendly vmouse fetch via public mirror + non-fatal mode

Fork PRs (e.g. external CVE backports) cannot access org-scoped
secrets, so the private repo AlkaidLab/ZakoVirtualMouse download for
the vmouse driver fails and aborts CMake configure with FATAL_ERROR.
This blocked CI on PR #659 (CVE-2025-54081) even though the patch
itself was unrelated to the driver pipeline.

Two layered fixes:

1. Public mirror first (cmake/packaging/FetchDriverDeps.cmake):
   - New cache var VMOUSE_PUBLIC_REPO (default AlkaidLab/zako-vmouse-release).
   - _fetch_vmouse() now tries the public mirror via plain
     browser_download_url (no auth) before falling back to the private
     repo's GitHub API path. Public mirror release tag and asset
     filenames must match VMOUSE_DRIVER_VERSION.

2. Graceful degradation (DRIVER_DEPS_REQUIRED option):
   - New option DRIVER_DEPS_REQUIRED (default ON, preserves existing
     behavior).
   - When OFF, missing driver files become WARNING instead of
     FATAL_ERROR, per-driver _CHECK_DRIVER_AVAILABLE cache var is set,
     and packaging skips the affected driver entirely.
   - windows.cmake gates each driver's install(FILES ...) on its
     availability flag.
   - sunshine.iss.in adds 'skipifsourcedoesntexist' to the vmouse
     driver wildcard so Inno doesn't abort when the dir is empty.

3. Workflow (.github/workflows/main.yml):
   - Build Windows step now passes
     -DDRIVER_DEPS_REQUIRED=${DRIVER_DEPS_REQUIRED}, which evaluates to
     OFF only when github.event_name == 'pull_request' && head repo is
     a fork. All other triggers (push, internal PR, release) stay ON.

Net effect: fork PRs configure/build/package successfully (just
without the vmouse component); internal PRs and release builds are
unchanged.

* fix: apply CodeRabbit auto-fixes

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant