mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-11 02:18:20 +00:00
Add initial version of validator
This initial version just exports each model, failing if there's an error. Eventually, it should also validate the exported 3MF file. But the current version is already useful, and can replace the manually specified model export steps in the CI build.
This commit is contained in:
parent
b8e7c8bb10
commit
ab4d83bf34
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -2789,6 +2789,13 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "validator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
|
@ -17,6 +17,7 @@ members = [
|
||||
"models/star",
|
||||
|
||||
"tools/release-operator",
|
||||
"tools/validator",
|
||||
]
|
||||
default-members = [
|
||||
"crates/fj-app",
|
||||
|
7
tools/validator/Cargo.toml
Normal file
7
tools/validator/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "validator"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.56"
|
27
tools/validator/src/main.rs
Normal file
27
tools/validator/src/main.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use std::{fs, process::Command};
|
||||
|
||||
use anyhow::{anyhow, bail};
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
for model in fs::read_dir("models")? {
|
||||
let model = model?;
|
||||
let model = model.file_name().into_string().map_err(|err| {
|
||||
anyhow!("Failed to convert directory name to `String`: {:?}", err)
|
||||
})?;
|
||||
|
||||
let export_file = format!("{model}.3mf");
|
||||
|
||||
let exit_status = Command::new("cargo")
|
||||
.arg("run")
|
||||
.arg("--")
|
||||
.args(["--model", &model])
|
||||
.args(["--export", &export_file])
|
||||
.status()?;
|
||||
|
||||
if !exit_status.success() {
|
||||
bail!("Exporting model failed with error status: {}", exit_status);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user