Skip to content

fix(ci): preflight self-hosted runner prerequisites#1339

Merged
ZR233 merged 1 commit into
devfrom
codex/ci-self-hosted-preflight
Jun 22, 2026
Merged

fix(ci): preflight self-hosted runner prerequisites#1339
ZR233 merged 1 commit into
devfrom
codex/ci-self-hosted-preflight

Conversation

@ZR233

@ZR233 ZR233 commented Jun 22, 2026

Copy link
Copy Markdown
Member

问题

#813 记录了 self-hosted run_host 类 CI 在正式测试前因为 runner 基础环境不满足约定而失败的问题:有些 runner 缺少 rustc/cargo,有些标记为 intel,kvm 的 runner 没有可用 /dev/kvm 或权限不正确。失败原本会晚到 QEMU 或测试命令内部才暴露,日志不够直接。

修改

  • .github/workflows/reusable-command.yml 的 host 执行路径新增 self-hosted preflight:
    • 只在 runs_on 包含 self-hosted 时执行;
    • 检查 rustccargo 是否在 GitHub Actions service 的 PATH 中可见,并输出 rustc -vVcargo -V
    • 输出 runner 名称、OS/arch、要求标签、当前用户与用户组,方便维护者定位具体 runner。
  • 新增 require_kvm workflow_call 输入,用于需要 KVM 的 self-hosted job:
    • 检查 /dev/kvm 是否存在且对 runner 用户可读写;
    • 输出 /dev/kvm 权限、KVM 模块线索和 CPU vendor/implementer;
    • 失败时在测试命令运行前用 ::error:: 和 step summary 明确指出前置条件问题。
  • ci.yml 中只给 self-hosted/linux/intel/kvm 的 x86_64 VMX/UEFI/axloader 项设置 require_kvm: true,避免普通 self-hosted/board 任务误要求 KVM。
  • 保留现有矩阵 fail-fast 行为不变,使前置条件失败仍能快速停止相关矩阵,避免浪费 CI 资源。

验证

  • python3 解析 .github/workflows/ci.yml.github/workflows/reusable-command.yml 成功。
  • 从 workflow 中提取 preflight shell 后执行:
    • bash -n /tmp/self-hosted-preflight.sh
    • REQUIRE_KVM=false 本地 dry run 通过。
    • REQUIRE_KVM=true 本地 dry run 通过,并确认 /dev/kvm 可用。
  • /tmp/actionlint/actionlint -ignore 'unexpected key "queue"' .github/workflows/ci.yml .github/workflows/reusable-command.yml 通过。
    • 这里忽略的是仓库既有 concurrency.queue: max 对当前 actionlint 版本的报错,不是本 PR 新增内容。
  • git diff --check 通过。

Fixes #813

@ZR233
ZR233 marked this pull request as ready for review June 22, 2026 03:00

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR 审查总结

变更内容

本 PR 在 .github/workflows/reusable-command.ymlrun_host 任务中新增了 self-hosted runner preflight 检查步骤,并在 .github/workflows/ci.yml 中为需要 KVM 的 x86_64 VMX/UEFI/axloader 矩阵项设置 require_kvm: true

具体变更:

  1. 新增 require_kvm workflow_call 输入(boolean,默认 false)
  2. 新增 Preflight 步骤:仅在 runs_on 包含 self-hosted 时执行
    • 检查 rustccargo 是否在 PATH 中可见,输出版本信息
    • 输出 runner 名称、OS/arch、用户和组信息
    • require_kvm=true 时检查 /dev/kvm 存在性和读写权限
    • 输出 KVM 模块信息和 CPU vendor
    • 失败时通过 ::error:: 和 step summary 明确报告
  3. ci.yml 中仅对 self-hosted/linux/intel/kvm 的 x86_64 项设置 require_kvm: true

实现逻辑

实现正确且符合项目需求:

  • Preflight 正确放置在 run_host 任务中(run_container 不需要,因为容器镜像已预装工具)
  • KVM 检查仅在明确需要的矩阵项上启用,避免误报
  • set -euo pipefail 保证脚本健壮性
  • record_error 函数收集所有错误后统一退出,而非遇到第一个错误就停止
  • lsmod 未找到 KVM 模块时仅发出 warning(合理,因为 KVM 可能是内建模块)

CI 状态

  • Push 事件 run #6857:success
  • PR 事件 run #6858:所有矩阵项为 skipped(因为本 PR 仅修改 workflow 文件,路径过滤导致测试矩阵被跳过)。这是预期行为,不属于 PR 导致的 CI 失败。

本地验证

  • Shell 语法检查:bash -n 通过 ✓
  • PR 正文声明的 actionlintbash -n 验证已由作者完成
  • 本 PR 仅修改 YAML workflow 文件,无需 Rust 编译/测试验证

重复/重叠分析

搜索了当前 open PRs(#1340 ax-net 重构、#1336 sdio-host、#1333 image 工具),均与本 PR 完全无关。本 PR 解决的 CI preflight 问题 (#813) 没有其他 PR 在处理。

历史评论

无先前 review 评论或 issue 评论需要处理。

结论

本 PR 质量良好,正确解决了 #813 中描述的 self-hosted runner 环境不满足前置条件的问题。代码简洁、作用域恰当、验证充分。建议合并。

Powered by mimo-v2.5-pro

@ZR233
ZR233 merged commit b605d3f into dev Jun 22, 2026
106 of 110 checks passed
@ZR233
ZR233 deleted the codex/ci-self-hosted-preflight branch June 22, 2026 04:32
@ZR233 ZR233 mentioned this pull request Jun 22, 2026
Antareske pushed a commit to Antareske/tgoskits that referenced this pull request Jun 27, 2026
Antareske pushed a commit to Antareske/tgoskits that referenced this pull request Jun 27, 2026
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.

ci(infra): harden self-hosted x86_64 runner Rust and KVM prerequisites

1 participant