mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-26 20:00:32 +00:00
Reduce disk space used when running xtask ci
(#3969)
This commit is contained in:
parent
bc13bf40f3
commit
61bc88c8fb
@ -15,7 +15,7 @@ use crate::{Package, windows_safe_path};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum CargoAction {
|
||||
Build(PathBuf),
|
||||
Build(Option<PathBuf>),
|
||||
Run,
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ pub fn build_examples(
|
||||
args: ExamplesArgs,
|
||||
examples: Vec<Metadata>,
|
||||
package_path: &Path,
|
||||
out_path: &Path,
|
||||
out_path: Option<&Path>,
|
||||
) -> Result<()> {
|
||||
let chip = args.chip.unwrap();
|
||||
|
||||
@ -160,7 +160,7 @@ pub fn build_examples(
|
||||
chip,
|
||||
&target,
|
||||
example,
|
||||
CargoAction::Build(out_path.to_path_buf()),
|
||||
CargoAction::Build(out_path.map(|p| p.to_path_buf())),
|
||||
1,
|
||||
args.debug,
|
||||
args.toolchain.as_deref(),
|
||||
@ -177,7 +177,7 @@ pub fn build_examples(
|
||||
chip,
|
||||
&target,
|
||||
example,
|
||||
CargoAction::Build(out_path.to_path_buf()),
|
||||
CargoAction::Build(out_path.map(|p| p.to_path_buf())),
|
||||
1,
|
||||
args.debug,
|
||||
args.toolchain.as_deref(),
|
||||
|
@ -129,7 +129,7 @@ pub fn examples(workspace: &Path, mut args: ExamplesArgs, action: CargoAction) -
|
||||
|
||||
// Execute the specified action:
|
||||
match action {
|
||||
CargoAction::Build(out_path) => build_examples(args, examples, &package_path, &out_path),
|
||||
CargoAction::Build(out_path) => build_examples(args, examples, &package_path, out_path.as_ref().map(|p| p.as_path())),
|
||||
CargoAction::Run => run_examples(args, examples, &package_path),
|
||||
}
|
||||
}
|
||||
|
@ -452,23 +452,25 @@ pub fn execute_app(
|
||||
};
|
||||
|
||||
if let CargoAction::Build(out_dir) = action {
|
||||
cargo::run_with_env(&args, &cwd, env_vars, false)?;
|
||||
if let Some(out_dir) = out_dir {
|
||||
cargo::run_with_env(&args, &cwd, env_vars, false)?;
|
||||
|
||||
// Now that the build has succeeded and we printed the output, we can
|
||||
// rerun the build again quickly enough to capture JSON. We'll use this to
|
||||
// copy the binary to the output directory.
|
||||
builder.add_arg("--message-format=json");
|
||||
let args = builder.build();
|
||||
// Now that the build has succeeded and we printed the output, we can
|
||||
// rerun the build again quickly enough to capture JSON. We'll use this to
|
||||
// copy the binary to the output directory.
|
||||
builder.add_arg("--message-format=json");
|
||||
let args = builder.build();
|
||||
|
||||
let output = cargo::run_with_env(&args, &cwd, env_vars, true)?;
|
||||
for line in output.lines() {
|
||||
if let Ok(artifact) = serde_json::from_str::<cargo::Artifact>(line) {
|
||||
let out_dir = out_dir.join(chip.to_string());
|
||||
std::fs::create_dir_all(&out_dir)?;
|
||||
let output = cargo::run_with_env(&args, &cwd, env_vars, true)?;
|
||||
for line in output.lines() {
|
||||
if let Ok(artifact) = serde_json::from_str::<cargo::Artifact>(line) {
|
||||
let out_dir = out_dir.join(chip.to_string());
|
||||
std::fs::create_dir_all(&out_dir)?;
|
||||
|
||||
let output_file = out_dir.join(app.output_file_name());
|
||||
std::fs::copy(artifact.executable, &output_file)?;
|
||||
log::info!("Output ready: {}", output_file.display());
|
||||
let output_file = out_dir.join(app.output_file_name());
|
||||
std::fs::copy(artifact.executable, &output_file)?;
|
||||
log::info!("Output ready: {}", output_file.display());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -130,13 +130,13 @@ fn main() -> Result<()> {
|
||||
Build::Examples(args) => examples(
|
||||
&workspace,
|
||||
args,
|
||||
CargoAction::Build(target_path.join("examples")),
|
||||
CargoAction::Build(Some(target_path.join("examples"))),
|
||||
),
|
||||
Build::Package(args) => build_package(&workspace, args),
|
||||
Build::Tests(args) => tests(
|
||||
&workspace,
|
||||
args,
|
||||
CargoAction::Build(target_path.join("tests")),
|
||||
CargoAction::Build(Some(target_path.join("tests"))),
|
||||
),
|
||||
},
|
||||
|
||||
@ -382,10 +382,10 @@ fn run_ci_checks(workspace: &Path, args: CiArgs) -> Result<()> {
|
||||
toolchain: args.toolchain.clone(),
|
||||
timings: false,
|
||||
},
|
||||
CargoAction::Build(PathBuf::from(format!(
|
||||
CargoAction::Build(Some(PathBuf::from(format!(
|
||||
"./esp-lp-hal/target/{}/release/examples",
|
||||
args.chip.target()
|
||||
))),
|
||||
)))),
|
||||
)
|
||||
.inspect_err(|_| failed.push("Build LP-HAL Examples"))
|
||||
.and_then(|_| {
|
||||
@ -407,6 +407,13 @@ fn run_ci_checks(workspace: &Path, args: CiArgs) -> Result<()> {
|
||||
Ok(())
|
||||
})
|
||||
.ok();
|
||||
|
||||
// remove the (now) obsolete duplicates
|
||||
std::fs::remove_dir_all(PathBuf::from(format!(
|
||||
"./esp-lp-hal/target/{}/release/examples/{}",
|
||||
args.chip.target(),
|
||||
args.chip
|
||||
)))?;
|
||||
println!("::endgroup");
|
||||
|
||||
// Check documentation
|
||||
@ -458,7 +465,7 @@ fn run_ci_checks(workspace: &Path, args: CiArgs) -> Result<()> {
|
||||
toolchain: args.toolchain.clone(),
|
||||
timings: false,
|
||||
},
|
||||
CargoAction::Build(PathBuf::from("./examples/target/")),
|
||||
CargoAction::Build(None),
|
||||
)
|
||||
.inspect_err(|_| failed.push("Build examples"))
|
||||
.ok();
|
||||
@ -476,7 +483,7 @@ fn run_ci_checks(workspace: &Path, args: CiArgs) -> Result<()> {
|
||||
toolchain: args.toolchain.clone(),
|
||||
timings: false,
|
||||
},
|
||||
CargoAction::Build(PathBuf::from("./qa-test/target/")),
|
||||
CargoAction::Build(None),
|
||||
)
|
||||
.inspect_err(|_| failed.push("Build qa-test"))
|
||||
.ok();
|
||||
|
Loading…
x
Reference in New Issue
Block a user