Step file unfuck ci (#5891)
* remove the files Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove step shit from kcl-samples Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -29,7 +29,6 @@ struct Test {
|
||||
}
|
||||
|
||||
pub(crate) const RENDERED_MODEL_NAME: &str = "rendered_model.png";
|
||||
pub(crate) const EXPORTED_STEP_NAME: &str = "exported_step.step";
|
||||
|
||||
impl Test {
|
||||
fn new(name: &str) -> Self {
|
||||
@ -170,11 +169,15 @@ async fn execute_test(test: &Test, render_to_png: bool, export_step: bool) {
|
||||
if render_to_png {
|
||||
twenty_twenty::assert_image(test.output_dir.join(RENDERED_MODEL_NAME), &png, 0.99);
|
||||
}
|
||||
if export_step && std::env::var("EXPECTORATE").is_ok() {
|
||||
let step = step.unwrap();
|
||||
// We do not use expectorate here because the output is non-deterministic
|
||||
// due to SSI and GPU.
|
||||
std::fs::write(test.output_dir.join(EXPORTED_STEP_NAME), step).unwrap();
|
||||
|
||||
// Ensure the step has data.
|
||||
if export_step {
|
||||
let Some(step_contents) = step else {
|
||||
panic!("Step data was not generated");
|
||||
};
|
||||
if step_contents.is_empty() {
|
||||
panic!("Step data was empty");
|
||||
}
|
||||
}
|
||||
let outcome = exec_state.to_wasm_outcome(env_ref).await;
|
||||
|
||||
|
@ -59,12 +59,11 @@ fn test_after_engine_ensure_kcl_samples_manifest_etc() {
|
||||
.collect::<Vec<_>>();
|
||||
assert!(missing.is_empty(), "Expected input kcl-samples for the following. If these are no longer tests, delete the expected output directories for them in {}: {missing:?}", OUTPUTS_DIR.to_string_lossy());
|
||||
|
||||
// We want to move the step and screenshot for the inputs to the public/kcl-samples
|
||||
// We want to move the screenshot for the inputs to the public/kcl-samples
|
||||
// directory so that they can be used as inputs for the next run.
|
||||
// First ensure each directory exists.
|
||||
let public_screenshot_dir = INPUTS_DIR.join("screenshots");
|
||||
let public_step_dir = INPUTS_DIR.join("step");
|
||||
for dir in [&public_step_dir, &public_screenshot_dir] {
|
||||
for dir in [&public_screenshot_dir] {
|
||||
if !dir.exists() {
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
}
|
||||
@ -79,23 +78,17 @@ fn test_after_engine_ensure_kcl_samples_manifest_etc() {
|
||||
public_screenshot_dir.join(format!("{}.png", &tests.name)),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let step_file = OUTPUTS_DIR.join(&tests.name).join(super::EXPORTED_STEP_NAME);
|
||||
if !step_file.exists() {
|
||||
panic!("Missing step for test: {}", tests.name);
|
||||
}
|
||||
std::fs::copy(step_file, public_step_dir.join(format!("{}.step", &tests.name))).unwrap();
|
||||
}
|
||||
|
||||
// Update the README.md with the new screenshots and steps.
|
||||
// Update the README.md with the new screenshots.
|
||||
let mut new_content = String::new();
|
||||
for test in tests {
|
||||
// Format:
|
||||
new_content.push_str(&format!(
|
||||
r#"#### [{}]({}/main.kcl) ([step](step/{}.step)) ([screenshot](screenshots/{}.png))
|
||||
r#"#### [{}]({}/main.kcl) ([screenshot](screenshots/{}.png))
|
||||
[]({}/main.kcl)
|
||||
"#,
|
||||
test.name, test.name, test.name, test.name, test.name, test.name, test.name
|
||||
test.name, test.name, test.name, test.name, test.name, test.name,
|
||||
));
|
||||
}
|
||||
update_readme(&INPUTS_DIR, &new_content).unwrap();
|
||||
@ -144,7 +137,7 @@ fn kcl_samples_inputs() -> Vec<Test> {
|
||||
// Skip hidden directories.
|
||||
continue;
|
||||
}
|
||||
if matches!(dir_name_str.as_ref(), "step" | "screenshots") {
|
||||
if matches!(dir_name_str.as_ref(), "screenshots") {
|
||||
// Skip output directories.
|
||||
continue;
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ pub(crate) async fn walk_dir(dir: &std::path::PathBuf) -> Result<Vec<std::path::
|
||||
|
||||
/// Recast all the kcl files in a directory, recursively.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub async fn recast_dir(dir: &std::path::Path, options: &crate::FormatOptions) -> Result<(), crate::KclError> {
|
||||
pub async fn recast_dir(dir: &std::path::Path, options: &crate::FormatOptions) -> Result<(), anyhow::Error> {
|
||||
let files = walk_dir(&dir.to_path_buf()).await.map_err(|err| {
|
||||
crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to walk directory `{}`: {:?}", dir.display(), err),
|
||||
@ -882,33 +882,38 @@ pub async fn recast_dir(dir: &std::path::Path, options: &crate::FormatOptions) -
|
||||
.map(|file| {
|
||||
let options = options.clone();
|
||||
tokio::spawn(async move {
|
||||
let contents = tokio::fs::read_to_string(&file).await.map_err(|err| {
|
||||
crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to read file `{}`: {:?}", file.display(), err),
|
||||
source_ranges: vec![crate::SourceRange::default()],
|
||||
})
|
||||
let contents = tokio::fs::read_to_string(&file)
|
||||
.await
|
||||
.map_err(|err| anyhow::anyhow!("Failed to read file `{}`: {:?}", file.display(), err))?;
|
||||
let (program, ces) = crate::Program::parse(&contents).map_err(|err| {
|
||||
let report = crate::Report {
|
||||
kcl_source: contents.to_string(),
|
||||
error: err.clone(),
|
||||
filename: file.to_string_lossy().to_string(),
|
||||
};
|
||||
let report = miette::Report::new(report);
|
||||
anyhow::anyhow!("{:?}", report)
|
||||
})?;
|
||||
let (program, ces) = crate::Program::parse(&contents)?;
|
||||
for ce in &ces {
|
||||
if ce.severity != crate::errors::Severity::Warning {
|
||||
return Err(crate::KclError::Semantic(ce.clone().into()));
|
||||
let report = crate::Report {
|
||||
kcl_source: contents.to_string(),
|
||||
error: crate::KclError::Semantic(ce.clone().into()),
|
||||
filename: file.to_string_lossy().to_string(),
|
||||
};
|
||||
let report = miette::Report::new(report);
|
||||
anyhow::bail!("{:?}", report);
|
||||
}
|
||||
}
|
||||
let Some(program) = program else {
|
||||
return Err(crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to parse file `{}`: {:?}", file.display(), ces),
|
||||
source_ranges: vec![crate::SourceRange::default()],
|
||||
}));
|
||||
anyhow::bail!("Failed to parse file `{}`", file.display());
|
||||
};
|
||||
let recast = program.recast_with_options(&options);
|
||||
tokio::fs::write(&file, recast).await.map_err(|err| {
|
||||
crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to write file `{}`: {:?}", file.display(), err),
|
||||
source_ranges: vec![crate::SourceRange::default()],
|
||||
})
|
||||
})?;
|
||||
tokio::fs::write(&file, recast)
|
||||
.await
|
||||
.map_err(|err| anyhow::anyhow!("Failed to write file `{}`: {:?}", file.display(), err))?;
|
||||
|
||||
Ok::<(), crate::KclError>(())
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@ -919,21 +924,13 @@ pub async fn recast_dir(dir: &std::path::Path, options: &crate::FormatOptions) -
|
||||
// Check if any of the futures failed.
|
||||
let mut errors = Vec::new();
|
||||
for result in results {
|
||||
if let Err(err) = result.map_err(|err| {
|
||||
crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to recast file: {:?}", err),
|
||||
source_ranges: vec![crate::SourceRange::default()],
|
||||
})
|
||||
})? {
|
||||
if let Err(err) = result? {
|
||||
errors.push(err);
|
||||
}
|
||||
}
|
||||
|
||||
if !errors.is_empty() {
|
||||
return Err(crate::KclError::Internal(crate::errors::KclErrorDetails {
|
||||
message: format!("Failed to recast files: {:?}", errors),
|
||||
source_ranges: vec![crate::SourceRange::default()],
|
||||
}));
|
||||
anyhow::bail!("Failed to recast some files: {:?}", errors);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user