flowey_lib_hvlite/_jobs/
check_xtask_fmt.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Invoke `xtask fmt`
5
6use crate::run_cargo_build::common::CommonTriple;
7use flowey::node::prelude::*;
8
9flowey_request! {
10    pub struct Request {
11        pub target: CommonTriple,
12        pub done: WriteVar<SideEffect>,
13    }
14}
15
16new_simple_flow_node!(struct Node);
17
18impl SimpleFlowNode for Node {
19    type Request = Request;
20
21    fn imports(ctx: &mut ImportCtx<'_>) {
22        ctx.import::<crate::build_xtask::Node>();
23        ctx.import::<crate::git_checkout_openvmm_repo::Node>();
24    }
25
26    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
27        let Request { target, done } = request;
28
29        let openvmm_repo_path = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);
30
31        let xtask = ctx.reqv(|v| crate::build_xtask::Request { target, xtask: v });
32
33        ctx.emit_rust_step("run xtask fmt", |ctx| {
34            done.claim(ctx);
35            let xtask = xtask.claim(ctx);
36            let openvmm_repo_path = openvmm_repo_path.claim(ctx);
37            |rt| {
38                let xtask = match rt.read(xtask) {
39                    crate::build_xtask::XtaskOutput::LinuxBin { bin, .. } => bin,
40                    crate::build_xtask::XtaskOutput::WindowsBin { exe, .. } => exe,
41                };
42
43                let sh = xshell::Shell::new()?;
44                sh.change_dir(rt.read(openvmm_repo_path));
45                xshell::cmd!(sh, "{xtask} fmt --no-parallel")
46                    // CI runs with trace logging, but that results in a lot of
47                    // spam when running the xtask flowey check
48                    .env("FLOWEY_LOG", "info")
49                    .run()?;
50
51                Ok(())
52            }
53        });
54
55        Ok(())
56    }
57}