12 个版本 (6 个重大更新)
0.7.1 | 2022 年 9 月 30 日 |
---|---|
0.7.0 | 2022 年 3 月 15 日 |
0.6.1 | 2021 年 11 月 24 日 |
0.4.0 | 2021 年 2 月 24 日 |
0.2.0 | 2020 年 6 月 20 日 |
#4 in #guppy
每月下载量 44,077
在 11 个crate中使用 (通过 guppy)
66KB
1.5K SLoC
guppy-summaries
提供序列化、反序列化和比较构建摘要的功能。
构建摘要是一个记录在目标平台和主机平台上构建了哪些包和特性的记录。摘要文件可以提交到仓库中,保持最新状态并在 CI 中进行比较,从而可以跟踪构建结果随时间的变化。
guppy-summaries
被设计得小巧且独立于主要的 guppy
crate。
示例
use guppy_summaries::{Summary, SummaryId, SummarySource, PackageStatus};
use pretty_assertions::assert_eq;
use semver::Version;
use std::collections::BTreeSet;
use toml::Value;
// A summary is a TOML file that has this format:
static SUMMARY: &str = r#"
[[target-package]]
name = "foo"
version = "1.2.3"
workspace-path = "foo"
status = 'initial'
features = ["feature-a", "feature-c"]
[[host-package]]
name = "proc-macro"
version = "0.1.2"
workspace-path = "proc-macros/macro"
status = 'workspace'
features = ["macro-expand"]
[[host-package]]
name = "bar"
version = "0.4.5"
crates-io = true
status = 'direct'
features = []
"#;
// The summary can be deserialized:
let summary = Summary::parse(SUMMARY).expect("from_str succeeded");
// ... and a package and its features can be looked up.
let summary_id = SummaryId::new("foo", Version::new(1, 2, 3), SummarySource::workspace("foo"));
let info = &summary.target_packages[&summary_id];
assert_eq!(info.status, PackageStatus::Initial, "correct status");
assert_eq!(
info.features.iter().map(|feature| feature.as_str()).collect::<Vec<_>>(),
["feature-a", "feature-c"],
"correct feature list"
);
// Another summary.
static SUMMARY2: &str = r#"
[[target-package]]
name = "foo"
version = "1.2.4"
workspace-path = "new-location/foo"
status = 'initial'
features = ["feature-a", "feature-b"]
[[target-package]]
name = "once_cell"
version = "1.4.0"
source = "git+https://github.com/matklad/once_cell?tag=v1.4.0"
status = 'transitive'
features = ["std"]
[[host-package]]
name = "bar"
version = "0.4.5"
crates-io = true
status = 'direct'
features = []
"#;
let summary2 = Summary::parse(SUMMARY2).expect("from_str succeeded");
// Diff summary and summary2.
let diff = summary.diff(&summary2);
// Pretty-print a report generated from the diff.
let diff_str = format!("{}", diff.report());
assert_eq!(
r#"target packages:
A once_cell 1.4.0 (transitive third-party, external 'git+https://github.com/matklad/once_cell?tag=v1.4.0')
* features: std
M foo 1.2.4 (initial, path 'new-location/foo')
* version upgraded from 1.2.3
* source changed from path 'foo'
* added features: feature-b
* removed features: feature-c
* (unchanged features: feature-a)
* (unchanged optional dependencies: [none])
host packages:
R proc-macro 0.1.2 (workspace, path 'proc-macros/macro')
* (old features: macro-expand)
"#,
diff_str,
);
贡献
有关如何帮助的详细信息,请参阅 CONTRIBUTING 文件。
许可
此项目可在 Apache 2.0 许可证或 MIT 许可证的条款下使用。
依赖项
~2–2.8MB
~54K SLoC