mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
start with a clean ci/builds always
This commit is contained in:
parent
7ce4391e4e
commit
7f45254e39
2 changed files with 24 additions and 6 deletions
|
@ -1,7 +1,22 @@
|
|||
use std::path::PathBuf;
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::{command::BuildMode, TestRunError};
|
||||
|
||||
const HEX_BUILD_ROOT: &str = "ci/builds";
|
||||
|
||||
/// make sure we're starting with a clean,but existing slate
|
||||
pub fn init_build_dir() -> anyhow::Result<()> {
|
||||
if Path::new(HEX_BUILD_ROOT).exists() {
|
||||
fs::remove_dir_all(HEX_BUILD_ROOT)
|
||||
.map_err(|_| anyhow::anyhow!("Could not clear out directory: {}", HEX_BUILD_ROOT))?;
|
||||
}
|
||||
fs::create_dir_all(HEX_BUILD_ROOT)
|
||||
.map_err(|_| anyhow::anyhow!("Could not create directory: {}", HEX_BUILD_ROOT))
|
||||
}
|
||||
|
||||
pub fn build_hexpath(
|
||||
example: &str,
|
||||
features: Option<&str>,
|
||||
|
@ -14,10 +29,11 @@ pub fn build_hexpath(
|
|||
};
|
||||
|
||||
let filename = format!("{}_{}_{}_{}.hex", example, features, build_mode, build_num);
|
||||
["ci", "builds", &filename]
|
||||
.iter()
|
||||
.collect::<PathBuf>()
|
||||
.into_os_string()
|
||||
|
||||
let mut path = PathBuf::from(HEX_BUILD_ROOT);
|
||||
path.push(filename);
|
||||
|
||||
path.into_os_string()
|
||||
.into_string()
|
||||
.map_err(|e| anyhow::Error::new(TestRunError::PathConversionError(e)))
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::{
|
|||
use structopt::StructOpt;
|
||||
|
||||
use crate::{
|
||||
build::{build_hexpath, compare_builds},
|
||||
build::{build_hexpath, compare_builds, init_build_dir},
|
||||
command::{run_command, run_successful, BuildMode, CargoCommand},
|
||||
};
|
||||
|
||||
|
@ -98,6 +98,8 @@ fn main() -> anyhow::Result<()> {
|
|||
let opts = Options::from_args();
|
||||
let target = &opts.target;
|
||||
|
||||
init_build_dir()?;
|
||||
|
||||
if target == "all" {
|
||||
for t in targets {
|
||||
run_test(t, examples)?;
|
||||
|
|
Loading…
Reference in a new issue