Skip to content

Commit

Permalink
Merge pull request #855 from axodotdev/brew_bundle_workaround
Browse files Browse the repository at this point in the history
feat: support cask deps for Homebrew
  • Loading branch information
mistydemeo committed Mar 19, 2024
2 parents d9f417d + d855cab commit a6e21cd
Show file tree
Hide file tree
Showing 3 changed files with 3,026 additions and 1 deletion.
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

0 comments on commit a6e21cd

Please sign in to comment.