Skip to content

Commit 2717d69

Browse files
damanm24Daman Mulye
andauthored
flowey: use release branches to download artifacts for servicing tests (#1897)
This PR revives: #941. It adds a new node for downloading release artifacts and uses them in servicing tests. Tests for the following servicing scenarios are added: Upgrades: 2505->latest in main Downgrades: latest in main->2505 --------- Co-authored-by: Daman Mulye <[email protected]>
1 parent f55095a commit 2717d69

File tree

21 files changed

+1527
-355
lines changed

21 files changed

+1527
-355
lines changed

.github/workflows/openvmm-ci.yaml

Lines changed: 350 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/openvmm-pr-release.yaml

Lines changed: 350 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/openvmm-pr.yaml

Lines changed: 356 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flowey/flowey_core/src/node/github_context.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ impl GhContextVarReader<'_, state::Global> {
119119

120120
/// `github.token`
121121
pub fn token(self) -> ReadVar<String> {
122-
self.read_var("github.token", true, false)
122+
// TODO: change is_secret parameter to true.
123+
// N.B. Flowey core treats all variables as secrets after a secret variable is read from. Secrecy is viral this way.
124+
// This causes unintended consequences in the job, as all subsequent variables are also treated as secrets.
125+
// We don't have a good way of fixing this issue yet. Hence, the change in parameter value here.
126+
// GitHub redacts access tokens from being printed to logs anyways, so by flipping the is_secret parameter to false, the token won't be leaked.
127+
self.read_var("github.token", false, false)
123128
}
124129
}
125130

flowey/flowey_hvlite/src/pipelines/restore_packages.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ impl IntoPipeline for RestorePackagesCli {
2121
);
2222

2323
let mut pipeline = Pipeline::new();
24+
let (_pub_last_release_igvm_files, use_last_release_igvm_files) =
25+
pipeline.new_artifact("last-release-igvm-files");
2426
let mut job = pipeline
2527
.new_job(
2628
FlowPlatform::host(backend_hint),
@@ -54,14 +56,16 @@ impl IntoPipeline for RestorePackagesCli {
5456
}
5557
};
5658

57-
for arch in arches {
58-
job = job.dep_on(
59-
|ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request {
60-
arch: arch.into(),
61-
done: ctx.new_done_handle(),
62-
},
63-
);
64-
}
59+
let arches = arches.into_iter().map(|arch| arch.into()).collect();
60+
61+
job = job.dep_on(
62+
|ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request {
63+
arches,
64+
done: ctx.new_done_handle(),
65+
release_artifact: ctx.use_artifact(&use_last_release_igvm_files),
66+
},
67+
);
68+
6569
job.finish();
6670
Ok(pipeline)
6771
}

flowey/flowey_hvlite/src/pipelines_shared/cfg_common_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn get_cfg_common_params(
105105
}
106106
}
107107

108-
#[derive(clap::ValueEnum, Clone, Copy)]
108+
#[derive(clap::ValueEnum, Clone, Copy, PartialEq)]
109109
pub enum CommonArchCli {
110110
X86_64,
111111
Aarch64,

flowey/flowey_lib_common/src/download_gh_artifact.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ flowey_request! {
2121
pub path: WriteVar<PathBuf>,
2222
/// The Github actions run id to download artifacts from
2323
pub run_id: ReadVar<String>,
24-
/// Github token to authenticate with
25-
pub gh_token: ReadVar<String>,
2624
}
2725
}
2826

@@ -43,12 +41,8 @@ impl SimpleFlowNode for Node {
4341
file_name,
4442
path,
4543
run_id,
46-
gh_token,
4744
} = request;
4845

49-
ctx.req(crate::use_gh_cli::Request::WithAuth(
50-
crate::use_gh_cli::GhCliAuth::AuthToken(gh_token),
51-
));
5246
let gh_cli = ctx.reqv(crate::use_gh_cli::Request::Get);
5347

5448
ctx.emit_rust_step("download artifacts from github actions run", |ctx| {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
//! Gets the latest completed Github workflow id for a pipeline and branch
5+
use flowey::node::prelude::*;
6+
7+
flowey_request! {
8+
pub struct Request {
9+
pub repo: String,
10+
pub pipeline_name: String,
11+
pub branch: ReadVar<String>,
12+
pub gh_workflow_id: WriteVar<String>,
13+
}
14+
}
15+
new_simple_flow_node!(struct Node);
16+
17+
impl SimpleFlowNode for Node {
18+
type Request = Request;
19+
20+
fn imports(ctx: &mut ImportCtx<'_>) {
21+
ctx.import::<crate::use_gh_cli::Node>();
22+
}
23+
24+
fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
25+
let Request {
26+
repo,
27+
gh_workflow_id,
28+
pipeline_name,
29+
branch,
30+
} = request;
31+
32+
let pipeline_name = pipeline_name.clone();
33+
34+
let gh_cli = ctx.reqv(crate::use_gh_cli::Request::Get);
35+
36+
ctx.emit_rust_step("get latest completed action id", |ctx| {
37+
let pipeline_name = pipeline_name.clone();
38+
let gh_cli = gh_cli.claim(ctx);
39+
let gh_workflow_id = gh_workflow_id.claim(ctx);
40+
let branch = branch.claim(ctx);
41+
42+
move |rt| {
43+
let sh = xshell::Shell::new()?;
44+
let gh_cli = rt.read(gh_cli);
45+
let branch = rt.read(branch);
46+
47+
let id = xshell::cmd!(
48+
sh,
49+
"{gh_cli} run list -R {repo} -b {branch} -w {pipeline_name} -s completed --limit 1 --json databaseId -q .[0].databaseId"
50+
)
51+
.read()?;
52+
53+
log::info!("Got action id {id}");
54+
rt.write(gh_workflow_id, &id);
55+
56+
Ok(())
57+
}
58+
});
59+
60+
Ok(())
61+
}
62+
}

flowey/flowey_lib_common/src/gh_workflow_id.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ flowey_request! {
1010
pub github_commit_hash: ReadVar<String>,
1111
pub repo_path: ReadVar<PathBuf>,
1212
pub pipeline_name: String,
13-
pub gh_token: ReadVar<String>,
1413
pub gh_workflow: WriteVar<GithubWorkflow>,
1514
}
1615
}
@@ -36,14 +35,10 @@ impl SimpleFlowNode for Node {
3635
github_commit_hash,
3736
gh_workflow,
3837
pipeline_name,
39-
gh_token,
4038
} = request;
4139

4240
let pipeline_name = pipeline_name.clone();
4341

44-
ctx.req(crate::use_gh_cli::Request::WithAuth(
45-
crate::use_gh_cli::GhCliAuth::AuthToken(gh_token.clone()),
46-
));
4742
let gh_cli = ctx.reqv(crate::use_gh_cli::Request::Get);
4843

4944
ctx.emit_rust_step("get action id", |ctx| {

flowey/flowey_lib_common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub mod download_nuget_exe;
3333
pub mod download_protoc;
3434
pub mod gen_cargo_nextest_run_cmd;
3535
pub mod gh_download_azure_key_vault_secret;
36+
pub mod gh_latest_completed_workflow_id;
3637
pub mod gh_task_azure_login;
3738
pub mod gh_workflow_id;
3839
pub mod git_checkout;

0 commit comments

Comments
 (0)