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

plan should warn if target that has no default github runner is specified w/o a configured custom runner #977

Open
ashleygwilliams opened this issue Apr 30, 2024 · 1 comment
Labels
bug Something isn't working feature request New feature or request good first issue Good for newcomers

Comments

@ashleygwilliams
Copy link
Member

we currently support an infinite number of targets in the targets array, but github has a finite and specified number of default runners. if someone adds a target that does not have a default runner, AND does not specify a custom runner, we should have plan error. ideally, this means that cargo-dist will catch the error on the configuration update and not when someone is trying to release.

@ashleygwilliams ashleygwilliams added bug Something isn't working feature request New feature or request labels Apr 30, 2024
@Gankra Gankra added the good first issue Good for newcomers label May 9, 2024
@Gankra
Copy link
Member

Gankra commented May 9, 2024

So this is an interesting one in that there's a few different interacting checks.

Here we do a preliminary selection of what github runner to use for a given target triple, but in a very loose/permissive way:

fn github_runner_for_target(
target: &TargetTriple,
custom_runners: &HashMap<String, String>,
) -> Option<GithubRunner> {
if let Some(runner) = custom_runners.get(target) {
return Some(runner.to_owned());
}
// We want to default to older runners to minimize the places
// where random system dependencies can creep in and be very
// recent. This helps with portability!
if target.contains("linux") {
Some(GITHUB_LINUX_RUNNER.to_owned())
} else if target.contains("x86_64-apple") {
Some(GITHUB_MACOS_INTEL_RUNNER.to_owned())
} else if target.contains("aarch64-apple") {
Some(GITHUB_MACOS_ARM64_RUNNER.to_owned())
} else if target.contains("windows") {
Some(GITHUB_WINDOWS_RUNNER.to_owned())
} else {
None
}

And here we check that result and warn if it returned None:

let default = GITHUB_LINUX_RUNNER;
warn!("not sure which github runner should be used for {target}, assuming {default}");
default.to_owned()

So we do have a warning and it does fire after init/plan, but the "real" issue is that the preliminary selection is really generous, and arguably should be changed to be more strict, especially now that we have a proper config for the user to disambiguate (the looseness here was basically trying to let stuff work in a world where the user was doomed if we didn't pick something).

Also of note is this code that selects and expression for how to install cargo-dist for a given target triple, again very loose:

/// Select the cargo-dist installer approach for a given Github Runner
fn install_dist_for_targets<'a>(
targets: &'a [&'a TargetTriple],
install_sh: &'a str,
install_ps1: &'a str,
) -> &'a str {
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!?")
}

This code is ~fine for now since we need to have builds for the platform for it to work.


So the "fix" here is:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature request New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants