Download crates/forge_config/tests/schema.rs from SaylorTwift/forgecode: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_config/tests/schema.rs
- Command line
-
hf download hf://SaylorTwift/forgecode/crates/forge_config/tests/schema.rs
-
curl -L -o schema.rs https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_config/tests/schema.rs
1.06 kB
| use std::path::Path; | |
| use forge_config::ForgeConfig; | |
| use pretty_assertions::assert_eq; | |
| async fn generate_workflow_schema() -> anyhow::Result<()> { | |
| let schema = schemars::schema_for!(ForgeConfig); | |
| let generated_schema = serde_json::to_string_pretty(&schema)?; | |
| // Use the crate root directory for the schema file | |
| let crate_root = env!("CARGO_MANIFEST_DIR"); | |
| let schema_path = Path::new(crate_root).join("../../forge.schema.json"); | |
| if is_ci::uncached() { | |
| // On CI: validate that the generated schema matches the committed file | |
| let existing_schema = tokio::fs::read_to_string(&schema_path).await?; | |
| assert_eq!( | |
| generated_schema.trim(), | |
| existing_schema.trim(), | |
| "Generated workflow schema does not match the committed schema file. \ | |
| Please run the test locally to update the schema file." | |
| ); | |
| } else { | |
| // Locally: generate and write the schema file | |
| tokio::fs::write(&schema_path, generated_schema).await?; | |
| } | |
| Ok(()) | |
| } | |