Skip to main content

flowey_hvlite/pipelines/
burn_in.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! See [`BurnInCli`]
5
6use crate::pipelines_shared::gh_pools;
7use flowey::node::prelude::GhPermission;
8use flowey::node::prelude::GhPermissionValue;
9use flowey::pipeline::prelude::*;
10use flowey_lib_common::git_checkout::RepoSource;
11use flowey_lib_hvlite::_jobs::download_and_run_nextest_vmm_tests::VmmTestsProfile;
12
13/// A pipeline for repeated running VMM tests to determine the frequency of
14/// failures
15#[derive(clap::Args)]
16pub struct BurnInCli {}
17
18impl IntoPipeline for BurnInCli {
19    fn into_pipeline(self, backend_hint: PipelineBackendHint) -> anyhow::Result<Pipeline> {
20        let mut pipeline = Pipeline::new();
21
22        let openvmm_repo_source = match backend_hint {
23            PipelineBackendHint::Local => anyhow::bail!("local backend unsupported"),
24            PipelineBackendHint::Github => RepoSource::GithubSelf,
25            PipelineBackendHint::Ado => anyhow::bail!("ado backend unsupported"),
26        };
27
28        if let RepoSource::GithubSelf = &openvmm_repo_source {
29            pipeline.gh_set_flowey_bootstrap_template(
30                crate::pipelines_shared::gh_flowey_bootstrap_template::get_template(),
31            );
32        }
33
34        let cfg_common_params = crate::pipelines_shared::cfg_common_params::get_cfg_common_params(
35            &mut pipeline,
36            backend_hint,
37            None,
38        )?;
39
40        pipeline
41            .gh_set_name("OpenVMM Burn In")
42            .gh_add_schedule_trigger(GhScheduleTriggers {
43                cron: "0 19 * * 1-5".into(),
44                timezone: Some("America/Los_Angeles".into()),
45            });
46
47        pipeline.inject_all_jobs_with(move |job| {
48            job.dep_on(&cfg_common_params)
49                .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request::Init)
50                .dep_on(
51                    |_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params {
52                        hvlite_repo_source: openvmm_repo_source.clone(),
53                    },
54                )
55                .gh_grant_permissions::<flowey_lib_common::git_checkout::Node>([(
56                    GhPermission::Contents,
57                    GhPermissionValue::Read,
58                )])
59                .gh_grant_permissions::<flowey_lib_common::gh_task_azure_login::Node>([(
60                    GhPermission::IdToken,
61                    GhPermissionValue::Write,
62                )])
63                // 15 hour timeout. Should take approximately 8.5 hours.
64                .with_timeout_in_minutes(900)
65        });
66
67        struct VmmTestJobParams<'a> {
68            platform: FlowPlatform,
69            arch: FlowArch,
70            gh_pool: GhRunner,
71            label: &'a str,
72            profile: VmmTestsProfile,
73        }
74
75        // in the future we will add more burn in tests
76        #[expect(clippy::single_element_loop)]
77        for VmmTestJobParams {
78            platform,
79            arch,
80            gh_pool,
81            label,
82            profile,
83        } in [VmmTestJobParams {
84            platform: FlowPlatform::Windows,
85            arch: FlowArch::X86_64,
86            gh_pool: gh_pools::windows_snp_self_hosted_baremetal(),
87            label: "x64-windows-all-snp",
88            profile: VmmTestsProfile::X64WindowsAll,
89        }] {
90            pipeline
91                .new_job(platform, arch, format!("run vmm-tests [{label}]"))
92                .gh_set_pool(gh_pool)
93                .dep_on(|ctx| {
94                    flowey_lib_hvlite::_jobs::download_and_run_nextest_vmm_tests::Params {
95                        label: label.into(),
96                        profile,
97                        repetitions: std::num::NonZeroU64::new(25).unwrap(),
98                        done: ctx.new_done_handle(),
99                    }
100                })
101                .finish();
102        }
103
104        Ok(pipeline)
105    }
106}