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

feat: support cask deps for Homebrew #855

Merged
merged 1 commit into from
Mar 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion cargo-dist/src/backend/ci/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,17 @@ fn install_dist_for_targets<'a>(
fn brewfile_from(packages: &[String]) -> String {
let brewfile_lines: Vec<String> = packages
.iter()
.map(|p| format!(r#"brew "{p}""#).to_owned())
.map(|p| {
let lower = p.to_ascii_lowercase();
// Although `brew install` can take either a formula or a cask,
// Brewfiles require you to use the `cask` verb for casks and `brew`
// for formulas.
if lower.starts_with("homebrew/cask") || lower.starts_with("homebrew/homebrew-cask") {
format!(r#"cask "{p}""#).to_owned()
} else {
format!(r#"brew "{p}""#).to_owned()
}
})
.collect();

brewfile_lines.join("\n")
Expand Down
37 changes: 37 additions & 0 deletions cargo-dist/tests/integration-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,43 @@ path-guid = "BFD25009-65A4-4D1E-97F1-0030465D90D6"
})
}

#[test]
fn axolotlsay_homebrew_packages() -> Result<(), miette::Report> {
let test_name = _function_name!();
AXOLOTLSAY.run_test(|ctx| {
let dist_version = ctx.tools.cargo_dist.version().unwrap();
ctx.patch_cargo_toml(format!(
r#"
[workspace.metadata.dist]
cargo-dist-version = "{dist_version}"
installers = ["shell", "powershell", "homebrew", "npm", "msi"]
tap = "axodotdev/homebrew-packages"
publish-jobs = ["homebrew"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"]
ci = ["github"]
unix-archive = ".tar.gz"
windows-archive = ".tar.gz"
scope = "@axodotdev"

[workspace.metadata.dist.dependencies.homebrew]
"homebrew/cask/macfuse" = "*"
libcue = "2.3.0"

"#
))?;

// Run generate to make sure stuff is up to date before running other commands
let ci_result = ctx.cargo_dist_generate(test_name)?;
let ci_snap = ci_result.check_all()?;
// Do usual build+plan checks
let main_result = ctx.cargo_dist_build_and_plan(test_name)?;
let main_snap = main_result.check_all(ctx, ".cargo/bin/")?;
// snapshot all
main_snap.join(ci_snap).snap();
Ok(())
})
}

#[test]
fn akaikatana_basic() -> Result<(), miette::Report> {
let test_name = _function_name!();
Expand Down