From 93aa664c32932c182612c64f60bff62e0b225b76 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 28 Nov 2023 12:09:24 -0800 Subject: [PATCH] Rename fields. --- Cargo.toml | 1 - cargo-dist/src/backend/ci/github.rs | 39 +++++++++++++---------------- cargo-dist/src/config.rs | 12 ++++----- cargo-dist/src/init.rs | 11 ++++---- cargo-dist/src/lib.rs | 2 +- cargo-dist/src/tasks.rs | 10 ++++---- 6 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c932e60e8..79d8dd9bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,6 @@ targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc", - "aarch64-unknown-linux-gnu", ] # Publish jobs to run in CI pr-run-mode = "plan" diff --git a/cargo-dist/src/backend/ci/github.rs b/cargo-dist/src/backend/ci/github.rs index 55c1c25bd..1473f27e0 100644 --- a/cargo-dist/src/backend/ci/github.rs +++ b/cargo-dist/src/backend/ci/github.rs @@ -110,14 +110,14 @@ impl GithubCiInfo { // Figure out what Local Artifact tasks we need let local_runs = if dist.merge_tasks { - distribute_targets_to_runners_merged(local_targets, &dist.custom_runners) + distribute_targets_to_runners_merged(local_targets, &dist.github_custom_runners) } else { - distribute_targets_to_runners_split(local_targets, &dist.custom_runners) + distribute_targets_to_runners_split(local_targets, &dist.github_custom_runners) }; for (runner, targets) in local_runs { use std::fmt::Write; let install_dist = - install_dist_for_github_runner(&runner, &install_dist_sh, &install_dist_ps1); + install_dist_for_targets(&targets, &install_dist_sh, &install_dist_ps1); let mut dist_args = String::from("--artifacts=local"); for target in &targets { write!(dist_args, " --target={target}").unwrap(); @@ -194,9 +194,9 @@ impl GithubCiInfo { /// succeed (uploading itself to the draft release). /// /// In priniciple it does remove some duplicated setup work, so this is ostensibly "cheaper". -fn distribute_targets_to_runners_merged<'a, 'b>( +fn distribute_targets_to_runners_merged<'a>( targets: SortedSet<&'a TargetTriple>, - custom_runners: &'b HashMap, + custom_runners: &HashMap, ) -> std::vec::IntoIter<(GithubRunner, Vec<&'a TargetTriple>)> { let mut groups = SortedMap::>::new(); for target in targets { @@ -215,9 +215,9 @@ fn distribute_targets_to_runners_merged<'a, 'b>( /// Given a set of targets we want to build local artifacts for, map them to Github Runners /// while preferring each target gets its own runner for latency and fault-isolation. -fn distribute_targets_to_runners_split<'a, 'b>( +fn distribute_targets_to_runners_split<'a>( targets: SortedSet<&'a TargetTriple>, - custom_runners: &'b HashMap, + custom_runners: &HashMap, ) -> std::vec::IntoIter<(GithubRunner, Vec<&'a TargetTriple>)> { let mut groups = vec![]; for target in targets { @@ -265,25 +265,20 @@ fn github_runner_for_target( } /// Select the cargo-dist installer approach for a given Github Runner -fn install_dist_for_github_runner<'a>( - runner: &'a GithubRunner, +fn install_dist_for_targets<'a>( + targets: &'a [&'a TargetTriple], install_sh: &'a str, install_ps1: &'a str, ) -> &'a str { - dbg!(runner); - - if runner.contains("linux") - || runner.contains("ubuntu") - || runner.contains("apple") - || runner.contains("macos") - || runner.contains("darwin") - { - install_sh - } else if runner.contains("windows") || runner.contains("msvc") { - install_ps1 - } else { - unreachable!("internal error: unknown github runner!?") + for target in targets { + if target.contains("linux") || target.contains("apple") { + return install_sh; + } else if target.contains("windows") { + return install_ps1; + } } + + unreachable!("internal error: unknown target triple!?") } fn brewfile_from(packages: &[String]) -> String { diff --git a/cargo-dist/src/config.rs b/cargo-dist/src/config.rs index 5f67fa15a..8553acd2c 100644 --- a/cargo-dist/src/config.rs +++ b/cargo-dist/src/config.rs @@ -277,9 +277,9 @@ pub struct DistMetadata { #[serde(skip_serializing_if = "Option::is_none")] pub extra_artifacts: Option>, - /// Custom GitHub runners, mapped by triple + /// Custom GitHub runners, mapped by triple target #[serde(skip_serializing_if = "Option::is_none")] - pub custom_runners: Option>, + pub github_custom_runners: Option>, } impl DistMetadata { @@ -317,7 +317,7 @@ impl DistMetadata { msvc_crt_static: _, hosting: _, extra_artifacts: _, - custom_runners: _, + github_custom_runners: _, } = self; if let Some(include) = include { for include in include { @@ -364,7 +364,7 @@ impl DistMetadata { msvc_crt_static, hosting, extra_artifacts, - custom_runners, + github_custom_runners, } = self; // Check for global settings on local packages @@ -459,8 +459,8 @@ impl DistMetadata { if extra_artifacts.is_none() { *extra_artifacts = workspace_config.extra_artifacts.clone(); } - if custom_runners.is_none() { - *custom_runners = workspace_config.custom_runners.clone(); + if github_custom_runners.is_none() { + *github_custom_runners = workspace_config.github_custom_runners.clone(); } // This was historically implemented as extend, but I'm not convinced the diff --git a/cargo-dist/src/init.rs b/cargo-dist/src/init.rs index a97c13542..55cbf2b8c 100644 --- a/cargo-dist/src/init.rs +++ b/cargo-dist/src/init.rs @@ -252,7 +252,7 @@ fn get_new_dist_metadata( msvc_crt_static: None, hosting: None, extra_artifacts: None, - custom_runners: None, + github_custom_runners: None, } }; @@ -773,7 +773,7 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { msvc_crt_static, hosting, extra_artifacts: _, - custom_runners: _, + github_custom_runners: _, } = &meta; apply_optional_value( @@ -967,11 +967,12 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { hosting.as_ref(), ); + // NOTE: HashMap not supported by axoasset // apply_optional_value( // table, - // "custom_runners", - // "# Custom GitHub runners to use for builds, mapped by triple\n", - // custom_runners.as_ref(), + // "github-custom-runners", + // "# Custom GitHub runners to use for builds, mapped by triple target\n", + // github_custom_runners.as_ref(), // ); // Finalize the table diff --git a/cargo-dist/src/lib.rs b/cargo-dist/src/lib.rs index 37c56c024..77a3e5af7 100644 --- a/cargo-dist/src/lib.rs +++ b/cargo-dist/src/lib.rs @@ -308,7 +308,7 @@ fn do_generate_preflight_checks(dist: &DistGraph) -> Result<()> { && !desired_version.pre.starts_with("github-") && !matches!(dist.allow_dirty, DirtyMode::AllowAll) { - // return Err(miette!("you're running cargo-dist {}, but 'cargo-dist-version = {}' is set in your Cargo.toml\n\nYou should update cargo-dist-version if you want to update to this version", current_version, desired_version)); + return Err(miette!("you're running cargo-dist {}, but 'cargo-dist-version = {}' is set in your Cargo.toml\n\nYou should update cargo-dist-version if you want to update to this version", current_version, desired_version)); } } if !dist.is_init { diff --git a/cargo-dist/src/tasks.rs b/cargo-dist/src/tasks.rs index 3b5ba261d..a620eace0 100644 --- a/cargo-dist/src/tasks.rs +++ b/cargo-dist/src/tasks.rs @@ -199,8 +199,8 @@ pub struct DistGraph { pub hosting: Option, /// Additional artifacts to build and upload pub extra_artifacts: Vec, - /// Custom GitHub runners, mapped by triple - pub custom_runners: HashMap, + /// Custom GitHub runners, mapped by triple target + pub github_custom_runners: HashMap, } /// Info about artifacts should be hosted @@ -737,7 +737,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { msvc_crt_static, hosting, extra_artifacts, - custom_runners: _, + github_custom_runners: _, } = &workspace_metadata; let desired_cargo_dist_version = cargo_dist_version.clone(); @@ -850,8 +850,8 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { msvc_crt_static, hosting, extra_artifacts: extra_artifacts.clone().unwrap_or_default(), - custom_runners: workspace_metadata - .custom_runners + github_custom_runners: workspace_metadata + .github_custom_runners .clone() .unwrap_or_default(), },