forge
Explore
Log in

Don't you dare go Hollow

Release build shows podman's own error and a VM that fails to start only fails the Windows steps

Browse files at this commit

b2fc28ad9fa908049f0d4def84637c659d3462f9Ahmet Kaan GümüşParent: 5a068bf
  • fix
    • release build shows podman's own error and a VM that fails to start only fails the Windows steps
    • linux builds still run
Show full message
🐛 fix: release build shows podman's own error and a VM that fails to start only fails the Windows steps; linux builds still run
crates/client/src/release.rsmodified+26 -23
@@ -97,10 +97,11 @@ impl Cx {
97 }97 }
98 }98 }
99 99
100-#[derive(Clone, Copy)]100+enum Vm {
101-struct Vm {101+ Missing,
102- present: bool,102+ Running,
103- started: bool,103+ Started,
104+ Broken(String),
104 }105 }
105 106
106 fn run(source: &Path, cx: &Cx) {107 fn run(source: &Path, cx: &Cx) {
@@ -119,7 +120,7 @@ fn run(source: &Path, cx: &Cx) {
119 let result = if cx.cancelled() {120 let result = if cx.cancelled() {
120 Err("cancelled".to_string())121 Err("cancelled".to_string())
121 } else {122 } else {
122- run_job(job, source, &key, cx, vm)123+ run_job(job, source, &key, cx, &vm)
123 };124 };
124 if let Err(e) = result {125 if let Err(e) = result {
125 let e = if cx.cancelled() {126 let e = if cx.cancelled() {
@@ -131,7 +132,7 @@ fn run(source: &Path, cx: &Cx) {
131 break;132 break;
132 }133 }
133 }134 }
134- if vm.started {135+ if let Vm::Started = vm {
135 podman_ok(&["stop", VM]);136 podman_ok(&["stop", VM]);
136 }137 }
137 cx.send(Event::Done);138 cx.send(Event::Done);
@@ -148,24 +149,23 @@ fn preflight(source: &Path) -> Result<Vm, String> {
148 return Err("uncommitted changes".into());149 return Err("uncommitted changes".into());
149 }150 }
150 fs::create_dir_all(source.join("dist")).map_err(|e| e.to_string())?;151 fs::create_dir_all(source.join("dist")).map_err(|e| e.to_string())?;
151- let present = podman_ok(&["container", "exists", VM]);152+ if !podman_ok(&["container", "exists", VM]) {
152- let mut started = false;153+ return Ok(Vm::Missing);
153- if present {
154- let state = Command::new("podman")
155- .args(["inspect", "-f", "{{.State.Running}}", VM])
156- .output()
157- .map_err(|e| e.to_string())?;
158- if String::from_utf8_lossy(&state.stdout).trim() == "false" {
159- if !podman_ok(&["start", VM]) {
160- return Err("podman start failed".into());
161- }
162- started = true;
163- }
164 }154 }
165- Ok(Vm { present, started })155+ let state = Command::new("podman")
156+ .args(["inspect", "-f", "{{.State.Running}}", VM])
157+ .output()
158+ .map_err(|e| e.to_string())?;
159+ if String::from_utf8_lossy(&state.stdout).trim() != "false" {
160+ return Ok(Vm::Running);
161+ }
162+ Ok(match check(Command::new("podman").args(["start", VM])) {
163+ Ok(()) => Vm::Started,
164+ Err(error) => Vm::Broken(error),
165+ })
166 }166 }
167 167
168-fn run_job(job: Job, source: &Path, key: &Path, cx: &Cx, vm: Vm) -> Result<(), String> {168+fn run_job(job: Job, source: &Path, key: &Path, cx: &Cx, vm: &Vm) -> Result<(), String> {
169 match job {169 match job {
170 Job::Linux(level) => {170 Job::Linux(level) => {
171 if !cfg!(target_os = "linux") {171 if !cfg!(target_os = "linux") {
@@ -175,14 +175,17 @@ fn run_job(job: Job, source: &Path, key: &Path, cx: &Cx, vm: Vm) -> Result<(), S
175 build_linux(job, level, source, cx)175 build_linux(job, level, source, cx)
176 }176 }
177 Job::WindowsStart => {177 Job::WindowsStart => {
178- if !vm.present {178+ if let Vm::Missing = vm {
179 return skip(cx, job, "no yumush-win");179 return skip(cx, job, "no yumush-win");
180 }180 }
181 cx.send(Event::Started(job));181 cx.send(Event::Started(job));
182+ if let Vm::Broken(error) = vm {
183+ return Err(error.clone());
184+ }
182 start_windows(job, source, key, cx)185 start_windows(job, source, key, cx)
183 }186 }
184 Job::Windows(level) => {187 Job::Windows(level) => {
185- if !vm.present {188+ if let Vm::Missing = vm {
186 return skip(cx, job, "no yumush-win");189 return skip(cx, job, "no yumush-win");
187 }190 }
188 cx.send(Event::Started(job));191 cx.send(Event::Started(job));