Crates.io | shrub-rs |
lib.rs | shrub-rs |
version | 0.5.4 |
source | src |
created_at | 2021-04-13 00:18:08.190702 |
updated_at | 2024-11-18 14:14:53.791998 |
description | Library for working with Evergreen Project configurations. |
homepage | |
repository | |
max_upload_size | |
id | 382628 |
size | 65,634 |
A rust package for defining and interpreting Evergreen project configuration.
Provide structs to model evergreen project configuration files.
If you have a question about shrub-rs, please mention @dag-on-call in slack channel #evergreen-users, or email us at dev-prod-dag@mongodb.com.
Create a DAG ticket in Jira.
Please include as much information as possible. This can help avoid long information-gathering threads.
Please include the following:
To install, include "shrub-rs" in your projects Cargo.toml dependencies.
Shrub provides two-way translation of evergreen project configurations. Meaning you can convert evergreen project configurations into rust structs or convert rust structs into evergreen project configuration.
Converting evergreen project configuration into rust structs can make it much easier to analyze the configuration of an evergreen project.
Note: You will likely want to run a project configuration through evergreen evaluate
before
interpreting it in order to perform some preprocessing that evergreen does.
A simple example:
use std::path::Path;
use std::process::Command;
use shrub_rs::models::project::EvgProject;
fn get_project_config(location: &Path) -> EvgProject {
let evg_config_yaml = Command::new("evergreen")
.args(&["evaluate", location.to_str().unwrap()])
.output()
.unwrap();
EvgProject::from_yaml_str(std::str::from_utf8(&evg_config_yaml.stdout).unwrap()).unwrap()
}
let evg_project = get_project_config(Path::from("path/to/config.yml));
println!("My project has {} build variants", evg_project.build_variants.len());
Build up evergreen configuration and then exporting it can be very useful when performing dynamic
task generation via evergreen's generate.tasks
.
A simple example:
use std::path::Path;
use shrub_rs::models::{project::EvgProject, task::{EvgTask}};
let evg_task = EvgTask {
name: "My new task".to_string(),
..Default::default()
};
let evg_project = EvgProject {
tasks: vec![evg_task],
..Default::default()
};
std::fs::write(Path::from("path/to/target"), serde_json::to_string_pretty(&evg_project).unwrap()).unwrap();
For a more complex example of how shrub can be used see the mongo-task-generator.
Shrub-rs provides rust structs to model evergreen project configuration. To understand the structures provided, review the evergreen project configuration documentation
After cloning the repository, simply run cargo build
to download and build the project.
cargo fmt
cargo clippy
cargo test
This project uses semver for versioning.
Please include a description what is added for each new version in CHANGELOG.md
.
Code reviews are required on all changes and are done via Github Pull Requests.
Deployment to production is automatically triggered on merges to master.