1 unstable release

0.1.0 Sep 7, 2024

#313 in Build Utils

Apache-2.0

29KB
562 lines

Cicero

Toolbox to help automate Rust CI builds with plain Rust.

Current goal is to provide helper functions, which are useful independent of how you structure your CI code. But you likely still want to structure your CI code according to the cargo-xtask pattern.

Features

CLI Management (commands)

CI code frequently relies on external CLI tools.
Cicero aids in centrally tracking these, installing them and setting default arguments.

You specify in code which CLI tools you use. Here's some examples:

pub static CLIPPY: Cli = Cli::expect_installed("cargo-clippy");

pub static CARGO_AUDIT: Cli = Cli::install_crate("cargo-audit");

pub static CROSS: Cli = Cli::install_crate("cross")
    .with_default_command(&|command|
        command.arg("build").arg("--release")
    );

pub static TRUNK: Cli = Cli::install_crate_with_args("trunk", &["--locked"]);

Then use the .command() method to get a std::process::Command object:

CROSS.command()
    .arg("--target=aarch64-unknown-linux-gnu")
    .status()?;

When a crate needs to be installed, Cicero will ask you to specify the version in the workspace Cargo.toml:

[workspace.metadata.cicero.commands.dependencies]
cross = "0.2.5"
diesel_cli = "2.2.4"
trunk = "0.20.3"

Details on Crate Installation

  • Cicero doesn't install crates globally on your system, but rather into your project's target/ folder.
    This allows you to have different versions of CLI crates between projects.

  • Cicero only installs CLI crates when you actually use them.
    For example, you might only use cross in a CI/CD runner, then you don't need it on your development machine.

  • Some crates use a different executable name than their crate name,
    for example the crate diesel_cli installs an executable called diesel. Cicero will automatically use this executable name.

Dependencies

~5–14MB
~202K SLoC