microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
flowey/flowey_lib_hvlite/src/_jobs/all_good_job.rs
52lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | //! (GitHub Actions only) Check that all dependent jobs prior to this job |
| 5 | //! completed successfully, and in turn, succeeding / failing itself. |
| 6 | //! |
| 7 | //! Workaround for <https://github.com/orgs/community/discussions/12395>. |
| 8 | //! |
| 9 | //! Workaround itself required _another_ workaround, in order to deal with |
| 10 | //! <https://github.com/actions/runner/issues/2566>. |
| 11 | |
| 12 | use flowey::node::prelude::*; |
| 13 | |
| 14 | flowey_request! { |
| 15 | pub struct Params { |
| 16 | pub did_fail_env_var: String, |
| 17 | pub done: WriteVar<SideEffect>, |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | new_simple_flow_node!(struct Node); |
| 22 | |
| 23 | impl SimpleFlowNode for Node { |
| 24 | type Request = Params; |
| 25 | |
| 26 | fn imports(ctx: &mut ImportCtx<'_>) { |
| 27 | ctx.import::<crate::git_checkout_openvmm_repo::Node>(); |
| 28 | ctx.import::<flowey_lib_common::install_rust::Node>(); |
| 29 | } |
| 30 | |
| 31 | fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> { |
| 32 | let Params { |
| 33 | did_fail_env_var, |
| 34 | done, |
| 35 | } = request; |
| 36 | |
| 37 | ctx.emit_rust_step("Check if any jobs failed", |ctx| { |
| 38 | done.claim(ctx); |
| 39 | |_rt| { |
| 40 | let did_fail = std::env::var(did_fail_env_var)? |
| 41 | .to_lowercase() |
| 42 | .parse::<bool>()?; |
| 43 | if did_fail { |
| 44 | anyhow::bail!("Detected failures in one or more previous jobs!") |
| 45 | } |
| 46 | Ok(()) |
| 47 | } |
| 48 | }); |
| 49 | |
| 50 | Ok(()) |
| 51 | } |
| 52 | } |