diff options
author | Aleksey Kladov <[email protected]> | 2020-08-18 09:38:57 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-18 10:07:21 +0100 |
commit | 6cff076513924430c8cdf422fa56dbe711faee40 (patch) | |
tree | 9d88875b060e5b941ce58c389f4dab2dfbab278f /xtask/src/lib.rs | |
parent | 80ab6c8cd53bc9bca43b8b95e80e39677cd319f8 (diff) |
Revive cache cleaning
The idea here is that, on CI, we only want to cache crates.io
dependencies, and not local crates. This keeps the size of the cache
low, and also improves performance, as network and moving files on
disk (on Windows) can be slow.
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r-- | xtask/src/lib.rs | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index f3ad81ba7..e790d995f 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -3,14 +3,15 @@ | |||
3 | //! See https://github.com/matklad/cargo-xtask/ | 3 | //! See https://github.com/matklad/cargo-xtask/ |
4 | 4 | ||
5 | pub mod not_bash; | 5 | pub mod not_bash; |
6 | pub mod codegen; | ||
7 | mod ast_src; | ||
8 | |||
6 | pub mod install; | 9 | pub mod install; |
7 | pub mod release; | 10 | pub mod release; |
8 | pub mod dist; | 11 | pub mod dist; |
9 | pub mod pre_commit; | 12 | pub mod pre_commit; |
10 | pub mod metrics; | 13 | pub mod metrics; |
11 | 14 | pub mod pre_cache; | |
12 | pub mod codegen; | ||
13 | mod ast_src; | ||
14 | 15 | ||
15 | use std::{ | 16 | use std::{ |
16 | env, | 17 | env, |
@@ -21,7 +22,7 @@ use walkdir::{DirEntry, WalkDir}; | |||
21 | 22 | ||
22 | use crate::{ | 23 | use crate::{ |
23 | codegen::Mode, | 24 | codegen::Mode, |
24 | not_bash::{fs2, pushd, pushenv, rm_rf}, | 25 | not_bash::{pushd, pushenv}, |
25 | }; | 26 | }; |
26 | 27 | ||
27 | pub use anyhow::{bail, Context as _, Result}; | 28 | pub use anyhow::{bail, Context as _, Result}; |
@@ -108,42 +109,6 @@ pub fn run_fuzzer() -> Result<()> { | |||
108 | Ok(()) | 109 | Ok(()) |
109 | } | 110 | } |
110 | 111 | ||
111 | /// Cleans the `./target` dir after the build such that only | ||
112 | /// dependencies are cached on CI. | ||
113 | pub fn run_pre_cache() -> Result<()> { | ||
114 | let slow_tests_cookie = Path::new("./target/.slow_tests_cookie"); | ||
115 | if !slow_tests_cookie.exists() { | ||
116 | panic!("slow tests were skipped on CI!") | ||
117 | } | ||
118 | rm_rf(slow_tests_cookie)?; | ||
119 | |||
120 | for entry in Path::new("./target/debug").read_dir()? { | ||
121 | let entry = entry?; | ||
122 | if entry.file_type().map(|it| it.is_file()).ok() == Some(true) { | ||
123 | // Can't delete yourself on windows :-( | ||
124 | if !entry.path().ends_with("xtask.exe") { | ||
125 | rm_rf(&entry.path())? | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | fs2::remove_file("./target/.rustc_info.json")?; | ||
131 | let to_delete = ["hir", "heavy_test", "xtask", "ide", "rust-analyzer"]; | ||
132 | for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() { | ||
133 | for entry in Path::new(dir).read_dir()? { | ||
134 | let entry = entry?; | ||
135 | if to_delete.iter().any(|&it| entry.path().display().to_string().contains(it)) { | ||
136 | // Can't delete yourself on windows :-( | ||
137 | if !entry.path().ends_with("xtask.exe") { | ||
138 | rm_rf(&entry.path())? | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | Ok(()) | ||
145 | } | ||
146 | |||
147 | fn is_release_tag(tag: &str) -> bool { | 112 | fn is_release_tag(tag: &str) -> bool { |
148 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) | 113 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) |
149 | } | 114 | } |