Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flowey: use typestate pattern for gh variables #643

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f4f97df
try and get something working
justus-camp-microsoft Jan 9, 2025
82db3d9
fmt
justus-camp-microsoft Jan 9, 2025
ff116bb
test printing pr event
justus-camp-microsoft Jan 10, 2025
46a3016
plumb through is_object
justus-camp-microsoft Jan 10, 2025
65fed09
Merge branch 'main' into ghcontext_typestate
justus-camp-microsoft Jan 10, 2025
dcfa810
try toJSON instead
justus-camp-microsoft Jan 10, 2025
478329b
try echoing instead?
justus-camp-microsoft Jan 10, 2025
cbdd984
try another strategy
justus-camp-microsoft Jan 10, 2025
db8a9c9
add parentheses
justus-camp-microsoft Jan 10, 2025
c7f63cf
let's try jq
justus-camp-microsoft Jan 10, 2025
e360854
better typestate impl (still needs do_read de-dupe)
justus-camp-microsoft Jan 11, 2025
ebec5e1
plumb is_object through on write path
justus-camp-microsoft Jan 11, 2025
d55fc8a
add from_json
justus-camp-microsoft Jan 13, 2025
f778042
clippy
justus-camp-microsoft Jan 13, 2025
b71c81b
see what happens when the event doesn't exist
justus-camp-microsoft Jan 13, 2025
bfa2abd
remove unused events
justus-camp-microsoft Jan 13, 2025
ff200aa
remove from_json and add back test event
justus-camp-microsoft Jan 13, 2025
1d8e3ff
move event to the right place
justus-camp-microsoft Jan 13, 2025
06bade7
try another way of passing is_object through
justus-camp-microsoft Jan 14, 2025
667fbb5
add comment about not adding further behavior to GhContextVar
justus-camp-microsoft Jan 15, 2025
86f2354
Merge branch 'main' into ghcontext_typestate
justus-camp-microsoft Jan 15, 2025
3aa18b6
move to separate module
justus-camp-microsoft Jan 15, 2025
d88b355
shared helper
justus-camp-microsoft Jan 15, 2025
a5b3562
clippy
justus-camp-microsoft Jan 15, 2025
1cd416e
restructure modules, remove test event
justus-camp-microsoft Jan 16, 2025
c20f33a
move global vars to typestate without removing GhContextVar
justus-camp-microsoft Jan 16, 2025
1395a24
remove ghcontextvar
justus-camp-microsoft Jan 17, 2025
7abe491
submodule structure
justus-camp-microsoft Jan 17, 2025
3f45028
re-introduce custom secrets flow
justus-camp-microsoft Jan 17, 2025
ac30808
Merge branch 'main' into ghcontext_typestate
justus-camp-microsoft Jan 17, 2025
9f7afd1
comments
Jan 24, 2025
440251b
docs
Jan 24, 2025
a293393
doc tests
Jan 24, 2025
caca8e4
use ghvarstate for outputs
Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 111 additions & 45 deletions .github/workflows/openvmm-ci.yaml

Large diffs are not rendered by default.

156 changes: 111 additions & 45 deletions .github/workflows/openvmm-pr.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions flowey/flowey_cli/src/cli/debug/interrogate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ impl flowey_core::node::NodeCtxBackend for InterrogateCtx {
_uses: &str,
_with: BTreeMap<String, ClaimedGhParam>,
_condvar: Option<String>,
_outputs: BTreeMap<String, Vec<(String, bool)>>,
_outputs: BTreeMap<String, Vec<(String, bool, bool)>>,
_permissions: BTreeMap<GhPermission, GhPermissionValue>,
_gh_to_rust: Vec<(String, String, bool)>,
_rust_to_gh: Vec<(String, String, bool)>,
_gh_to_rust: Vec<(String, String, bool, bool)>,
_rust_to_gh: Vec<(String, String, bool, bool)>,
) {
println!("[step][yaml] # {}", label);
self.idx_tracker += 1;
Expand Down
6 changes: 3 additions & 3 deletions flowey/flowey_cli/src/cli/exec_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ impl flowey_core::node::NodeCtxBackend for ExecSnippetCtx<'_, '_> {
_uses: &str,
_with: BTreeMap<String, ClaimedGhParam>,
_condvar: Option<String>,
_outputs: BTreeMap<String, Vec<(String, bool)>>,
_outputs: BTreeMap<String, Vec<(String, bool, bool)>>,
_permissions: BTreeMap<GhPermission, GhPermissionValue>,
_gh_to_rust: Vec<(String, String, bool)>,
_rust_to_gh: Vec<(String, String, bool)>,
_gh_to_rust: Vec<(String, String, bool, bool)>,
_rust_to_gh: Vec<(String, String, bool, bool)>,
) {
self.idx_tracker += 1;
}
Expand Down
21 changes: 13 additions & 8 deletions flowey/flowey_cli/src/flow_resolver/stage1_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ pub(crate) enum Step {
>,
},
GitHubYaml {
gh_to_rust: Vec<(String, String, bool)>,
rust_to_gh: Vec<(String, String, bool)>,
gh_to_rust: Vec<(String, String, bool, bool)>,
rust_to_gh: Vec<(String, String, bool, bool)>,
label: String,
step_id: String,
uses: String,
Expand Down Expand Up @@ -779,10 +779,10 @@ impl flowey_core::node::NodeCtxBackend for EmitFlowCtx<'_> {
uses: &str,
with: BTreeMap<String, ClaimedGhParam>,
condvar: Option<String>,
outputs: BTreeMap<String, Vec<(String, bool)>>,
outputs: BTreeMap<String, Vec<(String, bool, bool)>>,
permissions: BTreeMap<GhPermission, GhPermissionValue>,
mut gh_to_rust: Vec<(String, String, bool)>,
mut rust_to_gh: Vec<(String, String, bool)>,
mut gh_to_rust: Vec<(String, String, bool, bool)>,
mut rust_to_gh: Vec<(String, String, bool, bool)>,
) {
let mut fresh_yaml_var = || {
*self.yaml_var_ordinal += 1;
Expand All @@ -803,10 +803,15 @@ impl flowey_core::node::NodeCtxBackend for EmitFlowCtx<'_> {
ClaimedGhParam::Static(v) => (k, v),
ClaimedGhParam::GhVar(v) => (k, format!("${{{{ {} }}}}", v.as_raw_var_name())),
ClaimedGhParam::FloweyVar(v) => {
let (backing_var, is_secret) = read_var_internals(&v);
let (backing_var, is_secret, is_object) = read_var_internals(&v);
let backing_var = backing_var.unwrap();
let new_gh_var_name = fresh_yaml_var();
rust_to_gh.push((backing_var.clone(), new_gh_var_name.clone(), is_secret));
rust_to_gh.push((
backing_var.clone(),
new_gh_var_name.clone(),
is_secret,
is_object,
));
(k, format!("${{{{ env.{} }}}}", new_gh_var_name))
}
})
Expand All @@ -815,7 +820,7 @@ impl flowey_core::node::NodeCtxBackend for EmitFlowCtx<'_> {
for (name, output_vars) in outputs {
for output in output_vars {
let gh_context_var_name = format!("steps.{step_id}.outputs.{name}");
gh_to_rust.push((gh_context_var_name, output.0, output.1));
gh_to_rust.push((gh_context_var_name, output.0, output.1, output.2));
}
}

Expand Down
15 changes: 10 additions & 5 deletions flowey/flowey_cli/src/pipeline_resolver/github_yaml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,12 @@ fn resolve_flow_as_github_yaml_steps(
output_steps.push(map.into());
}

for (rust_var, gh_var, is_secret) in rust_to_gh {
for (rust_var, gh_var, is_secret, is_object) in rust_to_gh {
let mut cmd = String::new();

// flowey considers all GitHub vars to be typed as raw strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stale comment - not actually true with the introduction of is_object

let set_gh_env_var =
var_db_cmd(&rust_var, is_secret, None, true, Some(gh_var.clone()));
var_db_cmd(&rust_var, is_secret, None, !is_object, Some(gh_var.clone()));
writeln!(cmd, r#"{set_gh_env_var}"#)?;

let mut map = serde_yaml::Mapping::new();
Expand Down Expand Up @@ -878,10 +878,15 @@ fn resolve_flow_as_github_yaml_steps(
output_steps.push(step);
}

for (gh_var, rust_var, is_secret) in gh_to_rust {
for (gh_var, rust_var, is_secret, is_object) in gh_to_rust {
// flowey considers all GitHub vars to be typed as raw strings
let write_rust_var = var_db_cmd(&rust_var, is_secret, Some("{0}"), true, None);
let cmd = format!(r#"${{{{ {gh_var} }}}}"#);
let write_rust_var =
var_db_cmd(&rust_var, is_secret, Some("{0}"), !is_object, None);
let cmd = if is_object {
format!(r#"${{{{ toJSON({gh_var}) }}}}"#)
} else {
format!(r#"${{{{ {gh_var} }}}}"#)
};

let mut map = serde_yaml::Mapping::new();
map.insert("run".into(), serde_yaml::Value::String(cmd));
Expand Down
Loading
Loading