ci: 发布 PR 只跑发布元数据校验,跳过全平台测试 - #237
Merged
Merged
Conversation
只改 CHANGELOG.md / main/Cargo.toml / Cargo.lock 的发布 PR 此前仍要跑 macOS / Linux / Windows 三平台全量测试(Windows job 约 25 分钟),而改动里 没有任何代码,这些测试没有意义。 - ci.yml 新增 classify job:PR 场景下用 script/release_pr.py 判定是否只包含 发布改动,是则跳过 test 与 windows-rdp-probe,改为就地校验发布元数据 - script/release_pr.py:分类规则为「改动文件全部属于发布白名单」且 「Cargo.toml / Cargo.lock 的差异只有 version = "..." 行」;命中后校验 main/Cargo.toml 与 Cargo.lock 中 main 包版本一致,且该版本的双语 changelog 条目完整(更新内容/修复与优化 + What's New/Fixes and Improvements,含 CNB 镜像行);无法算出 diff 时回退到全量测试 - ci-gate 仍是唯一必需状态检查,分类或校验失败都会拦住合并 - .github/RELEASE.md 记录该快速通道 - windows_rdp_host 契约测试钉住 classify/needs/if 结构与脚本白名单 验证: - python3 -m unittest discover -s script/tests -p "test_release_pr.py" — 16 passed - cargo test -p windows_rdp_host --test contract — 40 passed - ruby -ryaml 解析 ci.yml,核对 classify/test/windows-rdp-probe/ci-gate 的 needs 与 if 表达式 - rustfmt --edition 2024 --check crates/windows_rdp_host/tests/contract.rs
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.
背景
发版流程里最贵的一步是发布 PR 的 CI:它只改
CHANGELOG.md和版本号,却要和功能 PR 一样跑 macOS / Linux / Windows 三平台全量测试(Windows job 约 25 分钟)。这次发 v0.18.3 时实测就是这样——改动里没有一行代码,测试却要重跑一遍。本 PR 给这类「发布 PR」加一条快速通道,同时保证
CI gate仍然是唯一必需检查,不会让坏 changelog 混进main。包含的改动
.github/workflows/ci.yml:classifyjob(仅pull_request事件),跑python3 script/release_pr.py check,命中则输出release_only=truetest与windows-rdp-probe增加if: needs.classify.outputs.release_only != 'true',命中快速通道时跳过;push到main或手动workflow_dispatch指定平台时照旧跑全量ci-gate的needs加入classify(唯一必需状态检查不变)script/release_pr.py(新增):CHANGELOG.md/main/Cargo.toml/Cargo.lock,且Cargo.toml、Cargo.lock的差异只有version = "..."行——顺手改依赖或任何代码都会掉回全量测试main/Cargo.toml与Cargo.lock中main包版本必须一致;该版本的双语 changelog 条目必须存在、完整(更新内容/修复与优化+What's New/Fixes and Improvements)并带 CNB 镜像行.github/RELEASE.md:新增「Release-only pull requests」一节记录该快速通道与判定条件crates/windows_rdp_host/tests/contract.rs:新增契约测试钉住classify的结构、needs/if表达式与脚本白名单效果
只改 changelog + 版本号的发布 PR:全平台测试被跳过,只跑「分类 + 发布元数据校验」,秒级完成;任何真实代码或依赖改动照旧跑三平台全量测试。
验证
python3 -m unittest discover -s script/tests -p "test_release_pr.py"— 16 passed(分类正向/反向、依赖变更、空 diff、版本号不一致、changelog 缺失、diff 不可用回退等)cargo test -p windows_rdp_host --test contract— 40 passedruby -ryaml解析.github/workflows/ci.yml,核对各 job 的needs与ifrustfmt --edition 2024 --check crates/windows_rdp_host/tests/contract.rs