From 55c9bdd4d306fa43d3dc5cd4aa82328907b214a5 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 | 4 --- 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(+), 43 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e125cb8d8..5d79e6959 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,14 +27,10 @@ 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" -[workspace.metadata.dist.custom-runners] -aarch64-unknown-linux-gnu = "buildjet-16vcpu-ubuntu-2204-arm" - # The profile that 'cargo dist' will build with [profile.dist] inherits = "release" 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 a2b8a7c18..5e33b79a1 100644 --- a/cargo-dist/src/config.rs +++ b/cargo-dist/src/config.rs @@ -273,9 +273,9 @@ pub struct DistMetadata { #[serde(skip_serializing_if = "Option::is_none")] pub hosting: 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 { @@ -312,7 +312,7 @@ impl DistMetadata { ssldotcom_windows_sign: _, msvc_crt_static: _, hosting: _, - custom_runners: _, + github_custom_runners: _, } = self; if let Some(include) = include { for include in include { @@ -358,7 +358,7 @@ impl DistMetadata { ssldotcom_windows_sign, msvc_crt_static, hosting, - custom_runners, + github_custom_runners, } = self; // Check for global settings on local packages @@ -450,8 +450,8 @@ impl DistMetadata { if publish_jobs.is_none() { *publish_jobs = workspace_config.publish_jobs.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 e5472d203..388f08e0c 100644 --- a/cargo-dist/src/init.rs +++ b/cargo-dist/src/init.rs @@ -251,7 +251,7 @@ fn get_new_dist_metadata( ssldotcom_windows_sign: None, msvc_crt_static: None, hosting: None, - custom_runners: None, + github_custom_runners: None, } }; @@ -771,7 +771,7 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { ssldotcom_windows_sign, msvc_crt_static, hosting, - custom_runners, + github_custom_runners: _, } = &meta; apply_optional_value( @@ -965,11 +965,12 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { hosting.as_ref(), ); + // 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 9fdbe05e1..1db3a09ee 100644 --- a/cargo-dist/src/lib.rs +++ b/cargo-dist/src/lib.rs @@ -307,7 +307,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 bd3e797ee..c748cc576 100644 --- a/cargo-dist/src/tasks.rs +++ b/cargo-dist/src/tasks.rs @@ -197,8 +197,8 @@ pub struct DistGraph { pub msvc_crt_static: bool, /// List of hosting providers to use pub hosting: Option, - /// 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 @@ -712,7 +712,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { allow_dirty, msvc_crt_static, hosting, - custom_runners: _, + github_custom_runners: _, } = &workspace_metadata; let desired_cargo_dist_version = cargo_dist_version.clone(); @@ -824,8 +824,8 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { allow_dirty, msvc_crt_static, hosting, - custom_runners: workspace_metadata - .custom_runners + github_custom_runners: workspace_metadata + .github_custom_runners .clone() .unwrap_or_default(), },