ci: 依赖感知的测试目标选择,按变更范围动态运行 CI 测试#369
Open
yoinspiration wants to merge 4 commits intoarceos-hypervisor:masterfrom
Open
ci: 依赖感知的测试目标选择,按变更范围动态运行 CI 测试#369yoinspiration wants to merge 4 commits intoarceos-hypervisor:masterfrom
yoinspiration wants to merge 4 commits intoarceos-hypervisor:masterfrom
Conversation
Add `cargo xtask affected` command that analyzes git changes against a base ref and determines which test targets (QEMU aarch64/x86_64, board phytiumpi/rk3568) actually need to run. The analysis works in three phases: 1. git diff detects changed files 2. cargo metadata builds the workspace reverse dependency graph, then BFS propagates changes to all affected crates 3. Path-based and crate-based rules map affected crates to concrete test targets Update CI workflows (test-qemu.yml, test-board.yml) to run a lightweight `detect` job on ubuntu-latest before dispatching actual tests on self-hosted hardware runners, skipping targets unaffected by the change. Co-authored-by: Cursor <cursoragent@cursor.com>
cargo_metadata 0.23 returns PackageName instead of String for package names. Convert with to_string() to match HashMap key types. Co-authored-by: Cursor <cursoragent@cursor.com>
The previous logic treated axruntime/axconfig as "all tests needed" whenever they appeared in the affected set. This caused false positives for target-specific deps (e.g. axplat-x86-qemu-q35 is a cfg(x86_64) dep of axruntime). Now only trigger all tests when these core modules are directly modified. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
aarkegz
reviewed
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
实现依赖感知的 CI 测试目标选择:根据代码变更和 workspace 依赖关系,只对受影响的目标运行测试,减少不必要的硬件占用和等待时间。
动机
axruntime)变更会影响依赖它的上层模块,需要根据依赖正确选择测试目标实现方式
三阶段流程
git diff获取变更文件,过滤文档等非代码文件cargo metadata构建 workspace 反向依赖图,BFS 找出受影响的 crate文件变更
xtask/src/affected.rsxtask/src/main.rscargo xtask affected子命令.github/workflows/test-qemu.ymldetectjob 动态构建矩阵.github/workflows/test-board.ymldoc/dependency-aware-testing.mdCI 流程调整
使用方式
# 本地:对比 main 分支查看需要运行的测试 cargo xtask affected --base origin/mainCI 会在 push/PR 时自动执行 detect 并选择测试目标,无需额外配置。
验证
已在本地覆盖以下典型场景:
skip_all=true,跳过所有测试