microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
flowey/flowey_hvlite/src/pipelines/restore_packages.rs
70lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use crate::pipelines_shared::cfg_common_params::CommonArchCli; |
| 5 | use flowey::node::prelude::ReadVar; |
| 6 | use flowey::pipeline::prelude::*; |
| 7 | |
| 8 | /// Download and restore packages needed for building the specified architectures. |
| 9 | #[derive(clap::Args)] |
| 10 | pub struct RestorePackagesCli { |
| 11 | /// Specify what architectures to restore packages for. |
| 12 | /// |
| 13 | /// If none are specified, defaults to just the current host architecture. |
| 14 | arch: Vec<CommonArchCli>, |
| 15 | } |
| 16 | |
| 17 | impl IntoPipeline for RestorePackagesCli { |
| 18 | fn into_pipeline(self, backend_hint: PipelineBackendHint) -> anyhow::Result<Pipeline> { |
| 19 | let openvmm_repo = flowey_lib_common::git_checkout::RepoSource::ExistingClone( |
| 20 | ReadVar::from_static(crate::repo_root()), |
| 21 | ); |
| 22 | |
| 23 | let mut pipeline = Pipeline::new(); |
| 24 | let (pub_last_release_igvm_files, _) = pipeline.new_artifact("last-release-igvm-files"); |
| 25 | let mut job = pipeline |
| 26 | .new_job( |
| 27 | FlowPlatform::host(backend_hint), |
| 28 | FlowArch::host(backend_hint), |
| 29 | "restore packages", |
| 30 | ) |
| 31 | .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request {}) |
| 32 | .dep_on( |
| 33 | |_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params { |
| 34 | hvlite_repo_source: openvmm_repo, |
| 35 | }, |
| 36 | ) |
| 37 | .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_common::Params { |
| 38 | local_only: Some(flowey_lib_hvlite::_jobs::cfg_common::LocalOnlyParams { |
| 39 | interactive: true, |
| 40 | auto_install: true, |
| 41 | force_nuget_mono: false, |
| 42 | external_nuget_auth: false, |
| 43 | ignore_rust_version: true, |
| 44 | }), |
| 45 | verbose: ReadVar::from_static(true), |
| 46 | locked: false, |
| 47 | deny_warnings: false, |
| 48 | }); |
| 49 | |
| 50 | let arches = { |
| 51 | if self.arch.is_empty() { |
| 52 | vec![FlowArch::host(backend_hint).try_into()?] |
| 53 | } else { |
| 54 | self.arch |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | let arches = arches.into_iter().map(|arch| arch.into()).collect(); |
| 59 | |
| 60 | job = job.dep_on( |
| 61 | |ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request { |
| 62 | arches, |
| 63 | done: ctx.new_done_handle(), |
| 64 | release_artifact: ctx.publish_artifact(pub_last_release_igvm_files), |
| 65 | }, |
| 66 | ); |
| 67 | job.finish(); |
| 68 | Ok(pipeline) |
| 69 | } |
| 70 | } |
| 71 | |