flowey_lib_hvlite/_jobs/
build_test_results_website.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Build the test-results website using npm.
5
6use flowey::node::prelude::*;
7
8flowey_request! {
9    pub struct Request {
10        pub path: WriteVar<PathBuf>,
11    }
12}
13
14new_simple_flow_node!(struct Node);
15
16impl SimpleFlowNode for Node {
17    type Request = Request;
18
19    fn imports(ctx: &mut ImportCtx<'_>) {
20        ctx.import::<crate::git_checkout_openvmm_repo::Node>();
21        ctx.import::<flowey_lib_common::install_nodejs::Node>();
22    }
23
24    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
25        let Request { path } = request;
26
27        // Make sure that npm is installed
28        let npm_installed = ctx.reqv(flowey_lib_common::install_nodejs::Request::EnsureInstalled);
29        let openvmm_repo_path = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);
30
31        ctx.emit_rust_step("build test-results website", |ctx| {
32            npm_installed.claim(ctx);
33            let path = path.claim(ctx);
34            let openvmm_repo_path = openvmm_repo_path.claim(ctx);
35
36            move |rt| {
37                let mut dist_path = rt.read(openvmm_repo_path);
38
39                // Navigate to the petri/logview_new directory within the
40                // OpenVMM repo
41                dist_path.push("petri");
42                dist_path.push("logview_new");
43
44                rt.sh.change_dir(&dist_path);
45
46                // Because the project is using vite, the output will go
47                // directly to the 'dist-ci' folder
48                flowey::shell_cmd!(rt, "npm install").run()?;
49                flowey::shell_cmd!(rt, "npm run build:ci").run()?;
50
51                dist_path.push("dist-ci");
52                if !dist_path.exists() {
53                    anyhow::bail!(
54                        "logview_new build failed. Expected 'dist-ci' directory at {:?} but it was not found.",
55                        dist_path
56                    );
57                }
58
59                rt.write(path, &dist_path);
60
61                Ok(())
62            }
63        });
64
65        Ok(())
66    }
67}