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

internal: Rewrite platform runtime logic. #1062

Merged
merged 9 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/core/action-pipeline/src/actions/install_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub async fn install_deps(
) -> miette::Result<ActionStatus> {
env::set_var("MOON_RUNNING_ACTION", "install-deps");

if matches!(runtime, Runtime::System) {
if runtime.platform.is_system() {
return Ok(ActionStatus::Skipped);
}

Expand Down
10 changes: 4 additions & 6 deletions crates/core/action-pipeline/src/actions/setup_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn setup_tool(
) -> miette::Result<ActionStatus> {
env::set_var("MOON_RUNNING_ACTION", "setup-tool");

if matches!(runtime, Runtime::System) {
if runtime.platform.is_system() {
return Ok(ActionStatus::Skipped);
}

Expand All @@ -40,11 +40,9 @@ pub async fn setup_tool(
let workspace = workspace.write().await;
let context = context.read().await;

let mut state = workspace.cache_engine.cache_state::<ToolState>(format!(
"tool{}-{}.json",
runtime,
runtime.version()
))?;
let mut state = workspace
.cache_engine
.cache_state::<ToolState>(format!("tool{}-{}.json", runtime, runtime.requirement))?;

// Install and setup the specific tool + version in the toolchain!
let installed_count = PlatformManager::write()
Expand Down
2 changes: 1 addition & 1 deletion crates/core/action-pipeline/src/subscribers/moonbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl Subscriber for MoonbaseSubscriber {

// Create a fake action label so that we can check the CI cache
let action_label =
ActionNode::RunTarget(Runtime::System, (*target).to_owned())
ActionNode::RunTarget(Runtime::system(), (*target).to_owned())
.label();
let job_id = self.job_ids.get(&action_label).cloned();

Expand Down
48 changes: 24 additions & 24 deletions crates/core/action-pipeline/tests/estimator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod estimator {
let est = Estimator::calculate(
&[Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "proj:task".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "proj:task".into())),
..Action::default()
}],
Duration::new(5, 0),
Expand All @@ -58,27 +58,27 @@ mod estimator {
&[
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(5, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:lint".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(15, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "b:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "b:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(8, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "c:test".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "c:test".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(12, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "d:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "d:lint".into())),
..Action::default()
},
],
Expand Down Expand Up @@ -113,17 +113,17 @@ mod estimator {
&[
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::SetupTool(Runtime::System)),
node: Some(ActionNode::SetupTool(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(25, 0)),
node: Some(ActionNode::InstallDeps(Runtime::System)),
node: Some(ActionNode::InstallDeps(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "proj:task".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "proj:task".into())),
..Action::default()
},
],
Expand Down Expand Up @@ -153,7 +153,7 @@ mod estimator {
let est = Estimator::calculate(
&[Action {
duration: Some(Duration::new(3, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "proj:task".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "proj:task".into())),
status: ActionStatus::Cached,
..Action::default()
}],
Expand Down Expand Up @@ -181,37 +181,37 @@ mod estimator {
&[
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::SetupTool(Runtime::System)),
node: Some(ActionNode::SetupTool(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(25, 0)),
node: Some(ActionNode::InstallDeps(Runtime::System)),
node: Some(ActionNode::InstallDeps(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(5, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:lint".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(15, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "b:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "b:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(8, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "c:test".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "c:test".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(12, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "d:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "d:lint".into())),
..Action::default()
},
],
Expand Down Expand Up @@ -250,37 +250,37 @@ mod estimator {
&[
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::SetupTool(Runtime::System)),
node: Some(ActionNode::SetupTool(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(25, 0)),
node: Some(ActionNode::InstallDeps(Runtime::System)),
node: Some(ActionNode::InstallDeps(Runtime::system())),
..Action::default()
},
Action {
duration: Some(Duration::new(10, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(5, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "a:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "a:lint".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(15, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "b:build".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "b:build".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(8, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "c:test".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "c:test".into())),
..Action::default()
},
Action {
duration: Some(Duration::new(12, 0)),
node: Some(ActionNode::RunTarget(Runtime::System, "d:lint".into())),
node: Some(ActionNode::RunTarget(Runtime::system(), "d:lint".into())),
..Action::default()
},
],
Expand Down
2 changes: 1 addition & 1 deletion crates/core/action/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
moon_common = { path = "../../../nextgen/common" }
moon_platform_runtime = { path = "../platform-runtime" }
moon_platform_runtime = { path = "../../../nextgen/platform-runtime" }
moon_target = { path = "../../../nextgen/target" }
moon_utils = { path = "../utils" }
miette = { workspace = true }
Expand Down
37 changes: 18 additions & 19 deletions crates/core/action/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,36 @@ pub enum ActionNode {
impl ActionNode {
pub fn label(&self) -> String {
match self {
ActionNode::InstallDeps(platform) => {
let version = platform.version();

if version.is_latest() {
format!("Install{platform}Deps")
ActionNode::InstallDeps(runtime) => {
if runtime.requirement.is_global() {
format!("Install{}Deps", runtime)
} else {
format!("Install{platform}Deps({version})")
format!("Install{}Deps({})", runtime, runtime.requirement)
}
}
ActionNode::InstallProjectDeps(platform, id) => {
let version = platform.version();

if version.is_latest() {
format!("Install{platform}DepsInProject({id})")
ActionNode::InstallProjectDeps(runtime, id) => {
if runtime.requirement.is_global() {
format!("Install{}DepsInProject({id})", runtime)
} else {
format!("Install{platform}DepsInProject({version}, {id})")
format!(
"Install{}DepsInProject({}, {id})",
runtime, runtime.requirement
)
}
}
ActionNode::RunTarget(_, id) => format!("RunTarget({id})"),
ActionNode::RunInteractiveTarget(_, id) => format!("RunInteractiveTarget({id})"),
ActionNode::RunPersistentTarget(_, id) => format!("RunPersistentTarget({id})"),
ActionNode::SetupTool(platform) => {
let version = platform.version();

if version.is_latest() {
format!("Setup{platform}Tool")
ActionNode::SetupTool(runtime) => {
if runtime.requirement.is_global() {
format!("Setup{}Tool", runtime)
} else {
format!("Setup{platform}Tool({version})")
format!("Setup{}Tool({})", runtime, runtime.requirement)
}
}
ActionNode::SyncProject(platform, id) => format!("Sync{platform}Project({id})"),
ActionNode::SyncProject(runtime, id) => {
format!("Sync{}Project({id})", runtime)
}
ActionNode::SyncWorkspace => "SyncWorkspace".into(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/dep-graph/src/dep_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl<'ws> DepGraphBuilder<'ws> {
return pair.clone();
}

let mut project_runtime = Runtime::System;
let mut workspace_runtime = Runtime::System;
let mut project_runtime = Runtime::system();
let mut workspace_runtime = Runtime::system();

if let Some(platform) = PlatformManager::read().find(|p| match task {
Some(task) => p.matches(&task.platform, None),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/emitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ harness = false
[dependencies]
moon_action = { path = "../action" }
moon_action_context = { path = "../action-context" }
moon_platform_runtime = { path = "../platform-runtime" }
moon_platform_runtime = { path = "../../../nextgen/platform-runtime" }
moon_project = { path = "../../../nextgen/project" }
moon_target = { path = "../../../nextgen/target" }
moon_task = { path = "../../../nextgen/task" }
Expand Down
5 changes: 0 additions & 5 deletions crates/core/platform-runtime/src/lib.rs

This file was deleted.

56 changes: 0 additions & 56 deletions crates/core/platform-runtime/src/runtime.rs

This file was deleted.

Loading