fix(release): 修复 CI 阻断与发布链路,强制版本一致性
- sysmon 采样测试改为分平台断言:此前无条件断言 working_set > 0,非 Windows 上 cargo test 必失败,v* tag 会停在测试阶段(test job 恰好跑在 ubuntu-latest) - CI test job 补齐 GPUI 的 Linux 系统依赖,--lib --tests 让集成测试参与编译 - meta job 校验 tag 与 gpui-app/Cargo.toml 版本一致:忘 bump 会导致新版本装完仍自报旧版,客户端反复提示同一更新 - 发布脚本:--exact-match 取 tag 并强制 semver 校验(--always 会产出 v1.0.0-4-gbc9f55c 这类客户端 release_part 截断后判定不新的版本,且该 Release 会占据 /releases/latest 遮蔽真更新);Release 创建/查询/解析失败一律 exit 1,不再让 job 变绿而 OTA 通道为空 - sysmon CPU 差分基准只在真正算出结果时前移:采样间隔过近沿用上次读数,修复手点立即刷新永远读到 0%;修正 cpu_percent 注释口径(0~100,整机占比) - README 订正发布流程:CI 实际仅出 Linux 产物;补 Release 附件(7z/裸二进制/.sha256)这一 OTA 唯一通道与命名约定;token 需 repo 写权限
This commit is contained in:
+22
-3
@@ -14,7 +14,8 @@ pub struct Sample {
|
||||
pub peak_working_set: u64,
|
||||
/// 提交内存(私有字节)
|
||||
pub private_bytes: u64,
|
||||
/// 自上次采样以来的 CPU 占用百分比(按可用核数归一,0~100×核数内)
|
||||
/// 自上次采样以来的 CPU 占用(占整机容量的百分比 0~100,已按核数归一,
|
||||
/// 与任务管理器的"总利用率"同口径)
|
||||
pub cpu_percent: f32,
|
||||
/// 线程数
|
||||
pub threads: u32,
|
||||
@@ -26,6 +27,8 @@ pub struct Sample {
|
||||
pub struct Sampler {
|
||||
pid: u32,
|
||||
last_cpu: Option<(u64, u64, Instant)>,
|
||||
/// 上一次成功算出的占用率:采样间隔过近时沿用,避免读数跳回 0
|
||||
last_percent: f32,
|
||||
}
|
||||
|
||||
impl Sampler {
|
||||
@@ -33,6 +36,7 @@ impl Sampler {
|
||||
Self {
|
||||
pid: std::process::id(),
|
||||
last_cpu: None,
|
||||
last_percent: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +124,16 @@ impl Sampler {
|
||||
if dt > 0.05 {
|
||||
let cpu_secs = ((k - pk) + (u - pu)) as f32 / 1e7;
|
||||
cpu_percent = cpu_secs / dt / cores * 100.;
|
||||
self.last_percent = cpu_percent;
|
||||
// 只有真正算出结果才前移差分基准:否则连续两次快速采样
|
||||
// 会既报 0 又把基准推到"刚刚",用户手点"立即刷新"永远读到 0%
|
||||
self.last_cpu = Some((k, u, now));
|
||||
} else {
|
||||
cpu_percent = self.last_percent;
|
||||
}
|
||||
} else {
|
||||
self.last_cpu = Some((k, u, now));
|
||||
}
|
||||
self.last_cpu = Some((k, u, now));
|
||||
}
|
||||
|
||||
// ── 线程数 / 句柄数 ──
|
||||
@@ -191,7 +202,15 @@ mod tests {
|
||||
let first = s.sample().expect("采样应成功");
|
||||
std::thread::sleep(Duration::from_millis(30));
|
||||
let second = s.sample().expect("第二次采样应成功");
|
||||
assert!(second.working_set > 0, "工作集应大于 0");
|
||||
// 采样能力分平台:Windows 采集真实数据,其余平台按契约返回全零占位样本。
|
||||
// 这里用 if cfg! 而不是 #[cfg]:两个分支都参与编译,避免只在某一个平台上
|
||||
// 才发现语法/类型错误。此前无条件断言 > 0,导致 Linux 上 cargo test 必失败,
|
||||
// 而 CI 的 test job 正是跑在 ubuntu-latest 上,v* tag 会直接停在测试阶段。
|
||||
if cfg!(target_os = "windows") {
|
||||
assert!(second.working_set > 0, "工作集应大于 0");
|
||||
} else {
|
||||
assert_eq!(second.working_set, 0, "非 Windows 平台应返回全零占位样本");
|
||||
}
|
||||
let _ = (first, second);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user