One Build per machine (flock on ~/.cache/yumush-build/build.lock): two builders shared dist/source.tgz, the cargo target cache and the containers, so a second Build could swap the commit under a running Windows lane
Browse files at this commit117c2aa1694cd4391b673340863b6b952d29dfdfParent: 4e8177a- fix
- one Build per machine (flock on ~/.cache/yumush-build/build.lock): two builders shared dist/source.tgz, the cargo target cache and the containers, so a second Build could swap the commit under a running Windows lane
1 changed file +17 -0
- crates/client/src/release.rs +17 -0
crates/client/src/release.rsmodified+17 -0
| @@ -185,6 +185,14 @@ impl Cx { | |||
| 185 | fn run(source: &Path, lanes: &[Cx]) { | 185 | fn run(source: &Path, lanes: &[Cx]) { |
| 186 | let key = vm_dir().join("id_ed25519"); | 186 | let key = vm_dir().join("id_ed25519"); |
| 187 | let first = &lanes[0]; | 187 | let first = &lanes[0]; |
| 188 | + let _lock = match lock() { | ||
| 189 | + Ok(lock) => lock, | ||
| 190 | + Err(e) => { | ||
| 191 | + first.send(Event::Failed(LANES[0].1[0], e)); | ||
| 192 | + first.send(Event::Done); | ||
| 193 | + return; | ||
| 194 | + } | ||
| 195 | + }; | ||
| 188 | let vm_was_running = match preflight(source) { | 196 | let vm_was_running = match preflight(source) { |
| 189 | Ok(running) => running, | 197 | Ok(running) => running, |
| 190 | Err(e) => { | 198 | Err(e) => { |
| @@ -229,6 +237,15 @@ fn run_lane(jobs: &[Job], source: &Path, key: &Path, cx: &Cx) { | |||
| 229 | } | 237 | } |
| 230 | } | 238 | } |
| 231 | 239 | ||
| 240 | +fn lock() -> Result<fs::File, String> { | ||
| 241 | + let cache = linux_cache(); | ||
| 242 | + fs::create_dir_all(&cache).map_err(|e| e.to_string())?; | ||
| 243 | + let file = fs::File::create(cache.join("build.lock")).map_err(|e| e.to_string())?; | ||
| 244 | + file.try_lock() | ||
| 245 | + .map_err(|_| "another build is running".to_string())?; | ||
| 246 | + Ok(file) | ||
| 247 | +} | ||
| 248 | + | ||
| 232 | fn preflight(source: &Path) -> Result<bool, String> { | 249 | fn preflight(source: &Path) -> Result<bool, String> { |
| 233 | let dirty = Command::new("git") | 250 | let dirty = Command::new("git") |
| 234 | .arg("-C") | 251 | .arg("-C") |