From 9c022e3013b0210de0c54b2cf89ba8459c11b66d Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Thu, 8 Apr 2021 18:55:28 +0200 Subject: Move CI to rust-cache Action --- xtask/src/flags.rs | 5 ---- xtask/src/main.rs | 2 -- xtask/src/pre_cache.rs | 79 -------------------------------------------------- 3 files changed, 86 deletions(-) delete mode 100644 xtask/src/pre_cache.rs (limited to 'xtask') diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs index 4cd2b1ddb..34e447c2f 100644 --- a/xtask/src/flags.rs +++ b/xtask/src/flags.rs @@ -28,7 +28,6 @@ xflags::xflags! { } cmd fuzz-tests {} - cmd pre-cache {} cmd release { optional --dry-run @@ -63,7 +62,6 @@ pub enum XtaskCmd { Help(Help), Install(Install), FuzzTests(FuzzTests), - PreCache(PreCache), Release(Release), Promote(Promote), Dist(Dist), @@ -91,9 +89,6 @@ pub struct Lint; #[derive(Debug)] pub struct FuzzTests; -#[derive(Debug)] -pub struct PreCache; - #[derive(Debug)] pub struct Release { pub dry_run: bool, diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 960927fc0..0dbbde275 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -18,7 +18,6 @@ mod install; mod release; mod dist; mod metrics; -mod pre_cache; use anyhow::{bail, Result}; use std::{ @@ -41,7 +40,6 @@ fn main() -> Result<()> { } flags::XtaskCmd::Install(cmd) => cmd.run(), flags::XtaskCmd::FuzzTests(_) => run_fuzzer(), - flags::XtaskCmd::PreCache(cmd) => cmd.run(), flags::XtaskCmd::Release(cmd) => cmd.run(), flags::XtaskCmd::Promote(cmd) => cmd.run(), flags::XtaskCmd::Dist(flags) => { diff --git a/xtask/src/pre_cache.rs b/xtask/src/pre_cache.rs deleted file mode 100644 index b456224fd..000000000 --- a/xtask/src/pre_cache.rs +++ /dev/null @@ -1,79 +0,0 @@ -use std::{ - fs::FileType, - path::{Path, PathBuf}, -}; - -use anyhow::Result; -use xshell::rm_rf; - -use crate::flags; - -impl flags::PreCache { - /// Cleans the `./target` dir after the build such that only - /// dependencies are cached on CI. - pub(crate) fn run(self) -> Result<()> { - let slow_tests_cookie = Path::new("./target/.slow_tests_cookie"); - if !slow_tests_cookie.exists() { - panic!("slow tests were skipped on CI!") - } - rm_rf(slow_tests_cookie)?; - - for path in read_dir("./target/debug", FileType::is_file)? { - // Can't delete yourself on windows :-( - if !path.ends_with("xtask.exe") { - rm_rf(&path)? - } - } - - rm_rf("./target/.rustc_info.json")?; - - let to_delete = read_dir("./crates", FileType::is_dir)? - .into_iter() - .map(|path| path.file_name().unwrap().to_string_lossy().replace('-', "_")) - .collect::>(); - - for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() { - for path in read_dir(dir, |_file_type| true)? { - if path.ends_with("xtask.exe") { - continue; - } - let file_name = path.file_name().unwrap().to_string_lossy(); - let (stem, _) = match rsplit_once(&file_name, '-') { - Some(it) => it, - None => { - rm_rf(path)?; - continue; - } - }; - let stem = stem.replace('-', "_"); - if to_delete.contains(&stem) { - rm_rf(path)?; - } - } - } - - Ok(()) - } -} -fn read_dir(path: impl AsRef, cond: impl Fn(&FileType) -> bool) -> Result> { - read_dir_impl(path.as_ref(), &cond) -} - -fn read_dir_impl(path: &Path, cond: &dyn Fn(&FileType) -> bool) -> Result> { - let mut res = Vec::new(); - for entry in path.read_dir()? { - let entry = entry?; - let file_type = entry.file_type()?; - if cond(&file_type) { - res.push(entry.path()) - } - } - Ok(res) -} - -fn rsplit_once(haystack: &str, delim: char) -> Option<(&str, &str)> { - let mut split = haystack.rsplitn(2, delim); - let suffix = split.next()?; - let prefix = split.next()?; - Some((prefix, suffix)) -} -- cgit v1.2.3