Crate cicero

Crate cicero 

Source
Expand description

§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

§Path Handling

Access paths in your repository with compile-time checks.

use cicero::path::repo_path;

let readme = repo_path!("README.md");
let doc_src = repo_path!("doc/src/");

For more information, see Cicero Path.

§Bundling a distribution (feature: distribution)

Create a distribution archive with a predictable file structure.

use std::{fs, path::Path};
use cicero_distribution::Distribution;
use cicero_path::repo_path;

fn main() -> anyhow::Result<()> {
    let distribution = Distribution::new("myproject")?;

    distribution
        .add_file_from_path("README.md", repo_path!("README.md"))?
        .add_file("myproject", |file| build_backend_executable(file))?;

    distribution
        .dir("public")?
        .add_all(|dir| build_frontend(dir))?;

    let distribution_dir = distribution.bundle_as_dir()?;
    Ok(())
}

fn build_frontend(out_dir: &Path) -> anyhow::Result<()> {
    todo!()
}
fn build_backend_executable(out_file: &Path) -> anyhow::Result<()> {
    todo!()
}

For more information, see Cicero Distribution.

§Build caching (feature: cache)

Rebuild files only when needed.

use std::{fs, path::PathBuf};
use cicero::cache;

let output_path = PathBuf::from("my/build/result.txt");

cache::Output::from(output_path.clone()).rebuild_on_change([
    PathBuf::from("my/build/input.csv"),
], || {
    fs::create_dir_all(output_path.parent().unwrap())?;
    fs::File::create(output_path)?;
    Ok(())
});

For more information, see Cicero Cache.

§CLI Management (feature: commands)

Automatically install CLIs when needed, independent from the CLIs in your other projects.

use cicero::commands::*;

pub static CROSS: Cli = Crate::new("cross").into_cli();

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

For more information, see Cicero Commands.

§Tracing (feature: tracing, default-enabled)

Call cicero::init::tracing().init() at the start of your main-function to setup logging output.

You can then use the tracing crate to write out messages.
In particular with more complex workflows, using #[tracing::instrument] on significant functions
is helpful to discern where the logging output belongs to.

§Changelog

You can find the changelog here: https://codeberg.org/trem/cicero/src/branch/main/CHANGELOG.md

Re-exports§

pub use cicero_cache as cache;
pub use cicero_commands as commands;
pub use cicero_distribution as distribution;
pub use cicero_path as path;

Modules§

command_exit_ok
init
task
Common Cicero tasks.

Type Aliases§

Result
Result type which can be used in CI code. Result<T, Error>