Skip to content

Commit

Permalink
Fix lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Sep 20, 2023
1 parent c2e6b2f commit 4b4b840
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 49 deletions.
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
14 changes: 7 additions & 7 deletions crates/core/action/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ impl ActionNode {
match self {
ActionNode::InstallDeps(runtime) => {
if runtime.requirement.is_latest() {
format!("Install{}Deps", runtime.platform)
format!("Install{}Deps", runtime)
} else {
format!("Install{}Deps({})", runtime.platform, runtime.requirement)
format!("Install{}Deps({})", runtime, runtime.requirement)
}
}
ActionNode::InstallProjectDeps(runtime, id) => {
if runtime.requirement.is_latest() {
format!("Install{}DepsInProject({id})", runtime.platform)
format!("Install{}DepsInProject({id})", runtime)
} else {
format!(
"Install{}DepsInProject({}, {id})",
runtime.platform, runtime.requirement
runtime, runtime.requirement
)
}
}
Expand All @@ -57,13 +57,13 @@ impl ActionNode {
ActionNode::RunPersistentTarget(_, id) => format!("RunPersistentTarget({id})"),
ActionNode::SetupTool(runtime) => {
if runtime.requirement.is_latest() {
format!("Setup{}Tool", runtime.platform)
format!("Setup{}Tool", runtime)
} else {
format!("Setup{}Tool({})", runtime.platform, runtime.requirement)
format!("Setup{}Tool({})", runtime, runtime.requirement)
}
}
ActionNode::SyncProject(runtime, id) => {
format!("Sync{}Project({id})", runtime.platform)
format!("Sync{}Project({id})", runtime)
}
ActionNode::SyncWorkspace => "SyncWorkspace".into(),
}
Expand Down
6 changes: 3 additions & 3 deletions crates/core/tool/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<T: Tool> ToolManager<T> {
}

pub fn has(&self, req: &RuntimeReq) -> bool {
self.cache.contains_key(&req)
self.cache.contains_key(req)
}

pub fn register(&mut self, req: &RuntimeReq, tool: T) {
Expand All @@ -52,14 +52,14 @@ impl<T: Tool> ToolManager<T> {
req: &RuntimeReq,
last_versions: &mut FxHashMap<String, Version>,
) -> miette::Result<u8> {
match self.cache.get_mut(&req) {
match self.cache.get_mut(req) {
Some(cache) => Ok(cache.setup(last_versions).await?),
None => Err(ToolError::UnknownTool(self.runtime.to_string()).into()),
}
}

pub async fn teardown(&mut self, req: &RuntimeReq) -> miette::Result<()> {
if let Some(mut tool) = self.cache.remove(&req) {
if let Some(mut tool) = self.cache.remove(req) {
tool.teardown().await?;
}

Expand Down
17 changes: 10 additions & 7 deletions crates/rust/platform/tests/rust_platform_test.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use moon_action_context::ActionContext;
use moon_config::{PlatformType, RustConfig};
use moon_platform::{Platform, Runtime, Version};
use moon_platform::{Platform, Runtime, RuntimeReq, VersionSpec};
use moon_process::Command;
use moon_project::Project;
use moon_rust_platform::RustPlatform;
use moon_task::Task;
use moon_test_utils::create_sandbox;
use moon_utils::string_vec;
use proto_core::{ProtoEnvironment, Version as SemVersion};
use proto_core::{ProtoEnvironment, Version};
use rustc_hash::FxHashMap;
use std::env;
use std::fs;
Expand Down Expand Up @@ -37,7 +37,7 @@ async fn create_target_command(task: Task) -> Command {
&ActionContext::default(),
&Project::default(),
&task,
&Runtime::Rust(Version::new_global()),
&Runtime::new(PlatformType::Rust, RuntimeReq::Global),
&PathBuf::from("cwd"),
)
.await
Expand Down Expand Up @@ -110,7 +110,7 @@ mod sync_project {
let mut platform = create_platform();
platform.config = RustConfig {
sync_toolchain_config: false,
version: Some(SemVersion::parse("1.70.0").unwrap()),
version: Some(Version::parse("1.70.0").unwrap()),
..RustConfig::default()
};

Expand Down Expand Up @@ -168,7 +168,7 @@ mod sync_project {
let mut platform = create_platform();
platform.config = RustConfig {
sync_toolchain_config: true,
version: Some(SemVersion::parse("1.70.0").unwrap()),
version: Some(Version::parse("1.70.0").unwrap()),
..RustConfig::default()
};

Expand Down Expand Up @@ -196,7 +196,7 @@ mod sync_project {
let mut platform = create_platform();
platform.config = RustConfig {
sync_toolchain_config: true,
version: Some(SemVersion::parse("1.70.0").unwrap()),
version: Some(Version::parse("1.70.0").unwrap()),
..RustConfig::default()
};

Expand Down Expand Up @@ -271,7 +271,10 @@ mod target_command {
&ActionContext::default(),
&Project::default(),
&task,
&Runtime::Rust(Version::new_override("1.60.0")),
&Runtime::new(
PlatformType::Rust,
RuntimeReq::ToolchainOverride(VersionSpec::parse("1.60.0").unwrap()),
),
&PathBuf::from("cwd"),
)
.await
Expand Down

0 comments on commit 4b4b840

Please sign in to comment.