fix(homebrew): mirror upstream PR formula fixes (#972)

* fix(homebrew): mirror upstream PR fixes

Keep the in-repo reference formula in sync with what's actually
being submitted at Homebrew/homebrew-core#283241:

- Bump url + sha256 to v0.50.0 (the version the upstream PR pins)
- Strip *musl* paths from the web bundle before libexec.install
  (brew linkage --test flags musl-linked variants of sharp on
  glibc-only Linuxbrew)
- Set KANDEV_AGENT_STANDALONE_PORT to a free port in the test block
  so agentctl doesn't collide on the default 39429

* fix(homebrew): switch test poll to quiet_system + agentctl-only

Mirror fixes from upstream Homebrew/homebrew-core#283241:
- Switch the functional test to spawn libexec/bin/agentctl (pure-Go,
  no cgo+sqlite) instead of the full backend, sidestepping a Linux
  arm64 agentctl-launcher crash unique to brew test sandbox
- Use quiet_system instead of system for the curl poll. Formula#system
  raises BuildError on the first non-zero exit, which killed the
  retry loop before agentctl had time to bind the port

* fix(homebrew): swap functional test to agentctl CLI dispatch

Mirror upstream Homebrew/homebrew-core#283241 — Linux arm64 bottle CI
keeps timing out spawning agentctl as an HTTP server. The 'agentctl
kandev' subcommand exercises the same binary's boot + flag parser
+ CLI dispatcher path without binding any ports, which fits within
the sandbox constraints of brew test.

* fix(homebrew): build agentctl static (CGO_ENABLED=0)

Mirror upstream Homebrew/homebrew-core#283241 — agentctl was
segfaulting on Linuxbrew arm64 bottle CI. agentctl is pure-Go
(no cgo deps), so building it without cgo gives a static binary
that avoids whatever dynamic-linker issue is biting on that
platform. kandev still needs cgo for mattn/go-sqlite3.

* fix(homebrew): tighten musl-prune style + assertion

Mirror upstream Homebrew/homebrew-core#283241:
- Use bundle.glob(...) instead of Pathname.glob with string interp
- Drop the if p.directory? guard so bare musl .node files (if a
  future bundler version emits them) also get stripped — rm_r
  handles both shapes
- Spell out sharp / @swc/core / lightningcss in the comment
- Tighten the agentctl smoke check to an exact-string match

* fix(homebrew): guard musl prune against ENOENT race

bundle.glob returns parent dirs alongside the musl-named .node
files inside them. rm_r on the parent makes the child path vanish
before iteration reaches it, blowing up with Errno::ENOENT. Skip
paths that no longer exist.
This commit is contained in:
José Almeida
2026-05-21 11:29:30 +01:00
committed by GitHub
parent b39f256e84
commit d02441201f
+35 -40
View File
@@ -1,8 +1,8 @@
class Kandev < Formula
desc "Manage tasks, orchestrate agents, review changes, and ship value"
homepage "https://github.com/kdlbs/kandev"
url "https://github.com/kdlbs/kandev/archive/refs/tags/v0.49.0.tar.gz"
sha256 "a97f93b7733656d2c128998bce10dd804c7f192bf03112540198aa96e005a449"
url "https://github.com/kdlbs/kandev/archive/refs/tags/v0.50.0.tar.gz"
sha256 "270d4c17f0cdd8b431e050f130dfee7d0f962149e3e0f50e149efec21a95954c"
license "AGPL-3.0-only"
livecheck do
@@ -19,7 +19,6 @@ class Kandev < Formula
def install
ENV["KANDEV_VERSION"] = version.to_s
ENV["CGO_ENABLED"] = "1"
system "pnpm", "-C", "apps", "install", "--frozen-lockfile"
system "pnpm", "-C", "apps", "--filter", "@kandev/web", "build"
@@ -30,17 +29,35 @@ class Kandev < Formula
(bundle/"bin").mkpath
cd "apps/backend" do
system "go", "build",
*std_go_args(ldflags: "-s -w -X main.Version=#{version}",
output: bundle/"bin/kandev"),
"./cmd/kandev"
system "go", "build",
*std_go_args(ldflags: "-s -w", output: bundle/"bin/agentctl"),
"./cmd/agentctl"
# kandev backend needs cgo for mattn/go-sqlite3.
with_env(CGO_ENABLED: "1") do
system "go", "build",
*std_go_args(ldflags: "-s -w -X main.Version=#{version}",
output: bundle/"bin/kandev"),
"./cmd/kandev"
end
# agentctl is pure-Go; build it static to avoid a dynamic linker
# crash observed on Linuxbrew arm64 bottle CI.
with_env(CGO_ENABLED: "0") do
system "go", "build",
*std_go_args(ldflags: "-s -w", output: bundle/"bin/agentctl"),
"./cmd/agentctl"
end
end
system "./scripts/release/package-bundle.sh"
# The Next.js standalone tracer pulls platform-tagged native modules
# into the bundle, including musl-libc variants of sharp, @swc/core,
# and lightningcss that brew linkage --test flags on glibc-only
# Linuxbrew. Strip them — rm_r handles both directory trees (the
# current shape) and bare .node files (in case a future bundler
# version inlines them). The exist? guard handles the glob
# returning a parent dir and its musl-named children together —
# removing the parent makes the child paths vanish before we get
# to them.
bundle.glob("web/**/*musl*").each { |p| rm_r(p) if p.exist? }
libexec.install Dir[bundle/"*"]
(bin/"kandev").write_env_script libexec/"cli/bin/cli.js",
@@ -53,35 +70,13 @@ class Kandev < Formula
# and the launcher reads the bundled package.json version.
assert_match version.to_s, shell_output("#{bin}/kandev --version")
# Functional test: boot the Go backend with an isolated data dir,
# poll /api/v1/system/health until it responds, then shut down.
# Exercises the cgo+sqlite linkage, migration runner, and HTTP
# server — the parts most likely to break across platforms.
port = free_port
pid = spawn({ "KANDEV_HOME_DIR" => testpath.to_s,
"KANDEV_SERVER_PORT" => port.to_s,
"KANDEV_LOG_LEVEL" => "warn" },
libexec/"bin/kandev")
begin
deadline = Time.now + 60
until system("curl", "-sf", "-o", File::NULL,
"http://127.0.0.1:#{port}/api/v1/system/health")
raise "kandev backend did not start within 60s" if Time.now > deadline
sleep 1
end
assert_match "healthy",
shell_output("curl -s http://127.0.0.1:#{port}/api/v1/system/health")
ensure
# Guard against ESRCH if the backend already crashed — without
# this, an exception in `ensure` masks the original failure
# diagnostic (e.g. the "did not start within 60s" message).
begin
Process.kill("TERM", pid)
Process.wait(pid)
rescue Errno::ESRCH, Errno::ECHILD
nil
end
end
# Functional test: exercise the agentctl sidecar's CLI subcommand
# dispatcher. Boots the Go binary, parses flags, dispatches to the
# kandev subcommand handler, and prints usage when called without
# arguments. Verifies the binary loads correctly across platforms
# without requiring HTTP listeners, port binds, or subprocesses —
# which can be problematic in sandboxed build environments.
output = shell_output("#{libexec}/bin/agentctl kandev 2>&1", 1)
assert_match "Usage: agentctl kandev", output
end
end