#cargo-command #cargo #features #combination #cargo-build #cargo-subcommand

bin+lib cargo-feature-combinations

运行针对所有功能组合的 cargo 命令

15 个版本

0.0.19 2024 年 3 月 8 日
0.0.16 2024 年 1 月 20 日
0.0.15 2023 年 7 月 3 日
0.0.8 2023 年 3 月 31 日
0.0.5 2022 年 11 月 20 日

#164Cargo 插件

Download history 2/week @ 2024-04-23 80/week @ 2024-04-30 38/week @ 2024-05-07 1/week @ 2024-05-14 22/week @ 2024-05-21 2/week @ 2024-06-11

每月 365 次下载

自定义许可证

1MB
684

cargo-feature-combinations

build status test status crates.io

cargo 编写的插件,用于对选定的功能组合运行命令。

安装

cargo install cargo-feature-combinations

用法

在大多数情况下,只需像使用 cargo 一样使用命令。然而,还有一些可选标志和 matrix 子命令。

cargo feature-combinations check

为了节省时间,您还可以使用缩短的名称 cargo fc

cargo fc test
cargo fc --fail-fast test
cargo fc build
cargo fc --silent build
cargo fc matrix

有关详细信息,请参阅 --help

$ cargo fc --help

USAGE:
    cargo [+toolchain] [SUBCOMMAND] [SUBCOMMAND_OPTIONS]
    cargo [+toolchain] [OPTIONS] [CARGO_OPTIONS] [CARGO_SUBCOMMAND]

SUBCOMMAND:
    matrix                  Print JSON feature combination matrix to stdout
        --pretty            Print pretty JSON

OPTIONS:
    --help                  Print help information
    --silent                Hide cargo output and only show summary
    --fail-fast             Fail fast on the first bad feature combination
    --errors-only           Allow all warnings, show errors only (-Awarnings)
    --pedantic              Treat warnings like errors in summary and
                            when using --fail-fast

配置

在您的 Cargo.toml 中,您可以配置功能组合矩阵

[package.metadata.cargo-feature-combinations]
# Exclude groupings of features that are incompatible or do not make sense
skip_feature_sets = [ ["foo", "bar"], ]

# Exclude features from the feature combination matrix
denylist = ["default", "full"]

与 github-actions 一起使用

github-actions 的 matrix 功能允许更有效地在 CI 中测试所有功能集组合。

以下工作流程文件使用 cargo-feature-combinations 自动生成功能矩阵,并在矩阵作业中运行多达 256 个功能组合。

# TODO: embed example

本地开发

对于本地开发和测试,您可以使用 --manifest-path 标志将 cargo fc 指向另一个项目。

cargo run -- cargo check --manifest-path ../path/to/Cargo.toml
cargo run -- cargo matrix --manifest-path ../path/to/Cargo.toml --pretty

代码质量检查

cargo clippy --tests --benches --examples -- -Dclippy::all -Dclippy::pedantic

致谢

cargo-all-features 包与此类似,但提供更复杂的配置,并且缺乏总结。

待办事项

  • 允许将自定义数据添加到矩阵输出中
  • 使用 embedme 集成帮助输出。
  • 添加 github actions 工作流程文件示例。

依赖关系

~9–20MB
~268K SLoC