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